From 4cd1df4ace2e0cd6f3fdddfc22a41af70cf2895c Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 30 Oct 2023 15:21:42 +0100 Subject: [PATCH 1/2] reorder imports --- CTDopts/CTDopts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CTDopts/CTDopts.py b/CTDopts/CTDopts.py index e4cc794..a6e6924 100644 --- a/CTDopts/CTDopts.py +++ b/CTDopts/CTDopts.py @@ -1,9 +1,10 @@ import argparse -from itertools import chain import collections import collections.abc +from itertools import chain from xml.etree.ElementTree import Element, SubElement, tostring, parse from xml.dom.minidom import parseString + import warnings # dummy classes for input-file and output-file CTD types. From 67245752c72355d691e10736676992e4287c626f Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 30 Oct 2023 15:28:21 +0100 Subject: [PATCH 2/2] drop warnings in favor or logging --- CTDopts/CTDopts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CTDopts/CTDopts.py b/CTDopts/CTDopts.py index a6e6924..6abff48 100644 --- a/CTDopts/CTDopts.py +++ b/CTDopts/CTDopts.py @@ -1,11 +1,11 @@ import argparse import collections import collections.abc +import logging from itertools import chain from xml.etree.ElementTree import Element, SubElement, tostring, parse from xml.dom.minidom import parseString -import warnings # dummy classes for input-file and output-file CTD types. @@ -225,7 +225,7 @@ def _translate_ctd_to_param(attribs): else: # there is nothing we can split with... so we will assume that this is a restriction of one possible # value... anyway, the user should be warned about it - warnings.warn( + logging.warning( "Restriction [%s] of a single value found for parameter [%s]. \n" "Restrictions should be comma separated value lists or colon separated values to " "indicate numeric ranges (e.g., 'true,false', '0:14', '1:', ':2.8')\n" @@ -1248,7 +1248,7 @@ def validate_args( enforce_type ): # but raise a warning or exception depending on enforcement level if enforce_type == 1: - warnings.warn( + logging.warning( "Argument %s is of wrong type. Expected %s, got: %s" % (":".join(lineage), TYPE_TO_CTDTYPE[param.type], arg) ) @@ -1261,7 +1261,7 @@ def validate_args( and not param.restrictions.check(validated_value) ): if enforce_restrictions == 1: - warnings.warn( + logging.warning( "Argument restrictions for %s violated. Restriction: %s. Value: %s" % ( ":".join(lineage), @@ -1280,7 +1280,7 @@ def validate_args( if not enforce_required: continue # this argument will be missing from the dict as required fields have no default value elif enforce_required == 1: - warnings.warn( + logging.warning( "Required argument %s missing" % ":".join(lineage), UserWarning, )