Commit 18870cd29b2f4edb0b105988cce82d9378352bd2
1 parent
360b3b2c
Improve PEP8 compliance in service_keywords.py
Showing
1 changed file
with
16 additions
and
7 deletions
@@ -24,16 +24,20 @@ import calendar | @@ -24,16 +24,20 @@ import calendar | ||
24 | 24 | ||
25 | TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev') | 25 | TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev') |
26 | 26 | ||
27 | + | ||
27 | def get_now(): | 28 | def get_now(): |
28 | return datetime.now(TZ) | 29 | return datetime.now(TZ) |
29 | 30 | ||
31 | + | ||
30 | def get_date(): | 32 | def get_date(): |
31 | - return get_now().isoformat() | 33 | + return get_now().isoformat() |
34 | + | ||
32 | 35 | ||
33 | def get_file_contents(path): | 36 | def get_file_contents(path): |
34 | with open(path, 'r') as f: | 37 | with open(path, 'r') as f: |
35 | return unicode(f.read()) or u'' | 38 | return unicode(f.read()) or u'' |
36 | 39 | ||
40 | + | ||
37 | def change_state(arguments): | 41 | def change_state(arguments): |
38 | try: | 42 | try: |
39 | if arguments[0] == "shouldfail": | 43 | if arguments[0] == "shouldfail": |
@@ -42,22 +46,25 @@ def change_state(arguments): | @@ -42,22 +46,25 @@ def change_state(arguments): | ||
42 | except IndexError: | 46 | except IndexError: |
43 | return "pass" | 47 | return "pass" |
44 | 48 | ||
49 | + | ||
45 | def prepare_prom_test_tender_data(): | 50 | def prepare_prom_test_tender_data(): |
46 | return munchify({'data': prom_test_tender_data()}) | 51 | return munchify({'data': prom_test_tender_data()}) |
47 | 52 | ||
53 | + | ||
48 | def compare_date(data1, data2): | 54 | def compare_date(data1, data2): |
49 | - data1=parse(data1) | ||
50 | - data2=parse(data2) | 55 | + data1 = parse(data1) |
56 | + data2 = parse(data2) | ||
51 | if data1.tzinfo is None: | 57 | if data1.tzinfo is None: |
52 | data1 = TZ.localize(data1) | 58 | data1 = TZ.localize(data1) |
53 | if data2.tzinfo is None: | 59 | if data2.tzinfo is None: |
54 | data2 = TZ.localize(data2) | 60 | data2 = TZ.localize(data2) |
55 | 61 | ||
56 | - delta = (data1-data2).total_seconds() | 62 | + delta = (data1 - data2).total_seconds() |
57 | if abs(delta) > 60: | 63 | if abs(delta) > 60: |
58 | - return False | 64 | + return False |
59 | return True | 65 | return True |
60 | 66 | ||
67 | + | ||
61 | def log_object_data(data, file_name=None, format="yaml"): | 68 | def log_object_data(data, file_name=None, format="yaml"): |
62 | """Log object data in pretty format (JSON or YAML) | 69 | """Log object data in pretty format (JSON or YAML) |
63 | 70 | ||
@@ -89,10 +96,12 @@ def log_object_data(data, file_name=None, format="yaml"): | @@ -89,10 +96,12 @@ def log_object_data(data, file_name=None, format="yaml"): | ||
89 | with open(os.path.join(output_dir, file_name + '.' + format), "w") as file_obj: | 96 | with open(os.path.join(output_dir, file_name + '.' + format), "w") as file_obj: |
90 | file_obj.write(data) | 97 | file_obj.write(data) |
91 | 98 | ||
99 | + | ||
92 | def convert_date_to_prom_format(isodate): | 100 | def convert_date_to_prom_format(isodate): |
93 | - iso_dt=parse_date(isodate) | 101 | + iso_dt = parse_date(isodate) |
94 | day_string = iso_dt.strftime("%d.%m.%Y %H:%M") | 102 | day_string = iso_dt.strftime("%d.%m.%Y %H:%M") |
95 | - return day_string | 103 | + return day_string |
104 | + | ||
96 | 105 | ||
97 | def load_initial_data_from(file_name): | 106 | def load_initial_data_from(file_name): |
98 | if not os.path.exists(file_name): | 107 | if not os.path.exists(file_name): |
Please
register
or
login
to post a comment