Skip to content

Commit be2f967

Browse files
Handle problems with unknown difficulty
1 parent 7432aeb commit be2f967

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

autokattis/api/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ def problems(self, show_solved=True, show_partial=True, show_tried=False, show_u
113113
shortest = int(columns[3].text.replace('--', '-1'))
114114
total = int(columns[4].text)
115115
acc = int(columns[5].text)
116-
difficulty = float(re.findall('[\d\.]+', columns[7].text)[-1])
117-
# [0] instead of [-1] if we want to take min instead of max
118-
# for example:
119-
# - difficulty 9.1-9.6 -> [9.1, 9.6]
120-
# - difficulty 5.0 -> [5.0]
116+
try:
117+
difficulty = float(re.findall('[\d\.]+', columns[7].text)[-1])
118+
# [0] instead of [-1] if we want to take min instead of max
119+
# for example:
120+
# - difficulty 9.1-9.6 -> [9.1, 9.6]
121+
# - difficulty 5.0 -> [5.0]
122+
except:
123+
difficulty = None
121124
try: category = re.findall('[A-Za-z]+', columns[7].text)[0]
122125
except: category = 'N/A'
123126
data.append({

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup_args = dict(
77
name='autokattis',
8-
version='1.4.9',
8+
version='1.4.10',
99
description='Updated Kattis API wrapper',
1010
long_description_content_type="text/markdown",
1111
long_description=README,

0 commit comments

Comments
 (0)