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