diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-04-09 01:10:42 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-04-09 01:10:42 +0200 |
commit | e80cbdc3224297ee57667e4000f1a671af05f520 (patch) | |
tree | 94275d5add1734ef6d03b0bb42d5af06bd758eba /factory/containers.py | |
parent | 250ce5bdc8b6067a28351f5b3bb4c418d3f1e731 (diff) | |
download | factory-boy-e80cbdc3224297ee57667e4000f1a671af05f520.tar factory-boy-e80cbdc3224297ee57667e4000f1a671af05f520.tar.gz |
Move ATTR_SPLITTER logic to a dedicated module.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory/containers.py')
-rw-r--r-- | factory/containers.py | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/factory/containers.py b/factory/containers.py index 2f92f62..b8557d6 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -22,11 +22,7 @@ from factory import declarations - - -#: String for splitting an attribute name into a -#: (subfactory_name, subfactory_field) tuple. -ATTR_SPLITTER = '__' +from factory import utils class CyclicDefinitionError(Exception): @@ -238,18 +234,7 @@ class AttributeBuilder(object): self.factory = factory self._containers = extra.pop('__containers', None) self._attrs = factory.declarations(extra) - self._subfields = self._extract_subfields() - - def _extract_subfields(self): - """Extract the subfields from the declarations list.""" - sub_fields = {} - for key in list(self._attrs): - if ATTR_SPLITTER in key: - # Trying to define a default of a subfactory - cls_name, attr_name = key.split(ATTR_SPLITTER, 1) - if cls_name in self._attrs: - sub_fields.setdefault(cls_name, {})[attr_name] = self._attrs.pop(key) - return sub_fields + self._subfields = utils.multi_extract_dict(self._attrs.keys(), self._attrs) def build(self, create): """Build a dictionary of attributes. |