From 666bee386577b06576d493a5c932a7cc646a8cf3 Mon Sep 17 00:00:00 2001 From: 1337MARCEL <16888873+1337MARCEL@users.noreply.github.com> Date: Fri, 21 Nov 2025 01:28:12 +0100 Subject: [PATCH] fix: avoid crashes on none values --- .../champions/pull_champions_wiki.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lolstaticdata/champions/pull_champions_wiki.py b/lolstaticdata/champions/pull_champions_wiki.py index f02904fc..d5c336dc 100644 --- a/lolstaticdata/champions/pull_champions_wiki.py +++ b/lolstaticdata/champions/pull_champions_wiki.py @@ -1,7 +1,6 @@ from typing import Tuple, List, Union, Iterator, Dict import re from bs4 import BeautifulSoup -from collections import Counter from slpp import slpp as lua from datetime import datetime @@ -14,16 +13,9 @@ Armor, MagicResistance, AttackDamage, - AbilityPower, AttackSpeed, AttackRange, Movespeed, - Lethality, - CooldownReduction, - GoldPer10, - HealAndShieldPower, - Lifesteal, - MagicPenetration, Stat, ) from ..common.utils import ( @@ -732,11 +724,12 @@ def _render_modifiers(self, mods: str, nvalues: int) -> List[Modifier]: except Exception as error: print(f"ERROR: FAILURE TO PARSE MODIFIER: {lvling}") print("ERROR:", error) - modifier = Modifier( - values=[0 for _ in range(nvalues)], - units=[lvling for _ in range(nvalues)], - ) - modifiers.append(modifier) + if nvalues is not None: + modifier = Modifier( + values=[0 for _ in range(nvalues)], + units=[lvling for _ in range(nvalues)], + ) + modifiers.append(modifier) return modifiers def _render_modifier(self, mod: str, nvalues: int) -> Modifier: @@ -763,7 +756,7 @@ def _render_ability_cooldown(self, mods: str, static_cooldown: bool, nvalues: in def _get_sale(self): get_prices = re.compile(r"(\d+) (\d+)") - url = f"https://wiki.leagueoflegends.com/en-us/Sales" + url = "https://wiki.leagueoflegends.com/en-us/Sales" html = download_soup(url, False) soup = BeautifulSoup(html, "lxml") spans = soup.findAll("div", {"class": "skin_portrait skin-icon"}) @@ -816,7 +809,7 @@ def _get_chroma_attribs(self, id, name): print(f"Chroma Mismatch: {id} not available in {available}") def _get_skins(self): - url = f"https://wiki.leagueoflegends.com/en-us/Module:SkinData/data" + url = "https://wiki.leagueoflegends.com/en-us/Module:SkinData/data" html = download_soup(url, False) soup = BeautifulSoup(html, "lxml")