diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2014-05-18 12:40:25 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2014-05-18 14:18:49 +0200 |
commit | d26f41368e7c8936306cf1c34d73fff40d958128 (patch) | |
tree | fa80cfba7b1ccfaddd34eefde096b38fe9c78c13 /factory/containers.py | |
parent | 395744736691b3412dbedaffa8735e248a70c3c1 (diff) | |
download | factory-boy-d26f41368e7c8936306cf1c34d73fff40d958128.tar factory-boy-d26f41368e7c8936306cf1c34d73fff40d958128.tar.gz |
Remove containers.DeclarationsDict.
Now replaced with a simple dict.
Diffstat (limited to 'factory/containers.py')
-rw-r--r-- | factory/containers.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/factory/containers.py b/factory/containers.py index 4537e44..c0c5e24 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -121,61 +121,6 @@ class LazyStub(object): raise AttributeError('Setting of object attributes is not allowed') -class DeclarationDict(dict): - """Slightly extended dict to work with OrderedDeclaration.""" - - def is_declaration(self, name, value): - """Determines if a class attribute is a field value declaration. - - Based on the name and value of the class attribute, return ``True`` if - it looks like a declaration of a default field value, ``False`` if it - is private (name starts with '_') or a classmethod or staticmethod. - - """ - if isinstance(value, (classmethod, staticmethod)): - return False - elif isinstance(value, declarations.OrderedDeclaration): - return True - return (not name.startswith("_") and not name.startswith("FACTORY_")) - - def update_with_public(self, d): - """Updates the DeclarationDict from a class definition dict. - - Takes into account all public attributes and OrderedDeclaration - instances; ignores all class/staticmethods and private attributes - (starting with '_'). - - Returns a dict containing all remaining elements. - """ - remaining = {} - for k, v in d.items(): - if self.is_declaration(k, v): - self[k] = v - else: - remaining[k] = v - return remaining - - def copy(self, extra=None): - """Copy this DeclarationDict into another one, including extra values. - - Args: - extra (dict): additional attributes to include in the copy. - """ - new = self.__class__() - new.update(self) - if extra: - new.update(extra) - return new - - -class PostGenerationDeclarationDict(DeclarationDict): - """Alternate DeclarationDict for PostGenerationDeclaration.""" - - def is_declaration(self, name, value): - """Captures instances of PostGenerationDeclaration.""" - return isinstance(value, declarations.PostGenerationDeclaration) - - class LazyValue(object): """Some kind of "lazy evaluating" object.""" |