equal
deleted
inserted
replaced
180 """ |
180 """ |
181 res = {} |
181 res = {} |
182 assert isinstance(row, dict) |
182 assert isinstance(row, dict) |
183 assert isinstance(map, list) |
183 assert isinstance(map, list) |
184 for src, dest, funcs in map: |
184 for src, dest, funcs in map: |
185 res[dest] = row[src] |
185 try: |
|
186 res[dest] = row[src] |
|
187 except KeyError: |
|
188 continue |
186 try: |
189 try: |
187 for func in funcs: |
190 for func in funcs: |
188 res[dest] = func(res[dest]) |
191 res[dest] = func(res[dest]) |
189 if res[dest] is None: |
192 if res[dest] is None: |
190 break |
193 break |
444 def __init__(self, session=None, commit=None): |
447 def __init__(self, session=None, commit=None): |
445 ObjectStore.__init__(self) |
448 ObjectStore.__init__(self) |
446 if session is None: |
449 if session is None: |
447 sys.exit('please provide a session of run this script with cubicweb-ctl shell and pass cnx as session') |
450 sys.exit('please provide a session of run this script with cubicweb-ctl shell and pass cnx as session') |
448 if not hasattr(session, 'set_cnxset'): |
451 if not hasattr(session, 'set_cnxset'): |
449 # connection |
452 if hasattr(session, 'request'): |
450 cnx = session |
453 # connection object |
451 session = session.request() |
454 cnx = session |
|
455 session = session.request() |
|
456 else: # object is already a request |
|
457 cnx = session.cnx |
452 session.set_cnxset = lambda : None |
458 session.set_cnxset = lambda : None |
453 commit = commit or cnx.commit |
459 commit = commit or cnx.commit |
454 else: |
460 else: |
455 session.set_cnxset() |
461 session.set_cnxset() |
456 self.session = session |
462 self.session = session |