change keyword names to valid Python identifiers

This commit mostly replaces all minus-signs ('-') in keyword names with
underscores ('_') to allow them to be used in filter-expressions. For
example 'gallery-id' got renamed to 'gallery_id'.

(It is theoretically possible to access any variable, regardless of its
name, with 'locals()["NAME"]', but that seems a bit too convoluted if
just 'NAME' could be enough)
This commit is contained in:
Mike Fährmann
2017-09-10 22:20:47 +02:00
parent 81877bb5f6
commit 6f30cf4c64
28 changed files with 157 additions and 154 deletions

View File

@@ -16,8 +16,8 @@ from ..cache import cache
class NijieExtractor(AsynchronousExtractor):
"""Base class for nijie extractors"""
category = "nijie"
directory_fmt = ["{category}", "{artist-id}"]
filename_fmt = "{category}_{artist-id}_{image-id}_p{index:>02}.{extension}"
directory_fmt = ["{category}", "{artist_id}"]
filename_fmt = "{category}_{artist_id}_{image_id}_p{index:>02}.{extension}"
cookiedomain = "nijie.info"
popup_url = "https://nijie.info/view_popup.php?id="
@@ -39,7 +39,7 @@ class NijieExtractor(AsynchronousExtractor):
def get_job_metadata(self):
"""Collect metadata for extractor-job"""
return {"artist-id": self.artist_id}
return {"artist_id": self.artist_id}
def get_image_ids(self):
"""Collect all image-ids for a specific artist"""
@@ -58,7 +58,7 @@ class NijieExtractor(AsynchronousExtractor):
yield "https://pic" + url, text.nameext_from_url(url, {
"count": len(images),
"index": index,
"image-id": image_id,
"image_id": image_id,
})
def login(self):
@@ -87,7 +87,7 @@ class NijieUserExtractor(NijieExtractor):
test = [
("https://nijie.info/members_illust.php?id=44", {
"url": "585d821df4716b1098660a0be426d01db4b65f2a",
"keyword": "7a2dbf8fc0dfdb2af208ecdb8ec7f3186bdc31ab",
"keyword": "804d3a9bb8205048ac0d1fe8eec39266b50f1e8e",
}),
("https://nijie.info/members_illust.php?id=43", {
"exception": exception.NotFoundError,
@@ -119,7 +119,7 @@ class NijieImageExtractor(NijieExtractor):
test = [
("https://nijie.info/view.php?id=70720", {
"url": "a10d4995645b5f260821e32c60a35f73546c2699",
"keyword": "e454c2bad9b636b90d569881bf4fe8438506e0d2",
"keyword": "4ecfd46460761b7a89fdba815eece10e917032c2",
"content": "d85e3ea896ed5e4da0bca2390ad310a4df716ca6",
}),
("https://nijie.info/view.php?id=70724", {