From 946b85ace909f593084492135910889c37264ce7 Mon Sep 17 00:00:00 2001 From: ricterz Date: Sat, 21 Dec 2024 09:32:33 +0800 Subject: [PATCH] tiny fix --- README.rst | 2 +- nhentai/cmdline.py | 2 +- nhentai/parser.py | 47 ---------------------------------------------- qodana.yaml | 29 ++++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 49 deletions(-) create mode 100755 qodana.yaml diff --git a/README.rst b/README.rst index 00098b8..189bdb0 100644 --- a/README.rst +++ b/README.rst @@ -59,7 +59,7 @@ On Gentoo Linux: .. code-block:: - layman -fa glicOne + layman -fa glibOne sudo emerge net-misc/nhentai On NixOS: diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index d10d7d7..c5c996b 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -37,7 +37,7 @@ def write_config(): f.write(json.dumps(constant.CONFIG)) -def callback(option, opt_str, value, parser): +def callback(option, _opt_str, _value, parser): if option == '--id': pass value = [] diff --git a/nhentai/parser.py b/nhentai/parser.py index 82a786d..be612f1 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -188,53 +188,6 @@ def doujinshi_parser(id_, counter=0): return doujinshi -def legacy_doujinshi_parser(id_): - if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()): - raise Exception(f'Doujinshi id({id_}) is not valid') - - id_ = int(id_) - logger.info(f'Fetching information of doujinshi id {id_}') - doujinshi = dict() - doujinshi['id'] = id_ - url = f'{constant.DETAIL_URL}/{id_}' - i = 0 - while 5 > i: - try: - response = request('get', url).json() - except Exception as e: - i += 1 - if not i < 5: - logger.critical(str(e)) - sys.exit(1) - continue - break - - doujinshi['name'] = response['title']['english'] - doujinshi['subtitle'] = response['title']['japanese'] - doujinshi['img_id'] = response['media_id'] - doujinshi['ext'] = ''.join([i['t'] for i in response['images']['pages']]) - doujinshi['pages'] = len(response['images']['pages']) - - # gain information of the doujinshi - needed_fields = ['character', 'artist', 'language', 'tag', 'parody', 'group', 'category'] - for tag in response['tags']: - tag_type = tag['type'] - if tag_type in needed_fields: - if tag_type == 'tag': - if tag_type not in doujinshi: - doujinshi[tag_type] = {} - - tag['name'] = tag['name'].replace(' ', '-') - tag['name'] = tag['name'].lower() - doujinshi[tag_type][tag['name']] = tag['id'] - elif tag_type not in doujinshi: - doujinshi[tag_type] = tag['name'] - else: - doujinshi[tag_type] += ', ' + tag['name'] - - return doujinshi - - def print_doujinshi(doujinshi_list): if not doujinshi_list: return diff --git a/qodana.yaml b/qodana.yaml new file mode 100755 index 0000000..76f58ef --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,29 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" + +#Specify inspection profile for code analysis +profile: + name: qodana.starter + +#Enable inspections +#include: +# - name: + +#Disable inspections +#exclude: +# - name: +# paths: +# - + +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh + +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) + +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-python:2024.3