rename 'category-map' to 'config-map' (#7612)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
"actions": [],
|
||||
"input" : null,
|
||||
"netrc" : false,
|
||||
"category-map": {
|
||||
"config-map": {
|
||||
"coomerparty": "coomer",
|
||||
"kemonoparty": "kemono",
|
||||
"koharu" : "schalenetwork"
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user