Permalink
Browse files

remove outdated stuff

  • Loading branch information...
1 parent 7743438 commit c132b6e8d29bccbde47c79f236346442e6e0b75c @rnixx rnixx committed May 18, 2012
Showing with 460 additions and 1,452 deletions.
  1. +10 −1 README.rst
  2. +0 −206 src/node/aliasing.py
  3. +0 −245 src/node/aliasing.rst
  4. +2 −0 src/node/base.rst
  5. +0 −535 src/node/bbb.py
  6. +0 −358 src/node/bbb.rst
  7. +0 −99 src/node/composition.py
  8. +197 −3 src/node/parts/alias.py
  9. +251 −3 src/node/parts/alias.rst
  10. +0 −2 src/node/tests.py
View
@@ -244,7 +244,6 @@ TestCoverage
Summary of the test coverage report::
lines cov% module
- 107 100% node.aliasing
53 100% node.base
14 100% node.events
127 100% node.interfaces
@@ -281,9 +280,19 @@ Contributors
Changes
=======
+
0.9.7dev
--------
+- Move aliaser objects from ``node.aliasing`` to ``node.parts.alias``.
+ [rnix, 2012-05-18]
+
+- Remove ``composition`` module.
+ [rnix, 2012-05-18]
+
+- Remove ``bbb`` module.
+ [rnix, 2012-05-18]
+
- ``node.parts.mapping.ClonableMapping`` nor supports deepcopy.
[rnix, 2012-05-18]
View
@@ -1,206 +0,0 @@
-from odict import odict
-from plumber import (
- plumber,
- Part,
-)
-from zope.interface import implementer
-from zope.interface.common.mapping import (
- IEnumerableMapping,
- IFullMapping,
-)
-from node.interfaces import IAliaser
-from node.utils import ReverseMapping
-from node.parts import (
- Adopt,
- Nodify,
- NodeChildValidate,
-)
-
-
-@implementer(IAliaser, IFullMapping)
-class DictAliaser(odict):
- """Uses its own dictionary for aliasing.
-
- ``__getitem__`` -> unalias
- """
-
- def __init__(self, data=(), strict=True):
- super(DictAliaser, self).__init__(data)
- self.strict = strict
-
- def alias(self, key):
- try:
- return ReverseMapping(self)[key]
- except KeyError, e:
- if not self.strict:
- return key
- raise e
-
- def unalias(self, aliased_key):
- try:
- return self[aliased_key]
- except KeyError, e:
- if not self.strict:
- return aliased_key
- raise e
-
-
-@implementer(IAliaser)
-class PrefixAliaser(object):
- """An aliaser that prefix all keys.
-
- As it never raise KeyError it is not whitelisting.
- """
-
- def __init__(self, prefix=None):
- self.prefix = prefix
-
- def alias(self, key):
- return (self.prefix or '') + key
-
- def unalias(self, prefixed_key):
- """Returns the real key for a prefixed_key.
- """
- prefix = self.prefix or ''
- if not prefixed_key.startswith(prefix):
- raise KeyError(u"key '%s' does not match prefix '%s'" % \
- (prefixed_key, prefix))
- return prefixed_key[len(prefix):]
-
-
-@implementer(IAliaser)
-class SuffixAliaser(object):
- """An aliaser that suffixes all keys.
-
- As it never raise KeyError it is not whitelisting.
- """
-
- def __init__(self, suffix=None):
- self.suffix = suffix
-
- def alias(self, key):
- return key + (self.suffix or '')
-
- def unalias(self, suffixed_key):
- """returns the real key for a suffixed_key
- """
- suffix = self.suffix or ''
- if not suffixed_key.endswith(suffix):
- raise KeyError(
- u"key '%s' does not match suffix '%s'" % \
- (suffixed_key, suffix)
- )
- return suffixed_key[:-len(suffix)]
-
-
-@implementer(IAliaser)
-class AliaserChain(object):
- """A chain of aliasers.
-
- chain = [aliaser1, aliaser2]
- chain.alias(key) == aliaser2.alias(aliaser1.alias(key))
- chain.unalias(alias_key) == aliaser2.unalias(aliaser1.unalias(aliased_key))
- """
-
- # XXX: we are IEnumerableMapping if one of our childs is, which is
- # important as we become a whitelist, eg. for Node.__iter__
-
- def __init__(self, chain=None):
- self.chain = chain
-
- def alias(self, key):
- for aliaser in self.chain:
- key = aliaser.alias(key)
- return key
-
- def unalias(self, key):
- for aliaser in reversed(self.chain):
- key = aliaser.unalias(key)
- return key
-
-
-class PrefixSuffixAliaser(AliaserChain):
- """Prefixes and suffixes.
- """
-
- def __init__(self, prefix=None, suffix=None):
- self.chain = (
- PrefixAliaser(prefix),
- SuffixAliaser(suffix))
-
-
-#class NamedAliasers(dict):
-# """A dictionary storing aliasers by name.
-#
-# XXX
-# """
-
-
-class AliasedNodespace(object):
- """Performs aliasing/unaliasing for node children.
-
- Is not the parent of its children, the children don't know about their name
- here.
-
- Future additional mode: children are wrapped, wrapper knows name and we are
- parent of wrapper.
- """
- __metaclass__ = plumber
- __plumbing__ = (
- NodeChildValidate,
- Adopt,
- Nodify,
- )
-
- def __init__(self, context, aliaser=None):
- """
- context
- the node whose children to alias
-
- aliaser
- the aliaser to be used
- """
- # XXX: is just taking over the name ok for all use cases?
- # XXX: case where not? -rn
- #super(AliasedNodespace, self).__init__(context.name)
-
- self.__name__ = context.name
- self.__parent__ = None
-
- self.context = context
- self.aliaser = aliaser
-
- def __delitem__(self, key):
- unaliased_key = self.aliaser and self.aliaser.unalias(key) or key
- try:
- del self.context[unaliased_key]
- except KeyError:
- raise KeyError(key)
-
- def __getitem__(self, key):
- unaliased_key = self.aliaser and self.aliaser.unalias(key) or key
- try:
- return self.context[unaliased_key]
- except KeyError:
- raise KeyError(key)
-
- def __setitem__(self, key, val):
- unaliased_key = self.aliaser and self.aliaser.unalias(key) or key
- self.context[unaliased_key] = val
-
- def __iter__(self):
- for key in self.context:
- try:
- yield self.aliaser and self.aliaser.alias(key) or key
- except KeyError:
- if IEnumerableMapping.providedBy(self.aliaser):
- # an enumerable aliaser whitelists, we skip non-listed keys
- continue
- # no whitelisting and a KeyError on our internal data: that's
- # bad! Most probably not triggered on _Node but a subclass
- # XXX: test case showing this.
- raise RuntimeError( #pragma NO COVERAGE
- u"Inconsist internal node state") #pragma NO COVERAGE
-
- def __repr__(self):
- return "Aliased " + self.context.__repr__()
Oops, something went wrong.

0 comments on commit c132b6e

Please sign in to comment.