From 6f0adbb1729ecd3139bce3534405a9156439a7c5 Mon Sep 17 00:00:00 2001 From: fosJoddie <5710881+fosJoddie@users.noreply.github.com> Date: Sat, 21 Aug 2021 07:45:18 +0200 Subject: [PATCH] Lint questgen --- mapadroid/utils/questGen.py | 29 +++++++++++++---------------- tox.ini | 1 + 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/mapadroid/utils/questGen.py b/mapadroid/utils/questGen.py index 548ecb710..4316701fd 100644 --- a/mapadroid/utils/questGen.py +++ b/mapadroid/utils/questGen.py @@ -40,7 +40,8 @@ def __init__(self, args): if not args.no_quest_titles: locale_url = "https://raw.githubusercontent.com/PokeMiners/pogo_assets/master/Texts/Latest%20APK/{0}.txt" - remote_locale_url = "https://raw.githubusercontent.com/PokeMiners/pogo_assets/master/Texts/Latest%20Remote/" \ + remote_locale_url = "https://raw.githubusercontent.com/" \ + "PokeMiners/pogo_assets/master/Texts/Latest%20Remote/" \ "{0}.txt" asset_language = QUEST_LANGUAGES.get(args.language, 'English') @@ -55,7 +56,8 @@ def __init__(self, args): if remote_locale is None: remote_locale = {} self.locale_resources = {**apk_locale, **remote_locale} - else: self.locale_resources = None + else: + self.locale_resources = None @staticmethod def __gen_assets_locale(url): @@ -162,13 +164,13 @@ def questtype(self, quest_type): return "Unknown quest type placeholder: {0}" def rewarditem(self, itemid): - file = open_json_file('items') - if str(itemid) in file: - return (file[str(itemid)]['name']) + reward_file = open_json_file('items') + if str(itemid) in reward_file: + return (reward_file[str(itemid)]['name']) return "Item " + str(itemid) - def pokemonname(self, id): - return self.pokemen_file[str(int(id))]["name"] + def pokemonname(self, pokemon_id): + return self.pokemen_file[str(int(pokemon_id))]["name"] def get_pokemon_type_str(self, pt): return self.pokemon_types[str(pt)].title() + _('-type') @@ -183,7 +185,7 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): gettext.find('quest', 'locales', all=True) throw_types = {"10": _("Nice"), "11": _("Great"), "12": _("Excellent"), "13": _("Curveball")} - buddyLevels = {2: _("Good"), 3: _("Great"), 4: _("Ultra"), 5: _("Best")} + buddy_levels = {2: _("Good"), 3: _("Great"), 4: _("Ultra"), 5: _("Best")} arr = {'0': target} text = self.questtype(typeid) # TODO use the dict instead of regex parsing in all logic @@ -234,9 +236,6 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): elif condition_type == 26: # Condition type 26 is alignment alignment = con.get('with_pokemon_alignment', {}).get('alignment', []) - # POKEMON_ALIGNMENT_UNSET = 0; - # POKEMON_ALIGNMENT_SHADOW = 1; - # POKEMON_ALIGNMENT_PURIFIED = 2; if len(alignment) == 1 and alignment[0] == 1: arr['different'] = _(" shadow") elif len(alignment) == 1 and alignment[0] == 2: @@ -305,7 +304,6 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): if con.get('type', 0) == 11: text = _("Use an item to {mega}evolve {0} Pokemon") # Try to find the exact evolution item needed - # [{"type": 11, "with_item": {"item": 1106}}] with_item = con.get('with_item', {}).get('item', None) if with_item is not None: text = _('Use {item} to {mega}evolve {0} Pokemon') @@ -431,7 +429,6 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): cur += 1 text = _("Take {0} snapshots of {poke}") elif re.search(r'"type": 1', condition) is not None: - # [{"type": 1, "with_pokemon_type": {"pokemon_type": [6]}}] text = _("Take {0} snapshots of wild {type} Pokemon") arr['wb'] = "" arr['type'] = "" @@ -473,7 +470,7 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): for con in condition_dict: if con.get('type', 0) == 28: level = con.get('with_buddy', {}).get('min_buddy_level', 0) - arr['level'] = buddyLevels.get(level, level) + arr['level'] = buddy_levels.get(level, level) elif typeid == 53: # type 53 is to do charged attacks (any kind of way gym/pvp/rocket) arr['type'] = '' @@ -500,8 +497,8 @@ def questtask(self, typeid, condition, target, quest_template, quest_title): text = text.replace(_('PVP Battle(s)'), _('PVP Battle')) arr['0'] = _("a") - for key, val in arr.items(): - text = text.replace('{' + key + '}', str(val)) + for key, text_replacement in arr.items(): + text = text.replace('{' + key + '}', str(text_replacement)) text = text.replace(' ', ' ').strip() return text diff --git a/tox.ini b/tox.ini index d95ea5808..1e1126d99 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,7 @@ exclude = configs/*.py, .tox ignore = E402,W504,W503, N818 +builtins = "_" max-line-length = 120 [gh-actions]