dataimport.py
branchstable
changeset 7159 3bcccd3ab6b6
parent 7158 0f31a50b144e
child 7160 923013173031
equal deleted inserted replaced
7158:0f31a50b144e 7159:3bcccd3ab6b6
    72 import os.path as osp
    72 import os.path as osp
    73 from StringIO import StringIO
    73 from StringIO import StringIO
    74 from copy import copy
    74 from copy import copy
    75 from datetime import datetime
    75 from datetime import datetime
    76 
    76 
    77 from logilab.common import shellutils
    77 from logilab.common import shellutils, attrdict
    78 from logilab.common.date import strptime
    78 from logilab.common.date import strptime
    79 from logilab.common.decorators import cached
    79 from logilab.common.decorators import cached
    80 from logilab.common.deprecation import deprecated
    80 from logilab.common.deprecation import deprecated
    81 
    81 
    82 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES
    82 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES
   303     def _put(self, type, item):
   303     def _put(self, type, item):
   304         self.items.append(item)
   304         self.items.append(item)
   305         return len(self.items) - 1
   305         return len(self.items) - 1
   306 
   306 
   307     def create_entity(self, etype, **data):
   307     def create_entity(self, etype, **data):
   308         data['eid'] =  eid = self._put(etype, data)
   308         data = attrdict(data)
       
   309         data['eid'] = eid = self._put(etype, data)
   309         self.eids[eid] = data
   310         self.eids[eid] = data
   310         self.types.setdefault(etype, []).append(eid)
   311         self.types.setdefault(etype, []).append(eid)
   311         return data
   312         return data
   312 
   313 
   313     @deprecated("[3.11] add is deprecated, use create_entity instead")
   314     @deprecated("[3.11] add is deprecated, use create_entity instead")