Skip to content

Commit

Permalink
fix code climate
Browse files Browse the repository at this point in the history
  • Loading branch information
darius BERNARD committed May 15, 2017
1 parent 7c91e9e commit 21e545f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .codeclimate.yml
Expand Up @@ -14,8 +14,11 @@ engines:
enabled: true
radon:
enabled: true
config:
threshold: "C"
ratings:
paths:
- "**.py"
exclude_paths:
- tests/
- tests/
- sample/
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -17,6 +17,7 @@ not_skip = __init__.py
[flake8]

ignore = E402
max-line-length=119

[nosetests]
where = tests
Expand Down
34 changes: 18 additions & 16 deletions src/booleano/operations/variables.py
Expand Up @@ -172,8 +172,23 @@ def is_subset(self, value, context):
return value < cv


class FormatableVariable(NativeVariable):
"""
a class that accept a extra format in his constructor
"""
formats = []

def __init__(self, context_name, formats=None):

if isinstance(formats, six.text_type):
self.formats = (formats, )
elif formats is not None:
self.formats = formats
super(FormatableVariable, self).__init__(context_name)


@variable_symbol_table_builder.register(datetime.timedelta)
class DurationVariable(NativeVariable):
class DurationVariable(FormatableVariable):
"""
a variable that allow to compare **duration** from the context (datetime.timedelta)
Expand All @@ -199,16 +214,10 @@ class DurationVariable(NativeVariable):
]

def __init__(self, context_name, formats=None):

if isinstance(formats, six.text_type):
self.formats = (formats, )
elif formats is not None:
self.formats = formats

super(DurationVariable, self).__init__(context_name, formats)
self.regexps = [
re.compile(regex) for regex in self.formats
]
super(DurationVariable, self).__init__(context_name)

def _from_native_string(self, value):
"""
Expand All @@ -227,7 +236,7 @@ def _from_native_string(self, value):


@variable_symbol_table_builder.register(datetime.datetime)
class DateTimeVariable(NativeVariable):
class DateTimeVariable(FormatableVariable):
"""
a variable that allow to compare **datetime** from the context (datetime.datetime)
Expand All @@ -253,13 +262,6 @@ class DateTimeVariable(NativeVariable):
"%Y-%m-%d %H:%M:%S",
)

def __init__(self, context_name, formats=None):
if isinstance(formats, six.text_type):
self.formats = (formats, )
elif formats is not None:
self.formats = formats
super(DateTimeVariable, self).__init__(context_name)

def _from_native_string(self, value):
"""
parse a string as a date using self.formats.
Expand Down
5 changes: 1 addition & 4 deletions tox.ini
Expand Up @@ -2,9 +2,6 @@
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[flake8]
max-line-length=119


[tox]
minversion=1.8.0
Expand All @@ -27,7 +24,7 @@ basepython = python3
usedevelop = false
deps = flake8
changedir = {toxinidir}
commands = flake8 src
commands = flake8 src --max-complexity 10


[testenv:isort]
Expand Down

0 comments on commit 21e545f

Please sign in to comment.