From a3aba5472dfb92906f6140702e46301a848906d4 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 11 May 2022 09:22:19 -0400 Subject: [PATCH] [87] Relative Year --- VERSION | 2 +- docs/metadata/dynamic.md | 6 +++++- modules/meta.py | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index b4b657be..fd4fae54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5-develop86 +1.16.5-develop87 diff --git a/docs/metadata/dynamic.md b/docs/metadata/dynamic.md index 85df7042..1c8c2fb6 100644 --- a/docs/metadata/dynamic.md +++ b/docs/metadata/dynamic.md @@ -1597,6 +1597,10 @@ Creates a collection for each number defined. Default: 1 + @@ -1644,7 +1648,7 @@ Creates a collection for each item in the list defined . Default Template - **None** + None diff --git a/modules/meta.py b/modules/meta.py index bf650d49..40a83561 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -457,12 +457,14 @@ class MetadataFile(DataFile): else: raise Failed(f"Config Error: {map_name} data attribute not found") number_methods = {nm.lower(): nm for nm in dynamic_data} - if "starting" in number_methods and dynamic_data[number_methods["starting"]] == "current_year": - starting = datetime.now().year + if "starting" in number_methods and str(dynamic_data[number_methods["starting"]]).startswith("current_year"): + year_values = str(dynamic_data[number_methods["starting"]]).split("-") + starting = datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip())) else: starting = util.parse("Config", "starting", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=0) - if "ending" in number_methods and dynamic_data[number_methods["ending"]] == "current_year": - ending = datetime.now().year + if "ending" in number_methods and str(dynamic_data[number_methods["ending"]]).startswith("current_year"): + year_values = str(dynamic_data[number_methods["ending"]]).split("-") + ending = datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip())) else: ending = util.parse("Config", "ending", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=1) increment = util.parse("Config", "increment", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=1, minimum=1)