rename 'category-map' to 'config-map' (#7612)

This commit is contained in:
Mike Fährmann
2025-06-03 20:22:15 +02:00
parent 4fc719bb10
commit 99bf92364a
4 changed files with 21 additions and 16 deletions

View File

@@ -7494,8 +7494,8 @@ Description
or by `extractor.modules`_.
extractor.category-map
----------------------
extractor.config-map
--------------------
Type
``object`` (`category` -> `category`)
Default
@@ -7507,7 +7507,8 @@ Default
"koharu" : "schalenetwork"
}
Description
A JSON ``object`` mapping category names to their replacements.
Duplicate the configuration settings of extractor `categories`
to other names.
globals

View File

@@ -79,7 +79,7 @@
"actions": [],
"input" : null,
"netrc" : false,
"category-map": {
"config-map": {
"coomerparty": "coomer",
"kemonoparty": "kemono",
"koharu" : "schalenetwork"

View File

@@ -188,16 +188,8 @@ def main():
ujob = update.UpdateJob(extr)
return ujob.run()
# category remapping
cmap = config.interpolate(("extractor",), "category-map")
if cmap is None:
cmap = {
"coomerparty": "coomer",
"kemonoparty": "kemono",
"koharu" : "schalenetwork",
}
if cmap:
config.rename_categories(cmap)
# category renaming
config.remap_categories()
# extractor modules
modules = config.get(("extractor",), "modules")

View File

@@ -162,12 +162,24 @@ def status():
stdout_write(fmt(path, status))
def rename_categories(cmap):
def remap_categories():
opts = _config.get("extractor")
if not opts:
return
for old, new in cmap.items():
cmap = opts.get("config-map")
if cmap is None:
cmap = (
("coomerparty", "coomer"),
("kemonoparty", "kemono"),
("koharu" , "schalenetwork"),
)
elif not cmap:
return
elif isinstance(cmap, dict):
cmap = cmap.items()
for old, new in cmap:
if old in opts and new not in opts:
opts[new] = opts[old]