Skip to content

Commit

Permalink
UnboundLocalError fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
solesensei committed Sep 22, 2021
1 parent f745ffe commit fe32008
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@

if errors:
echo.r("Not imported games: ")
for e in sorted(errors, key=lambda x: x.name):
echo.r(f"- {e.name}")
for error in sorted(errors, key=lambda x: x.name):
echo.r(f"- {error.name}")
echo.g(f"Imported: {imported}/{len(game_list)}\n")

except ServiceError as e:
echo(e)
except ServiceError as err:
echo(err)
if DEBUG:
raise e
raise err
soft_exit(1)
except (Exception, KeyboardInterrupt) as e:
echo(f"\n{e.__class__.__name__}: {e}", file=sys.stderr)
except (Exception, KeyboardInterrupt) as err:
echo(f"\n{err.__class__.__name__}: {err}", file=sys.stderr)
if DEBUG:
raise e
raise err
soft_exit(1)

echo.m("Completed!")
Expand Down
5 changes: 2 additions & 3 deletions ngl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ def _parse_date(date_str: tp.Optional[str]):
if not date_str:
return None
check_date_formats = (r"%d %b, %Y", r"%b %d, %Y", r"%b %Y")
e = None
for fmt in check_date_formats:
try:
return datetime.strptime(date_str, fmt).date()
except ValueError as e:
except ValueError:
pass
raise ServiceError(msg="time data '{}' does not match any of formats '{}'".format(date_str, "', '".join(check_date_formats)), error=e)
raise ServiceError(msg="time data '{}' does not match any of formats '{}'".format(date_str, "', '".join(check_date_formats)))

def add_game(self, game: GameInfo, game_page: CollectionViewPageBlock, use_bg_as_cover: bool = False) -> bool:
row_data = {"title": game.name, "platforms": game.platforms, "release_date": self._parse_date(game.release_date), "notes": f"Playtime: {game.playtime}"}
Expand Down

0 comments on commit fe32008

Please sign in to comment.