Skip to content

Commit

Permalink
:add: revision version after fixing a bug while retrieving new parame…
Browse files Browse the repository at this point in the history
…ters without ptype
  • Loading branch information
b3j0f committed Apr 2, 2016
1 parent 16a1402 commit 0b74af7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
21 changes: 16 additions & 5 deletions b3j0f/conf/configurable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,27 @@ def _configure(

return result

def _bind_target(self, target, *args, **kwargs):
def _bind_target(self, target, ctx, *args, **kwargs):

if callable(target):
result = super(Configurable, self)._bind_target(
target=target, *args, **kwargs
)

try:
result = super(Configurable, self)._bind_target(
target=target, ctx=ctx, *args, **kwargs
)

except AttributeError:
self.remove_from(target=target, ctx=ctx)
def __init__(*args, **kwargs):
return object.__init__(*args, **kwargs)
target.__init__ = __init__
result = super(Configurable, self)._bind_target(
target=target, ctx=ctx, *args, **kwargs
)

else:
result = Annotation._bind_target(
self, target=target, *args, **kwargs
self, target=target, ctx=ctx, *args, **kwargs
)

return result
Expand Down
7 changes: 4 additions & 3 deletions b3j0f/conf/model/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Error(Exception):
_PARAM_NAME_COMPILER_MATCHER = re_compile(PARAM_NAME_REGEX).match

DEFAULT_NAME = re_compile('.*')
DEFAULT_PTYPE = object #: default ptype.
DEFAULT_PTYPE = None #: default ptype.
DEFAULT_LOCAL = True #: default local value.

def __init__(
Expand Down Expand Up @@ -457,7 +457,7 @@ def value(self, value):
"""

if value is None or (
self.ptype is not None and isinstance(value, self.ptype)
self.ptype is None or isinstance(value, self.ptype)
):
self._value = value

Expand All @@ -481,7 +481,8 @@ def copy(self, cleaned=False, *args, **kwargs):
"""

props = (
'name', 'parser', 'local', 'ptype', 'conf', 'scope', 'besteffort'
'name', 'parser', 'local', 'ptype', 'conf', 'scope', 'besteffort',
'safe'
)
for prop in props:
kwargs.setdefault(prop, getattr(self, prop))
Expand Down
7 changes: 7 additions & 0 deletions b3j0f/conf/model/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ def test_update(self):

self.assertTrue(self.me.cleaned)

copiedme.name = None

self.me.update(copiedme)

self.assertIsNone(copiedme.name)
self.assertIsNotNone(self.me.name)


class CompositeModelElementTest(UTCase):
"""Test the CompositeModelElement."""
Expand Down
10 changes: 8 additions & 2 deletions b3j0f/conf/parser/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ def serialize(expr):


def parse(
svalue, conf=None, configurable=None, ptype=object,
svalue, conf=None, configurable=None, ptype=None,
scope=DEFAULT_SCOPE, safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT
):
"""Parser which delegates parsing to expression or format parser."""

result = None

if ptype is None:
ptype = object

compilation = REGEX_EXPR.match(svalue)

_scope = {} if scope is None else scope.copy()
Expand Down Expand Up @@ -277,7 +280,7 @@ def _exprparser(


def _strparser(
svalue, safe=DEFAULT_SAFE, ptype=str, scope=DEFAULT_SCOPE,
svalue, safe=DEFAULT_SAFE, ptype=None, scope=DEFAULT_SCOPE,
configurable=None, conf=None, besteffort=DEFAULT_BESTEFFORT
):

Expand All @@ -288,6 +291,9 @@ def _strparser(
), svalue
)

if ptype is None:
ptype = str

if not issubclass(ptype, string_types):

if issubclass(ptype, bool):
Expand Down
2 changes: 1 addition & 1 deletion b3j0f/conf/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
# thanks to https://github.com/pycontribs/jira/blob/master/jira/version.py

#: project version
__version__ = '0.3.5'
__version__ = '0.3.6'
5 changes: 5 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ChangeLog
=========

0.3.6 (2016/04/02)
------------------

- fix bug while updating parameter ptype (new None values did change old consistent values).

0.3.5 (2016/04/02)
------------------

Expand Down

0 comments on commit 0b74af7

Please sign in to comment.