add 'category-map' option
primarily to achieve some form of backwards compatibility for
922c296482
This commit is contained in:
@@ -7484,6 +7484,22 @@ Description
|
||||
or by `extractor.modules`_.
|
||||
|
||||
|
||||
extractor.category-map
|
||||
----------------------
|
||||
Type
|
||||
``object`` (`category` -> `category`)
|
||||
Default
|
||||
.. code:: json
|
||||
|
||||
{
|
||||
"coomerparty": "coomer",
|
||||
"kemonoparty": "kemono",
|
||||
"koharu" : "schalenetwork"
|
||||
}
|
||||
Description
|
||||
A JSON ``object`` mapping category names to their replacements.
|
||||
|
||||
|
||||
globals
|
||||
-------
|
||||
Type
|
||||
|
||||
@@ -79,6 +79,11 @@
|
||||
"actions": [],
|
||||
"input" : null,
|
||||
"netrc" : false,
|
||||
"category-map": {
|
||||
"coomerparty": "coomer",
|
||||
"kemonoparty": "kemono",
|
||||
"koharu" : "schalenetwork"
|
||||
},
|
||||
"extension-map": {
|
||||
"jpeg": "jpg",
|
||||
"jpe" : "jpg",
|
||||
|
||||
@@ -188,6 +188,17 @@ 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)
|
||||
|
||||
# extractor modules
|
||||
modules = config.get(("extractor",), "modules")
|
||||
if modules is not None:
|
||||
|
||||
@@ -162,6 +162,16 @@ def status():
|
||||
stdout_write(fmt(path, status))
|
||||
|
||||
|
||||
def rename_categories(cmap):
|
||||
opts = _config.get("extractor")
|
||||
if not opts:
|
||||
return
|
||||
|
||||
for old, new in cmap.items():
|
||||
if old in opts and new not in opts:
|
||||
opts[new] = opts[old]
|
||||
|
||||
|
||||
def load(files=None, strict=False, loads=util.json_loads):
|
||||
"""Load JSON configuration files"""
|
||||
for pathfmt in files or _default_configs:
|
||||
|
||||
Reference in New Issue
Block a user