python 3.5 support
This commit is contained in:
parent
dadf859905
commit
c8bc3093c7
37 changed files with 89 additions and 64 deletions
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu import setting, value
|
from tiramisu import setting, value
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
"""theses tests are much more to test that config, option description, vs...
|
"""theses tests are much more to test that config, option description, vs...
|
||||||
**it's there** and answers via attribute access"""
|
**it's there** and answers via attribute access"""
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"configuration objects global API"
|
"configuration objects global API"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
import warnings, sys
|
import warnings, sys
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.config import Config, GroupConfig, MetaConfig
|
from tiramisu.config import Config, GroupConfig, MetaConfig
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups
|
from tiramisu.setting import groups
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
"frozen and hidden values"
|
"frozen and hidden values"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.value import Multi
|
from tiramisu.value import Multi
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""these tests are here to create some :class:`tiramisu.option.Option`'s
|
"""these tests are here to create some :class:`tiramisu.option.Option`'s
|
||||||
and to compare them
|
and to compare them
|
||||||
"""
|
"""
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
@ -1083,9 +1083,9 @@ def test_callback_raise():
|
||||||
cfg.read_write()
|
cfg.read_write()
|
||||||
try:
|
try:
|
||||||
cfg.od1.opt1
|
cfg.od1.opt1
|
||||||
except ConfigError, err:
|
except ConfigError as err:
|
||||||
assert '"Option 1"' in str(err)
|
assert '"Option 1"' in str(err)
|
||||||
try:
|
try:
|
||||||
cfg.od2.opt2
|
cfg.od2.opt2
|
||||||
except ConfigError, err:
|
except ConfigError as err:
|
||||||
assert '"Option 2"' in str(err)
|
assert '"Option 2"' in str(err)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"test all types of option default values for options, add new option in a descr"
|
"test all types of option default values for options, add new option in a descr"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"config.set() or config.setoption() or option.setoption()"
|
"config.set() or config.setoption() or option.setoption()"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
@ -564,10 +564,11 @@ def test_pprint():
|
||||||
setting = config.cfgimpl_get_settings()
|
setting = config.cfgimpl_get_settings()
|
||||||
config.read_write()
|
config.read_write()
|
||||||
config.int = 1
|
config.int = 1
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
config.str
|
config.str
|
||||||
except Exception, err:
|
except Exception as error:
|
||||||
pass
|
err = error
|
||||||
|
|
||||||
list_disabled_1 = 'disabled (' + display_list([msg_is.format('string2', 'string'), msg_is.format('Test int option', '1')]) + ')'
|
list_disabled_1 = 'disabled (' + display_list([msg_is.format('string2', 'string'), msg_is.format('Test int option', '1')]) + ')'
|
||||||
list_disabled_2 = 'disabled (' + display_list([msg_is.format('Test int option', '1'), msg_is.format('string2', 'string')]) + ')'
|
list_disabled_2 = 'disabled (' + display_list([msg_is.format('Test int option', '1'), msg_is.format('string2', 'string')]) + ')'
|
||||||
|
@ -578,17 +579,20 @@ def test_pprint():
|
||||||
comp4 = str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_hidden, list_disabled_2])))
|
comp4 = str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_hidden, list_disabled_2])))
|
||||||
assert comp1 or comp2 or comp3 or comp4
|
assert comp1 or comp2 or comp3 or comp4
|
||||||
|
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
config.options.val2
|
config.options.val2
|
||||||
except Exception, err:
|
except Exception as error:
|
||||||
pass
|
err = error
|
||||||
|
|
||||||
assert str(err) == msg_error.format('optiondescription', 'options', prop, 'hidden (' + msg_is.format('Test int option', 1) + ')')
|
assert str(err) == msg_error.format('optiondescription', 'options', prop, 'hidden (' + msg_is.format('Test int option', 1) + ')')
|
||||||
|
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
config.val3
|
config.val3
|
||||||
except Exception, err:
|
except Exception as error:
|
||||||
pass
|
err = error
|
||||||
|
|
||||||
msg_1 = msg_is.format('string2', 'string')
|
msg_1 = msg_is.format('string2', 'string')
|
||||||
msg_2 = msg_is.format('Test int option', 1)
|
msg_2 = msg_is.format('Test int option', 1)
|
||||||
msg_3 = msg_is_not.format('Test int option', display_list([2, 3, 4], 'or'))
|
msg_3 = msg_is_not.format('Test int option', display_list([2, 3, 4], 'or'))
|
||||||
|
@ -607,16 +611,18 @@ def test_pprint():
|
||||||
comp6 = str(err) == msg_error.format('option', 'val3', prop, list_hidden)
|
comp6 = str(err) == msg_error.format('option', 'val3', prop, list_hidden)
|
||||||
assert comp1 or comp2 or comp3 or comp4 or comp5 or comp6
|
assert comp1 or comp2 or comp3 or comp4 or comp5 or comp6
|
||||||
|
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
config.string
|
config.string
|
||||||
except Exception, err:
|
except Exception as error:
|
||||||
pass
|
err = error
|
||||||
|
|
||||||
assert str(err) == msg_error.format('option', 'string', properties, display_list(['disabled', 'hidden']))
|
assert str(err) == msg_error.format('option', 'string', properties, display_list(['disabled', 'hidden']))
|
||||||
|
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
config.string3
|
config.string3
|
||||||
except Exception, err:
|
except Exception as error:
|
||||||
pass
|
err = error
|
||||||
|
|
||||||
assert str(err) == msg_error.format('option', 'string3', prop, 'hidden')
|
assert str(err) == msg_error.format('option', 'string3', prop, 'hidden')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
"frozen and hidden values"
|
"frozen and hidden values"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"configuration objects global API"
|
"configuration objects global API"
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
@ -97,7 +97,7 @@ def test_validator():
|
||||||
raises(ValueError, "cfg.opt2 = 'val'")
|
raises(ValueError, "cfg.opt2 = 'val'")
|
||||||
try:
|
try:
|
||||||
cfg.opt2 = 'val'
|
cfg.opt2 = 'val'
|
||||||
except ValueError, err:
|
except ValueError as err:
|
||||||
msg = _('"{0}" is an invalid {1} for "{2}", {3}').format('val', _('string'), 'opt2', 'test error')
|
msg = _('"{0}" is an invalid {1} for "{2}", {3}').format('val', _('string'), 'opt2', 'test error')
|
||||||
assert str(err) == msg
|
assert str(err) == msg
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#this test is much more to test that **it's there** and answers attribute access
|
#this test is much more to test that **it's there** and answers attribute access
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
## coding: utf-8
|
## coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
@ -11,7 +11,7 @@ from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\
|
||||||
URLOption, FilenameOption
|
URLOption, FilenameOption
|
||||||
|
|
||||||
|
|
||||||
print "FIXME slot pour un masterslaves !!"
|
#FIXME slot pour un masterslaves !!
|
||||||
|
|
||||||
|
|
||||||
def test_slots_option():
|
def test_slots_option():
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
#from py.test import raises
|
#from py.test import raises
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.option import BoolOption, StrOption, SymLinkOption, \
|
from tiramisu.option import BoolOption, StrOption, SymLinkOption, \
|
||||||
|
|
|
@ -263,13 +263,13 @@ def calculate(option, callback, is_validator, args, kwargs):
|
||||||
if len(args) != 0 or len(kwargs) != 0:
|
if len(args) != 0 or len(kwargs) != 0:
|
||||||
msg = _('unexpected error "{0}" in function "{1}" with arguments "{3}" and "{4}" '
|
msg = _('unexpected error "{0}" in function "{1}" with arguments "{3}" and "{4}" '
|
||||||
'for option "{2}"').format(str(error),
|
'for option "{2}"').format(str(error),
|
||||||
callback.func_name,
|
callback.__name__,
|
||||||
option.impl_get_display_name(),
|
option.impl_get_display_name(),
|
||||||
args,
|
args,
|
||||||
kwargs)
|
kwargs)
|
||||||
else:
|
else:
|
||||||
msg = _('unexpected error "{0}" in function "{1}" for option "{2}"'
|
msg = _('unexpected error "{0}" in function "{1}" for option "{2}"'
|
||||||
'').format(str(error),
|
'').format(str(error),
|
||||||
callback.func_name,
|
callback.__name__,
|
||||||
option.impl_get_display_name())
|
option.impl_get_display_name())
|
||||||
raise ConfigError(msg)
|
raise ConfigError(msg)
|
||||||
|
|
|
@ -168,7 +168,10 @@ class SubConfig(object):
|
||||||
yield name, self.getattr(name,
|
yield name, self.getattr(name,
|
||||||
force_permissive=force_permissive)
|
force_permissive=force_permissive)
|
||||||
except GeneratorExit: # pragma: optional cover
|
except GeneratorExit: # pragma: optional cover
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
else:
|
||||||
|
raise GeneratorExit()
|
||||||
except PropertiesOptionError: # pragma: optional cover
|
except PropertiesOptionError: # pragma: optional cover
|
||||||
pass # option with properties
|
pass # option with properties
|
||||||
|
|
||||||
|
@ -180,7 +183,10 @@ class SubConfig(object):
|
||||||
yield child.impl_getname(), self.getattr(child.impl_getname(),
|
yield child.impl_getname(), self.getattr(child.impl_getname(),
|
||||||
force_permissive=force_permissive)
|
force_permissive=force_permissive)
|
||||||
except GeneratorExit: # pragma: optional cover
|
except GeneratorExit: # pragma: optional cover
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
else:
|
||||||
|
raise GeneratorExit()
|
||||||
except PropertiesOptionError: # pragma: optional cover
|
except PropertiesOptionError: # pragma: optional cover
|
||||||
pass # option with properties
|
pass # option with properties
|
||||||
|
|
||||||
|
@ -206,7 +212,10 @@ class SubConfig(object):
|
||||||
name = child.impl_getname()
|
name = child.impl_getname()
|
||||||
yield name, self.getattr(name, force_permissive=force_permissive)
|
yield name, self.getattr(name, force_permissive=force_permissive)
|
||||||
except GeneratorExit: # pragma: optional cover
|
except GeneratorExit: # pragma: optional cover
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
else:
|
||||||
|
raise GeneratorExit()
|
||||||
except PropertiesOptionError: # pragma: optional cover
|
except PropertiesOptionError: # pragma: optional cover
|
||||||
pass
|
pass
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
"user defined exceptions"
|
"user defined exceptions"
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def display_list(lst, separator='and'):
|
def display_list(lst, separator='and'):
|
||||||
|
@ -27,21 +28,22 @@ def display_list(lst, separator='and'):
|
||||||
return ''
|
return ''
|
||||||
elif len(lst) == 1:
|
elif len(lst) == 1:
|
||||||
ret = lst[0]
|
ret = lst[0]
|
||||||
if isinstance(ret, unicode):
|
if sys.version_info[0] < 3 and isinstance(ret, unicode):
|
||||||
ret = ret.encode('utf8')
|
ret = ret.encode('utf8')
|
||||||
if not isinstance(ret, str):
|
if not isinstance(ret, str):
|
||||||
ret = str(ret)
|
ret = str(ret)
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
|
lst.sort()
|
||||||
lst_ = []
|
lst_ = []
|
||||||
for l in lst[:-1]:
|
for l in lst[:-1]:
|
||||||
if isinstance(l, unicode):
|
if sys.version_info[0] < 3 and isinstance(l, unicode):
|
||||||
l = l.encode('utf8')
|
l = l.encode('utf8')
|
||||||
elif not isinstance(l, str):
|
elif not isinstance(l, str):
|
||||||
l = str(l)
|
l = str(l)
|
||||||
lst_.append(l)
|
lst_.append(l)
|
||||||
last = lst[-1]
|
last = lst[-1]
|
||||||
if isinstance(last, unicode):
|
if sys.version_info[0] < 3 and isinstance(last, unicode):
|
||||||
last = last.encode('utf8')
|
last = last.encode('utf8')
|
||||||
if not isinstance(last, str):
|
if not isinstance(last, str):
|
||||||
last = str(last)
|
last = str(last)
|
||||||
|
|
|
@ -22,6 +22,10 @@ import re
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
import warnings
|
import warnings
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
from inspect import signature
|
||||||
|
else:
|
||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
|
|
||||||
from ..i18n import _
|
from ..i18n import _
|
||||||
|
@ -180,13 +184,17 @@ class Base(StorageBase):
|
||||||
self.commit(session)
|
self.commit(session)
|
||||||
|
|
||||||
def _build_validator_params(self, validator, validator_params):
|
def _build_validator_params(self, validator, validator_params):
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
func_args = getargspec(validator)
|
func_args = getargspec(validator)
|
||||||
defaults = func_args.defaults
|
defaults = func_args.defaults
|
||||||
if defaults is None:
|
if defaults is None:
|
||||||
defaults = []
|
defaults = []
|
||||||
args = func_args.args[0:len(func_args.args)-len(defaults)]
|
args = func_args.args[0:len(func_args.args)-len(defaults)]
|
||||||
|
else:
|
||||||
|
func_params = signature(validator).parameters
|
||||||
|
args = [f.name for f in func_params.values() if f.default is f.empty]
|
||||||
if validator_params is not None:
|
if validator_params is not None:
|
||||||
kwargs = validator_params.keys()
|
kwargs = list(validator_params.keys())
|
||||||
if '' in kwargs:
|
if '' in kwargs:
|
||||||
kwargs.remove('')
|
kwargs.remove('')
|
||||||
for kwarg in kwargs:
|
for kwarg in kwargs:
|
||||||
|
@ -454,7 +462,7 @@ class BaseOption(Base):
|
||||||
name = dyn_name
|
name = dyn_name
|
||||||
else:
|
else:
|
||||||
name = self.impl_getname()
|
name = self.impl_getname()
|
||||||
if isinstance(name, unicode):
|
if sys.version_info[0] < 3 and isinstance(name, unicode):
|
||||||
name = name.encode('utf8')
|
name = name.encode('utf8')
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -1024,7 +1032,7 @@ def validate_requires_arg(new_option, multi, requires, name):
|
||||||
operator = get_operator(require)
|
operator = get_operator(require)
|
||||||
if isinstance(expected, list):
|
if isinstance(expected, list):
|
||||||
for exp in expected:
|
for exp in expected:
|
||||||
if exp.keys() != ['option', 'value']:
|
if set(exp.keys()) != {'option', 'value'}:
|
||||||
raise ValueError(_('malformed requirements expected must have '
|
raise ValueError(_('malformed requirements expected must have '
|
||||||
'option and value for option {0}').format(name))
|
'option and value for option {0}').format(name))
|
||||||
option = exp['option']
|
option = exp['option']
|
||||||
|
|
|
@ -633,5 +633,5 @@ class DateOption(Option):
|
||||||
return err
|
return err
|
||||||
try:
|
try:
|
||||||
datetime.datetime.strptime(value,"%Y-%m-%d")
|
datetime.datetime.strptime(value,"%Y-%m-%d")
|
||||||
except ValueError, err:
|
except ValueError:
|
||||||
return ValueError()
|
return ValueError()
|
||||||
|
|
|
@ -75,7 +75,7 @@ class StorageBase(object):
|
||||||
_setattr = object.__setattr__
|
_setattr = object.__setattr__
|
||||||
_setattr(self, '_name', name)
|
_setattr(self, '_name', name)
|
||||||
if doc is not undefined:
|
if doc is not undefined:
|
||||||
if isinstance(doc, str):
|
if sys.version_info[0] < 3 and isinstance(doc, str):
|
||||||
doc = doc.decode('utf8')
|
doc = doc.decode('utf8')
|
||||||
_setattr(self, '_informations', {'doc': doc})
|
_setattr(self, '_informations', {'doc': doc})
|
||||||
if multi != 1:
|
if multi != 1:
|
||||||
|
|
Loading…
Reference in a new issue