From 040fac4be836daf249d1bf712fbfff439912bca1 Mon Sep 17 00:00:00 2001 From: Michele Lacchia Date: Mon, 26 Oct 2015 23:18:51 +0100 Subject: [PATCH] Make local imports relative --- challenges/cli.py | 18 +++++++++--------- challenges/local_exceptions.py | 2 +- challenges/writers.py | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/challenges/cli.py b/challenges/cli.py index 42a6c67..8e3f1c5 100644 --- a/challenges/cli.py +++ b/challenges/cli.py @@ -4,12 +4,12 @@ import requests import click -from local_exceptions import IncorrectParametersException +from .local_exceptions import IncorrectParametersException -import writers +from . import writers -from platformids import platforms as contest_platforms -from utilities import time_difference +from .platformids import platforms as contest_platforms +from .utilities import time_difference BASE_URL = "http://challengehuntapp.appspot.com/v2" PLATFORM_IDS = contest_platforms @@ -17,7 +17,7 @@ def check_platforms(platforms): """Checks if the platforms have a valid platform code""" if len(platforms) > 0: - return all(platform in PLATFORM_IDS for platform in platforms): + return all(platform in PLATFORM_IDS for platform in platforms) return True @@ -47,14 +47,14 @@ def active_contests(platforms): active_challenges = [contest for contest in contests_data["active"] if contest["host_name"] in platform_filter] return active_challenges - + def upcoming_contests(platforms, time): """Gets all the upcoming contests based on time and platforms""" contests_data = get_contests_data() platform_filter = get_platform_filter(platforms) - upcoming_challenges = [contest for contest in contests_data["pending"] if contest["host_name"] in platform_filter + upcoming_challenges = [contest for contest in contests_data["pending"] if contest["host_name"] in platform_filter and time_difference(contest["start"]).days <= time] return upcoming_challenges @@ -96,9 +96,9 @@ def get_all_contests(platforms, time): platform_filter = get_platform_filter(platforms) - contests_data = [contest for contest in active_contests + contests_data = [contest for contest in active_contests if contest["host_name"] in platform_filter] - contests_data += [contest for contest in upcoming_contests + contests_data += [contest for contest in upcoming_contests if contest["host_name"] in platform_filter and time_difference(contest["start"]).days <= time] return contests_data diff --git a/challenges/local_exceptions.py b/challenges/local_exceptions.py index 3e443e8..07bbdba 100644 --- a/challenges/local_exceptions.py +++ b/challenges/local_exceptions.py @@ -1,2 +1,2 @@ class IncorrectParametersException(Exception): - pass \ No newline at end of file + pass diff --git a/challenges/writers.py b/challenges/writers.py index a2dbaa7..59e5113 100644 --- a/challenges/writers.py +++ b/challenges/writers.py @@ -2,7 +2,7 @@ import click -from utilities import time_difference +from .utilities import time_difference def colors(): """Creates an enum for colors""" @@ -63,7 +63,7 @@ def get_time_string(contest, contest_type): time_diff = time_difference(contest["end"]) time_diff_string = "" - if time_diff.days > 0: + if time_diff.days > 0: time_diff_string = "{0} days {1} hours".format(time_diff.days, time_diff.hours) elif time_diff.hours > 0: time_diff_string = "{0} hours {1} minutes".format(time_diff.hours, time_diff.minutes) @@ -75,11 +75,11 @@ def get_time_string(contest, contest_type): def write_contest_header(contest_type): """Prints the header for the type of contest""" if contest_type == challenge().ACTIVE: - click.secho("%-3s %-50s %-20s %-11s %-15s" % + click.secho("%-3s %-50s %-20s %-11s %-15s" % ("NO.", "NAME", "ENDS IN", "DURATION", "PLATFORM")) elif contest_type == challenge().UPCOMING: - click.secho("%-3s %-50s %-20s %-11s %-15s" % + click.secho("%-3s %-50s %-20s %-11s %-15s" % ("NO.", "NAME", "STARTS IN", "DURATION", "PLATFORM")) elif contest_type in [challenge().HIRING, challenge().SHORT, challenge().ALL]: - click.secho("%-3s %-50s %-20s %-11s %-15s" % - ("NO.", "NAME", "STARTS/ENDS IN", "DURATION", "PLATFORM")) + click.secho("%-3s %-50s %-20s %-11s %-15s" % + ("NO.", "NAME", "STARTS/ENDS IN", "DURATION", "PLATFORM"))