Skip to content

Commit

Permalink
Fix minor pep8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Saturn committed Jan 14, 2019
1 parent b8ecf99 commit 10e6d96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 3 additions & 2 deletions soccer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def load_json(file):
def get_input_key():
"""Input API key and validate"""
click.secho("No API key found!", fg="yellow", bold=True)
click.secho("Please visit {0} and get an API token.".format(RequestHandler.BASE_URL),
fg="yellow", bold=True)
click.secho("Please visit {} and get an API token.".format(RequestHandler.BASE_URL),
fg="yellow",
bold=True)
while True:
confkey = click.prompt(click.style("Enter API key",
fg="yellow", bold=True))
Expand Down
22 changes: 14 additions & 8 deletions soccer/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def live_scores(self, live_scores, use_12_hour_format):
self.league_header(league)
for game in games:
self.scores(self.parse_result(game), add_new_line=False)
click.secho(' %s' % Stdout.utc_to_local(game["time"], use_12_hour_format),
click.secho(' %s' % Stdout.utc_to_local(game["time"],
use_12_hour_format),
fg=self.colors.TIME)
click.echo()

Expand Down Expand Up @@ -140,7 +141,8 @@ def standings(self, league_table, league):
else:
click.secho(team_str, fg=self.colors.POSITION)

def league_scores(self, total_data, time, show_datetime, use_12_hour_format):
def league_scores(self, total_data, time, show_datetime,
use_12_hour_format):
"""Prints the data in a pretty format"""
seen = set()
for league, data in self.supported_leagues(total_data):
Expand Down Expand Up @@ -209,10 +211,14 @@ def utc_to_local(time_str, use_12_hour_format, show_datetime=False):
if time_str.endswith(" UTC"):
time_str, _ = time_str.split(" UTC")
utc_time = datetime.datetime.strptime(time_str, '%I:%M %p')
utc_datetime = datetime.datetime(today_utc.year, today_utc.month, today_utc.day,
utc_time.hour, utc_time.minute)
utc_datetime = datetime.datetime(today_utc.year,
today_utc.month,
today_utc.day,
utc_time.hour,
utc_time.minute)
else:
utc_datetime = datetime.datetime.strptime(time_str, '%Y-%m-%dT%H:%M:%SZ')
utc_datetime = datetime.datetime.strptime(time_str,
'%Y-%m-%dT%H:%M:%SZ')

local_time = utc_datetime - utc_local_diff

Expand Down Expand Up @@ -303,10 +309,10 @@ def generate_output(self, result):
separators=(',', ': '),
ensure_ascii=False))
else:
with io.open(self.output_filename, 'w', encoding='utf-8') as json_file:
data = json.dumps(result, json_file, indent=4,
with io.open(self.output_filename, 'w', encoding='utf-8') as f:
data = json.dumps(result, f, indent=4,
separators=(',', ': '), ensure_ascii=False)
json_file.write(data)
f.write(data)

def live_scores(self, live_scores):
"""Store output of live scores to a JSON file"""
Expand Down

0 comments on commit 10e6d96

Please sign in to comment.