From 358f6d4c36ac72a82a01ba6c657e1316852e74ad Mon Sep 17 00:00:00 2001 From: Floreal Cabanettes <floreal.cabanettes@inra.fr> Date: Tue, 13 Jun 2017 15:51:29 +0200 Subject: [PATCH] xlsxwriter as optional dependency --- build_results.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/build_results.py b/build_results.py index 6034a9c..cc4ba65 100755 --- a/build_results.py +++ b/build_results.py @@ -21,8 +21,6 @@ import string import os import re -import xlsxwriter - import sys prg_path = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(prg_path, "lib")) @@ -499,6 +497,13 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce :param cells_gq: cells for third sheet (genotype quality) :param max_col_len: max content length for each column """ + + try: + import xlsxwriter + except ImportError: + print("Excel file not built: xslxwriter python module not installed") + return False + with xlsxwriter.Workbook(args.output + ".xslx") as workbook: ################################# @@ -553,6 +558,16 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb_per_tool: int, records_range: ()): + """ + Create tabulated separated values file + :param filename: filename of the file + :param headers: headers of each sheet + :param cells: cells of the table to save + :param nb_tools: number of tools + :param nb_per_tool: number per tools + :param records_range: range of records to treat {tuple(2)} + :return: + """ # Init rows: head = ["", headers[0]] top_headers = {} @@ -590,8 +605,6 @@ def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb tsv_file.write(tsv) - -# noinspection PyUnresolvedReferences def main(): # parse the command line args args = get_args() -- GitLab