def test_symbols(): sym1 = util.symbol('foo') assert sym1.name == 'foo' sym2 = util.symbol('foo') assert sym1 is sym2 assert sym1 == sym2 sym3 = util.symbol('bar') assert sym1 is not sym3 assert sym1 != sym3 assert repr(sym3) == 'bar'
def test_symbol_pickle(): import pickle try: import cPickle except ImportError: cPickle = pickle for mod in pickle, cPickle: sym1 = util.symbol('foo') sym2 = util.symbol('foo') assert sym1 is sym2 # default s = pickle.dumps(sym1) sym3 = pickle.loads(s) for protocol in 0, 1, 2: serial = pickle.dumps(sym1) rt = pickle.loads(serial) assert rt is sym1 assert rt is sym2
import operator from flatland.schema.paths import pathexpr from flatland.signals import validator_validated from flatland.util import ( Unspecified, assignable_class_property, class_cloner, named_int_factory, symbol, ) __all__ = 'Element' NoneType = type(None) Root = symbol('Root') NotEmpty = symbol('NotEmpty') Skip = named_int_factory('Skip', True, doc="""\ Abort validation of the element & mark as valid. """) SkipAll = named_int_factory('SkipAll', True, doc="""\ Abort validation of the element and its children & mark as valid. The :attr:`~Element.valid` of child elements will not be changed by skipping. Unless otherwise set, the child elements will retain the default value (:obj:`Unevaluated`). Only meaningful during a decent validation. Functions as :obj:`Skip` on upward validation. """)
from weakref import WeakKeyDictionary from flatland._compat import iterkeys, itervalues from flatland.util import symbol Deleted = symbol('deleted') class DictLike(object): def iteritems(self): # pragma: nocover raise NotImplementedError def items(self): return list(self.iteritems()) def iterkeys(self): return (item[0] for item in self.iteritems()) def keys(self): return list(iterkeys(self)) def itervalues(self): return (item[1] for item in self.iteritems()) def values(self): return list(itervalues(self)) def get(self, key, default=None): try:
import operator from flatland.schema.paths import pathexpr from flatland.schema.properties import Properties from flatland.signals import validator_validated from flatland.util import ( Unspecified, assignable_class_property, class_cloner, named_int_factory, symbol, ) __all__ = 'Element' NoneType = type(None) Root = symbol('Root') NotEmpty = symbol('NotEmpty') Unset = symbol('Unset') Skip = named_int_factory('Skip', True, doc="""\ Abort validation of the element & mark as valid. """) SkipAll = named_int_factory('SkipAll', True, doc="""\ Abort validation of the element and its children & mark as valid. The :attr:`~Element.valid` of child elements will not be changed by skipping.
import re from flatland.util import symbol __all__ = ['pathexpr'] expression_cache = {} max_cache_size = 1024 TOP = symbol('TOP') UP = symbol('UP') SLICE = symbol('SLICE') NAME = symbol('NAME') _tokenize_re = re.compile( r""" ( # name (?:\\[/.\[]|[^/\[])+ | # / (?<!\\)/ | # [1:2:3] (?<!\\)\[(-?\d*:?-?\d*\:?-?\d*)(?<!\\)\](?=$|/|\[) | # [bogus] (?<!\\)\[[^\]]*(?<!\\)\](?=$|/|\[) | # .. at start ^\.\. | # .. in expression (?<=[^\\]/)\.\. | \[ )
import re from flatland.util import symbol __all__ = ['pathexpr'] expression_cache = {} max_cache_size = 1024 TOP = symbol('TOP') UP = symbol('UP') HERE = symbol('HERE') SLICE = symbol('SLICE') NAME = symbol('NAME') _tokenize_re = re.compile(r""" ( # name (?:\\[/.\[]|[^/\[])+ | # / (?<!\\)/ | # [1:2:3] (?<!\\)\[(-?\d*:?-?\d*\:?-?\d*)(?<!\\)\](?=$|/|\[) | # [bogus] (?<!\\)\[[^\]]*(?<!\\)\](?=$|/|\[) | # . or .. at start ^\.\.? | # . or .. in expression (?<=[^\\]/)\.\.? | \[
from weakref import WeakKeyDictionary from flatland._compat import iterkeys, itervalues from flatland.util import symbol Deleted = symbol('deleted') class DictLike(object): def iteritems(self): # pragma: nocover raise NotImplementedError def items(self): return list(self.iteritems()) def iterkeys(self): return (item[0] for item in self.iteritems()) def keys(self): return list(iterkeys(self)) def itervalues(self): return (item[1] for item in self.iteritems()) def values(self): return list(itervalues(self)) def get(self, key, default=None): try: return self[key] except KeyError:
from flatland.schema.paths import pathexpr from flatland.schema.properties import Properties from flatland.signals import validator_validated from flatland.util import ( Unspecified, assignable_class_property, class_cloner, named_int_factory, symbol, ) __all__ = 'Element' NoneType = type(None) Root = symbol('Root') NotEmpty = symbol('NotEmpty') Unset = symbol('Unset') Skip = named_int_factory('Skip', True, doc="""\ Abort validation of the element & mark as valid. """) SkipAll = named_int_factory('SkipAll', True, doc="""\ Abort validation of the element and its children & mark as valid. The :attr:`~Element.valid` of child elements will not be changed by skipping. Unless otherwise set, the child elements will retain the default value (:obj:`Unevaluated`). Only meaningful during a decent validation. Functions as :obj:`Skip` on upward validation. """)
import itertools import operator from flatland.schema.paths import pathexpr from flatland.signals import validator_validated from flatland.util import ( Unspecified, assignable_class_property, class_cloner, named_int_factory, symbol, ) __all__ = 'Element' NoneType = type(None) Root = symbol('Root') NotEmpty = symbol('NotEmpty') Skip = named_int_factory('Skip', True, doc="""\ Abort validation of the element & mark as valid. """) SkipAll = named_int_factory('SkipAll', True, doc="""\ Abort validation of the element and its children & mark as valid. The :attr:`~Element.valid` of child elements will not be changed by skipping. Unless otherwise set, the child elements will retain the default value