pep8 line too long

This commit is contained in:
gwen 2013-09-04 09:05:12 +02:00
parent fc9f6ce816
commit 9983739b2b
2 changed files with 28 additions and 14 deletions

View File

@ -23,9 +23,6 @@ option APIs
others
----------
.. automodule:: test.test_config_api
:members:
.. automodule:: test.test_mandatory
:members:
@ -38,18 +35,12 @@ others
.. automodule:: test.test_option_consistency
:members:
.. automodule:: test.test_option
:members:
.. automodule:: test.test_cache
:members:
.. automodule:: test.test_option_setting
:members:
.. automodule:: test.test_config
:members:
.. automodule:: test.test_freeze
:members:

View File

@ -97,7 +97,8 @@ class BaseOption(object):
"frozen" (which has noting to do with the high level "freeze"
propertie or "read_only" property)
"""
if not name.startswith('_state') and name not in ('_cache_paths', '_consistencies'):
if not name.startswith('_state') and \
name not in ('_cache_paths', '_consistencies'):
is_readonly = False
# never change _name
if name == '_name':
@ -184,6 +185,12 @@ class BaseOption(object):
self._state_consistencies = tuple(new_value)
def _impl_convert_requires(self, descr, load=False):
"""export of the requires during the serialization process
:type descr: :class:`tiramisu.option.OptionDescription`
:param load: `True` if we are at the init of the option description
:type load: bool
"""
if not load and self._requires is None:
self._state_requires = None
elif load and self._state_requires is None:
@ -238,7 +245,8 @@ class BaseOption(object):
try:
self._stated
except AttributeError:
raise SystemError(_('cannot serialize Option, only in OptionDescription'))
raise SystemError(_('cannot serialize Option, '
'only in OptionDescription'))
slots = set()
for subclass in self.__class__.__mro__:
if subclass is not object:
@ -246,7 +254,8 @@ class BaseOption(object):
slots -= frozenset(['_cache_paths', '__weakref__'])
states = {}
for slot in slots:
# remove variable if save variable converted in _state_xxxx variable
# remove variable if save variable converted
# in _state_xxxx variable
if '_state' + slot not in slots:
if slot.startswith('_state'):
# should exists
@ -264,6 +273,11 @@ class BaseOption(object):
# unserialize
def _impl_setstate(self, descr):
"""the under the hood stuff that need to be done
before the serialization.
:type descr: :class:`tiramisu.option.OptionDescription`
"""
self._impl_convert_consistencies(descr, load=True)
self._impl_convert_requires(descr, load=True)
try:
@ -274,6 +288,15 @@ class BaseOption(object):
pass
def __setstate__(self, state):
"""special method that enables us to serialize (pickle)
Usualy, a `__setstate__` method does'nt need any parameter,
but somme under the hood stuff need to be done before this action
:parameter state: a dict is passed to the loads, it is the attributes
of the options object
:type state: dict
"""
for key, value in state.items():
setattr(self, key, value)
@ -284,8 +307,8 @@ class Option(BaseOption):
Reminder: an Option object is **not** a container for the value
"""
__slots__ = ('_multi', '_validator', '_default_multi', '_default', '_callback',
'_multitype', '_master_slaves', '__weakref__')
__slots__ = ('_multi', '_validator', '_default_multi', '_default',
'_callback', '_multitype', '_master_slaves', '__weakref__')
_empty = ''
def __init__(self, name, doc, default=None, default_multi=None,