[dataimport] methods that modify in-place shouldn't return value
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 21 Oct 2015 16:34:52 +0200
changeset 10864 b7f4acf0473b
parent 10863 8e1f6de61300
child 10865 2537df9fdd27
[dataimport] methods that modify in-place shouldn't return value Also mark those methods private and drop some useless comments in passing. Related to #5414760
dataimport/massive_store.py
--- a/dataimport/massive_store.py	Wed Oct 21 16:32:11 2015 +0200
+++ b/dataimport/massive_store.py	Wed Oct 21 16:34:52 2015 +0200
@@ -419,24 +419,20 @@
             for eid in range(last_eid - self._eids_seq_range + 1, last_eid + 1):
                 yield eid
 
-    def apply_size_constraints(self, etype, kwargs):
-        """ Apply the size constraints for a given etype, attribute and value
-        """
+    def _apply_size_constraints(self, etype, kwargs):
+        """Apply the size constraints for a given etype, attribute and value."""
         size_constraints = self.size_constraints[etype]
         for attr, value in kwargs.items():
             if value:
                 maxsize = size_constraints.get(attr)
                 if maxsize is not None and len(value) > maxsize:
                     kwargs[attr] = value[:maxsize-4] + '...'
-        return kwargs
 
-    def apply_default_values(self, etype, kwargs):
-        """ Apply the default values for a given etype, attribute and value
-        """
+    def _apply_default_values(self, etype, kwargs):
+        """Apply the default values for a given etype, attribute and value."""
         default_values = self.default_values[etype]
         missing_keys = set(default_values) - set(kwargs)
         kwargs.update((key, default_values[key]) for key in missing_keys)
-        return kwargs
 
     # store api ################################################################
 
@@ -461,13 +457,9 @@
             # If eid is not given and the eids sequence is set,
             # use the value from the sequence
             kwargs['eid'] = self.get_next_eid()
-        # Check size constraints
-        kwargs = self.apply_size_constraints(etype, kwargs)
-        # Apply default values
-        kwargs = self.apply_default_values(etype, kwargs)
-        # Push data
+        self._apply_size_constraints(etype, kwargs)
+        self._apply_default_values(etype, kwargs)
         self._data_entities[etype].append(kwargs)
-        # Return eid
         return kwargs.get('eid')
 
     def prepare_insert_relation(self, eid_from, rtype, eid_to, **kwargs):