From 2cf9a1f0d7d9c67088e0f8457525f3f64329ed37 Mon Sep 17 00:00:00 2001 From: Michael Milton Date: Mon, 27 May 2019 16:19:04 +1000 Subject: [PATCH] =?UTF-8?q?Use=20the=20megaqc=20format=20instead=20of=20IS?= =?UTF-8?q?O=20=F0=9F=98=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- megaqc/commands.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/megaqc/commands.py b/megaqc/commands.py index c7068780..113ad093 100644 --- a/megaqc/commands.py +++ b/megaqc/commands.py @@ -19,6 +19,7 @@ HERE = os.path.abspath(os.path.dirname(__file__)) PROJECT_ROOT = os.path.join(HERE, os.pardir) TEST_PATH = os.path.join(PROJECT_ROOT, 'tests') +MEGAQC_DATE_FORMAT = "%Y-%m-%d, %H:%M" @click.command() @@ -152,12 +153,16 @@ def initdb(): db.metadata.create_all() print('Initialized the database.') +def megaqc_date_type(arg): + return datetime.strptime(arg, MEGAQC_DATE_FORMAT) @click.option( '--date', default=None, - help='Custom date to be stored for all the MultiQC files provided. Should be provided in ISO 8601 format', - type=datetime.fromisoformat + help='Custom date to be stored for all the MultiQC files provided. Should be provided in the date format {}'.format( + MEGAQC_DATE_FORMAT + ), + type=megaqc_date_type ) @click.command( context_settings=dict( help_option_names = ['-h', '--help'] ) ) @click.argument('json_files', type=click.Path(exists=True), nargs=-1, required=True, metavar="" ) @@ -203,5 +208,5 @@ def upload(json_files, date): # Patch in the date provided on the CLI if date is not None: - multiqc_json_dump['config_creation_date'] = date.strftime("%Y-%m-%d, %H:%M") + multiqc_json_dump['config_creation_date'] = date.strftime(MEGAQC_DATE_FORMAT) multiqc_megaqc.multiqc_api_post(multiqc_json_dump)