Skip to content

Commit

Permalink
PEP 8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Jul 7, 2017
1 parent eb4c161 commit 4f24f18
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
24 changes: 16 additions & 8 deletions cron_descriptor/ExpressionDescriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def get_time_of_day_description(self):
minute_parts = minute_expression.split('-')
description.append(_("Every minute between {0} and {1}").format(
self.format_time(hour_expression, minute_parts[0]), self.format_time(hour_expression, minute_parts[1])))
elif "," in hour_expression and "-" not in hour_expression and any(exp in minute_expression for exp in self._special_characters) is False:
elif "," in hour_expression and "-" not in hour_expression and \
any(exp in minute_expression for exp in self._special_characters) is False:
# hours list with single minute (o.e. 30 6,14,16)
hour_parts = hour_expression.split(',')
description.append(_("At"))
Expand Down Expand Up @@ -428,7 +429,8 @@ def get_segment_description(

# interval contains 'between' piece (i.e. 2-59/3 )
if "-" in segments[0]:
between_segment_description = self.generate_between_segment_description(segments[0], get_between_description_format, get_single_item_description)
between_segment_description = self.generate_between_segment_description(
segments[0], get_between_description_format, get_single_item_description)
if not between_segment_description.startswith(", "):
description += ", "
description += between_segment_description
Expand Down Expand Up @@ -470,16 +472,22 @@ def get_segment_description(
expression).format(
description_content)
elif "-" in expression:
description = self.generate_between_segment_description(expression, get_between_description_format, get_single_item_description)
description = self.generate_between_segment_description(
expression, get_between_description_format, get_single_item_description)

return description

def generate_between_segment_description(self, between_expression, get_between_description_format, get_single_item_description):
def generate_between_segment_description(
self,
between_expression,
get_between_description_format,
get_single_item_description
):
"""
Generates the between segment description
:param between_expression:
:param get_between_description_format:
:param get_single_item_description:
Generates the between segment description
:param between_expression:
:param get_between_description_format:
:param get_single_item_description:
:return: The between segment description
"""
description = ""
Expand Down
9 changes: 5 additions & 4 deletions cron_descriptor/ExpressionParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def normalize_expression(self, expression_parts):

# convert JAN-DEC format to 1-12 format
for month_number in self._cron_months:
expression_parts[4] = expression_parts[4].upper().replace(self._cron_months[month_number], str(month_number))
expression_parts[4] = expression_parts[4].upper().replace(
self._cron_months[month_number], str(month_number))

# convert 0 second to (empty)
if expression_parts[0] == "0":
Expand All @@ -178,8 +179,8 @@ def normalize_expression(self, expression_parts):
"""
Convert Month,DOW,Year step values with a starting value (i.e. not '*') to between expressions.
This allows us to reuse the between expression handling for step values.
For Example:
For Example:
- month part '3/2' will be converted to '3-12/2' (every 2 months between March and December)
- DOW part '3/2' will be converted to '3-6/2' (every 2 days between Tuesday and Saturday)
"""
Expand All @@ -206,4 +207,4 @@ def decrease_days_of_week(self, day_of_week_expression_part):
dow_chars[i] = str(char_numeric - 1)[0]
except ValueError:
pass
return ''.join(dow_chars)
return ''.join(dow_chars)
1 change: 1 addition & 0 deletions examples/crontabReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class CrontabReader(object):

"""
Simple example reading /etc/contab
"""
Expand Down
7 changes: 3 additions & 4 deletions tests/TestFormats.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ def test_multi_part_day_of_the_week(self):

def test_day_of_week_with_day_of_month(self):
self.assertEqual(
"At 00:00 AM, on day 1, 2, and 3 of the month, only on Wednesday and Friday", get_description("0 0 0 1,2,3 * WED,FRI"))
"At 00:00 AM, on day 1, 2, and 3 of the month, only on Wednesday and Friday",
get_description("0 0 0 1,2,3 * WED,FRI")
)

def test_seconds_internal_with_step_value(self):
self.assertEqual(
Expand Down Expand Up @@ -404,6 +406,3 @@ def test_minites_combined_with_multiple_hour_ranges(self):
self.assertEqual(
"At 1 minutes past the hour, at 01:00 AM and 03:00 AM through 04:59 AM",
get_description("1 1,3-4 * * *"))



1 change: 1 addition & 0 deletions tests/TestLocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


class TestLocale(TestCase.TestCase):

def test_locale_de(self):
options = Options()
options.locale_code = 'de_DE'
Expand Down

0 comments on commit 4f24f18

Please sign in to comment.