diff --git a/src/caosadvancedtools/crawler.py b/src/caosadvancedtools/crawler.py index dfc5351c251cb209f4e9a5b28a8caa72934d7a02..7b5251afead180906d75897c622ff9821d484a2c 100644 --- a/src/caosadvancedtools/crawler.py +++ b/src/caosadvancedtools/crawler.py @@ -66,7 +66,7 @@ def separated(text): return "-"*60 + "\n" + text -def apply_list_of_updates(to_be_updated, update_flags={}, +def apply_list_of_updates(to_be_updated, update_flags=None, update_cache=None, run_id=None): """Updates the `to_be_updated` Container, i.e., pushes the changes to LinkAhead after removing possible duplicates. If a chace is provided, uauthorized @@ -86,6 +86,8 @@ def apply_list_of_updates(to_be_updated, update_flags={}, Id with which the pending updates are cached. Only meaningful if `update_cache` is provided. Default is None. """ + if update_flags is None: + update_flags = {} if len(to_be_updated) == 0: return diff --git a/src/caosadvancedtools/models/parser.py b/src/caosadvancedtools/models/parser.py index 1cd1fe6ecabbbee4143c7c9c1b5326639c6baf50..b97e507e2c1577fd8d56c7aca5f0adc625ae1b31 100644 --- a/src/caosadvancedtools/models/parser.py +++ b/src/caosadvancedtools/models/parser.py @@ -162,7 +162,7 @@ debug : bool, optional def parse_model_from_json_schema( filename: str, top_level_recordtype: bool = True, - types_for_missing_array_items: dict = {}, + types_for_missing_array_items: dict = None, ignore_unspecified_array_items: bool = False, existing_model: Optional[dict] = None ): @@ -204,6 +204,9 @@ def parse_model_from_json_schema( about the limitations of the current implementation. """ + if types_for_missing_array_items is None: + types_for_missing_array_items = {} + if existing_model is not None: raise NotImplementedError("Adding to an existing model is not implemented yet.") @@ -706,8 +709,11 @@ class JsonSchemaParser(Parser): # @date 2022-02-17 # @review Timm Fitschen 2023-05-25 - def __init__(self, types_for_missing_array_items={}, ignore_unspecified_array_items=False): + def __init__(self, types_for_missing_array_items=None, + ignore_unspecified_array_items=False): super().__init__() + if types_for_missing_array_items is None: + types_for_missing_array_items = {} self.types_for_missing_array_items = types_for_missing_array_items self.ignore_unspecified_array_items = ignore_unspecified_array_items diff --git a/src/caosadvancedtools/table_importer.py b/src/caosadvancedtools/table_importer.py index cd1b206f7ebbe7730692a3a6a7137e4aa467a5eb..b3977b395f0e74561108baf1a783a3d5a126ed69 100755 --- a/src/caosadvancedtools/table_importer.py +++ b/src/caosadvancedtools/table_importer.py @@ -110,8 +110,7 @@ def date_converter(val, fmt="%Y-%m-%d"): return datetime_converter(val, fmt=fmt).date() -def incomplete_date_converter(val, fmts={"%Y-%m-%d": "%Y-%m-%d", - "%Y-%m": "%Y-%m", "%Y": "%Y"}): +def incomplete_date_converter(val, fmts=None): """ if the value is already a datetime, it is returned otherwise it converts it using format string @@ -124,6 +123,8 @@ def incomplete_date_converter(val, fmts={"%Y-%m-%d": "%Y-%m-%d", keys are the formats into which the input value is tried to be converted, values are the possible input formats. """ + if fmts is None: + fmts = {"%Y-%m-%d": "%Y-%m-%d", "%Y-%m": "%Y-%m", "%Y": "%Y"} for to, fro in fmts.items(): try: