From 239e07c7bad93c5f1fd0d483b4bac542b4de6633 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 30 Jan 2022 03:52:02 -0500 Subject: [PATCH] sync dynamic collections --- modules/meta.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/meta.py b/modules/meta.py index 9a2fc83a..8973e122 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -301,6 +301,7 @@ class MetadataFile(DataFile): title_format = default_title_format titles = util.parse("Config", "titles", dynamic, parent=map_name, methods=methods, datatype="dict") if "titles" in methods else {} test = util.parse("Config", "test", dynamic, parent=map_name, methods=methods, default=False, datatype="bool") if "test" in methods else False + sync = util.parse("Config", "sync", dynamic, parent=map_name, methods=methods, default=False, datatype="bool") if "sync" in methods else False if "<>" in title_format: title_format = title_format.replace("<>", library.type) dictionary_variables = util.parse("Config", "dictionary_variables", dynamic, parent=map_name, methods=methods, datatype="dictdict") if "dictionary_variables" in methods else {} @@ -315,6 +316,7 @@ class MetadataFile(DataFile): template_name = map_name remove_prefix = util.parse("Config", "remove_prefix", dynamic, parent=map_name, methods=methods, datatype="commalist") if "remove_prefix" in methods else [] remove_suffix = util.parse("Config", "remove_suffix", dynamic, parent=map_name, methods=methods, datatype="commalist") if "remove_suffix" in methods else [] + sync = {i.title: i for i in self.library.search(libtype="collection", label=str(map_name))} if sync else {} for key, value in auto_list.items(): template_call = {"name": template_name, auto_type: [key].extend(add_ons[key]) if key in add_ons else key} for k, v in dictionary_variables.items(): @@ -333,10 +335,15 @@ class MetadataFile(DataFile): if collection_title in col_names: logger.warning(f"Config Warning: Skipping duplicate collection: {collection_title}") else: - col = {"template": template_call} + col = {"template": template_call, "label": str(map_name)} if test: col["test"] = True + if collection_title in sync: + sync.pop(collection_title) self.collections[collection_title] = col + for col_title, col in sync.items(): + col.delete() + logger.info(f"{map_name} Dynamic Collection: {col_title} Deleted") except Failed as e: logger.error(e) logger.error(f"{map_name} Dynamic Collection Failed")