~yerinalexey/pcrond

ebb65c87beefac2f8113648690248b7de9f4c92b — Luca Vercelli 2 years ago 6732d40
clean code
4 files changed, 7 insertions(+), 19 deletions(-)

M .travis.yml
M pcrond/job.py
M test_scheduler.py
M tox.ini
M .travis.yml => .travis.yml +1 -1
@@ 1,7 1,7 @@
sudo: false
language: python
python:
    - "2.7.11"
    - "2.7"
    - "3.6"
install: pip install tox-travis coveralls
script:

M pcrond/job.py => pcrond/job.py +6 -9
@@ 50,9 50,9 @@ class Job(object):
        if len(crontab_lst) != 6:
            raise ValueError(
                "Each crontab pattern *must* contain either 5 or 6 items")
        [self.allowed_every_min, self.allowed_min] =  self._parse_min(crontab_lst[0])
        [self.allowed_every_hour, self.allowed_hours] =  self._parse_hour(crontab_lst[1])
        [self.allowed_every_dom, self.allowed_dom] =  self._parse_day_in_month(crontab_lst[2])
        [self.allowed_every_min, self.allowed_min] = self._parse_min(crontab_lst[0])
        [self.allowed_every_hour, self.allowed_hours] = self._parse_hour(crontab_lst[1])
        [self.allowed_every_dom, self.allowed_dom] = self._parse_day_in_month(crontab_lst[2])
        [self.allowed_every_month, self.allowed_months] = self._parse_month(crontab_lst[3])
        [self.allowed_every_dow, self.allowed_dow] = self._parse_day_in_week(crontab_lst[4])
        [self.allowed_every_year, self.allowed_years] = self._parse_year(crontab_lst[5])


@@ 60,8 60,7 @@ class Job(object):
        self.must_calculate_last_dom = (-1 in self.allowed_dom)

        if -1 in self.allowed_years:
            raise ValueError(("Wrong format '%s' : 'L' is meaningless " +
                                      "talking about Years") % crontab_lst[5])
            raise ValueError(("Wrong format '%s' : 'L' is meaningless talking about Years") % crontab_lst[5])

        self.crontab_pattern = crontab_lst



@@ 78,8 77,7 @@ class Job(object):
        try:
            return int(token)
        except ValueError:
            raise ValueError(("token %s is not an integer, " +
                                        "nor it is a known constant") % token)
            raise ValueError(("token %s is not an integer, nor it is a known constant") % token)

    def _parse_common(self, s, maxval, offsets={}):
        """


@@ 113,8 111,7 @@ class Job(object):
            # here ["1","2-5","jul","10-L"]
            ranges = [x.split("-") for x in ranges]
            # here [["1"],["2","5"],["aug"], ["10","L"]]
            ranges = [[self._parse_token(w, offsets) for w in x]
                                                            for x in ranges]
            ranges = [[self._parse_token(w, offsets) for w in x] for x in ranges]
            # here [[1],[2,5],[7], [10,11]]
            if max([len(x) for x in ranges]) > 2:
                raise ValueError(

M test_scheduler.py => test_scheduler.py +0 -4
@@ 3,10 3,6 @@
import datetime
import unittest

# Silence "missing docstring", "method could be a function",
# "class already defined", and "too many public methods" messages:
# p y l i n t: disable-msg=R0201,C0111,E0102,R0904,R0901

from pcrond import scheduler, Job



M tox.ini => tox.ini +0 -5
@@ 1,11 1,6 @@
[tox]
envlist = py27, py36

[tox:travis]
#TODO this is DEPRECATED
2.7.11 = py27
3.6 = py36

[pytest]
#default is 79 :(
flake8-max-line-length = 120