From 4848b11151030d76dc934c5c8357a55511d96cb0 Mon Sep 17 00:00:00 2001 From: dryancd Date: Wed, 18 Nov 2020 08:48:52 -0500 Subject: [PATCH] Fixed gitignore and added Black config file for standardization --- .gitignore | 6 +-- .../champions/pull_champions_dragons.py | 13 +++++- .../champions/pull_champions_wiki.py | 43 +++++++++++++++---- lolstaticdata/common/modelcommon.py | 4 +- lolstaticdata/items/pull_items_dragon.py | 2 +- pyproject.toml | 5 +++ 6 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index a769dee5..19feb52a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -/files/ -/files/model2.py +/items/ +/champions/ __pycache__/ __cache__/ -champions/ champions.json -items/ items.json diff --git a/lolstaticdata/champions/pull_champions_dragons.py b/lolstaticdata/champions/pull_champions_dragons.py index 90daf2c9..8675e44a 100644 --- a/lolstaticdata/champions/pull_champions_dragons.py +++ b/lolstaticdata/champions/pull_champions_dragons.py @@ -43,7 +43,12 @@ def build_guess( def perform_guess( - champion_name, ability_name, ability_key, ability_index, filenames, use_underscores=True, + champion_name, + ability_name, + ability_key, + ability_index, + filenames, + use_underscores=True, ): best_score = -float("inf") for include_champion_name in (True, False): @@ -51,7 +56,11 @@ def perform_guess( for include_ability_index in (True, False): for include_ability_key in (True, False): if include_champion_name is True and not any( - [include_ability_name, include_ability_index, include_ability_key,] + [ + include_ability_name, + include_ability_index, + include_ability_key, + ] ): continue guess = build_guess( diff --git a/lolstaticdata/champions/pull_champions_wiki.py b/lolstaticdata/champions/pull_champions_wiki.py index f7f71744..5bb0b507 100644 --- a/lolstaticdata/champions/pull_champions_wiki.py +++ b/lolstaticdata/champions/pull_champions_wiki.py @@ -168,7 +168,11 @@ def get_champions(self) -> Iterator[Champion]: d["skill_q"] = {1: d["skills"][3], 2: d["skills"][4]} d["skill_e"] = {1: d["skills"][6], 2: d["skills"][7]} d["skill_r"] = {1: d["skills"][8], 2: d["skills"][9]} - if d["id"] == 9999 or d["date"] == "Upcoming" or datetime.strptime(d["date"], "%Y-%m-%d") > datetime.today(): # Champion not released yet + if ( + d["id"] == 9999 + or d["date"] == "Upcoming" + or datetime.strptime(d["date"], "%Y-%m-%d") > datetime.today() + ): # Champion not released yet continue champion = self._render_champion_data(name, d) yield champion @@ -230,7 +234,9 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: per_level=data["stats"]["as_lvl"], ), attack_speed_ratio=Stat(flat=data["stats"]["as_ratio"]), - attack_cast_time=Stat(flat=data["stats"].get("attack_cast_time", 0.3)), # I don't know if this default is correct, but going off the values the wiki provides, it seems reasonable. + attack_cast_time=Stat( + flat=data["stats"].get("attack_cast_time", 0.3) + ), # I don't know if this default is correct, but going off the values the wiki provides, it seems reasonable. attack_total_time=Stat(flat=data["stats"].get("attack_total_time", 1.6)), # ibid attack_delay_offset=Stat(flat=data["stats"].get("attack_delay_offset", 0)), attack_range=AttackRange( @@ -285,7 +291,10 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: abilities=[ self._pull_champion_ability(champion_name=name, ability_name=ability_name) for ability_name in data["skill_i"].values() - if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]) + if not ( + name in LolWikiDataHandler.MISSING_SKILLS + and ability_name in LolWikiDataHandler.MISSING_SKILLS[name] + ) ], ), self._render_abilities( @@ -293,7 +302,10 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: abilities=[ self._pull_champion_ability(champion_name=name, ability_name=ability_name) for ability_name in data["skill_q"].values() - if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]) + if not ( + name in LolWikiDataHandler.MISSING_SKILLS + and ability_name in LolWikiDataHandler.MISSING_SKILLS[name] + ) ], ), self._render_abilities( @@ -301,7 +313,10 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: abilities=[ self._pull_champion_ability(champion_name=name, ability_name=ability_name) for ability_name in data["skill_w"].values() - if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]) + if not ( + name in LolWikiDataHandler.MISSING_SKILLS + and ability_name in LolWikiDataHandler.MISSING_SKILLS[name] + ) ], ), self._render_abilities( @@ -309,7 +324,10 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: abilities=[ self._pull_champion_ability(champion_name=name, ability_name=ability_name) for ability_name in data["skill_e"].values() - if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]) + if not ( + name in LolWikiDataHandler.MISSING_SKILLS + and ability_name in LolWikiDataHandler.MISSING_SKILLS[name] + ) ], ), self._render_abilities( @@ -317,7 +335,10 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion: abilities=[ self._pull_champion_ability(champion_name=name, ability_name=ability_name) for ability_name in data["skill_r"].values() - if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]) + if not ( + name in LolWikiDataHandler.MISSING_SKILLS + and ability_name in LolWikiDataHandler.MISSING_SKILLS[name] + ) ], ), ] @@ -365,7 +386,9 @@ def _render_abilities(self, champion_name, abilities: List[HTMLAbilityWrapper]) assert _skill_key == skill_key if champion_name == "Pyke" and _skill_key == "I": - del data["Cost"] # This is a weird one... There's an embedded table that doesn't get parsed right. It overwrites 'cost', but luckily that isn't an issue because 'cost' is empty. + del data[ + "Cost" + ] # This is a weird one... There's an embedded table that doesn't get parsed right. It overwrites 'cost', but luckily that isn't an issue because 'cost' is empty. if data.get("Cost") is not None: raise ValueError(data) @@ -703,7 +726,9 @@ def _get_champ_skin(self, name): skins = [] champ_id = self.skin_data[name]["id"] - cdragon = "http://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champions/{0}.json".format(champ_id) + cdragon = "http://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champions/{0}.json".format( + champ_id + ) cdrag_json = download_json(cdragon, False) for s in champ_data: diff --git a/lolstaticdata/common/modelcommon.py b/lolstaticdata/common/modelcommon.py index 75c303f3..d0f053d4 100644 --- a/lolstaticdata/common/modelcommon.py +++ b/lolstaticdata/common/modelcommon.py @@ -140,8 +140,10 @@ class MagicPenetration(Stat): class ArmorPenetration(Stat): pass + class AbilityHaste(Stat): pass + class OmniVamp(Stat): - pass \ No newline at end of file + pass diff --git a/lolstaticdata/items/pull_items_dragon.py b/lolstaticdata/items/pull_items_dragon.py index fc8a72e2..cee19693 100644 --- a/lolstaticdata/items/pull_items_dragon.py +++ b/lolstaticdata/items/pull_items_dragon.py @@ -71,6 +71,6 @@ def get_ddragon(cls, ddragon: int, p: dict): active=[], stats=[], shop=shop, - rank="" + rank="", ) return item diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..ad0fd611 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.black] +line-length = 120 +target-version = ['py37'] +include = '\.pyi?$' +exclude = '' \ No newline at end of file