Skip to content

Commit

Permalink
Return types, 'with' for files
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeikobelev committed Dec 19, 2023
1 parent 1c907ef commit 9806c1a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sportorg/modules/recovery/recovery_orgeo_finish_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
race = race()


def recovery(file_name):
def recovery(file_name) -> None:
encoding = 'cp1251'
separator = ';'
spl_separator = '|'
Expand Down Expand Up @@ -88,7 +88,7 @@ def recovery(file_name):
res.person = person
if tokens[POS_CARD].isdigit():
res.card_number = int(tokens[POS_CARD])
res.start_time = hhmmss_to_time(tokens[POS_START])
res.start_time = person.start_time
result = tokens[POS_RES]
if result.find(':') > 0:
result_value = hhmmss_to_time(result)
Expand Down
2 changes: 1 addition & 1 deletion sportorg/modules/recovery/recovery_si_master_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
race = race()


def recovery(file_name):
def recovery(file_name) -> None:
separator = ';'

zero_time_val = race.get_setting('system_zero_time', (8, 0, 0))
Expand Down
13 changes: 5 additions & 8 deletions sportorg/modules/recovery/recovery_sportorg_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tempfile import gettempdir


def recovery(file_name):
def recovery(file_name) -> str:
with open(file_name, 'r', encoding='utf-8') as f:
for line in f.readlines():
if line.find("var race = {\"courses\":") > -1:
Expand All @@ -18,12 +18,9 @@ def recovery(file_name):
# save json to tmp file and op[en with standard import action
tmp_filename = os.path.join(
gettempdir(),
'sportorg_'
+ ''.join(choices(string.ascii_letters, k=10))
+ '.json',
f"sportorg_{''.join(choices(string.ascii_letters, k=10))}.json",
)
temp_file = open(tmp_filename, 'w')
temp_file.write(json)
temp_file.close()
with open(tmp_filename, 'w') as temp_file:
temp_file.write(json)

return tmp_filename
return None
2 changes: 1 addition & 1 deletion sportorg/modules/recovery/recovery_sportorg_si_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
race = race()


def recovery(file_name):
def recovery(file_name) -> None:
zero_time_val = race.get_setting('system_zero_time', (8, 0, 0))
zero_time = OTime(
hour=zero_time_val[0], minute=zero_time_val[1], sec=zero_time_val[2]
Expand Down

0 comments on commit 9806c1a

Please sign in to comment.