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

View File

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

View File

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

View File

@@ -162,12 +162,24 @@ def status():
stdout_write(fmt(path, status)) stdout_write(fmt(path, status))
def rename_categories(cmap): def remap_categories():
opts = _config.get("extractor") opts = _config.get("extractor")
if not opts: if not opts:
return 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: if old in opts and new not in opts:
opts[new] = opts[old] opts[new] = opts[old]