[server] Use dict.setdefault() instead of if/else in repo.glob_add_relations()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 30 Nov 2017 11:20:58 +0100
changeset 12240 8eb15566142f
parent 12239 19aae64c4010
child 12241 06deb43c23c3
[server] Use dict.setdefault() instead of if/else in repo.glob_add_relations()
cubicweb/server/repository.py
--- a/cubicweb/server/repository.py	Fri Nov 03 15:26:32 2017 +0100
+++ b/cubicweb/server/repository.py	Thu Nov 30 11:20:58 2017 +0100
@@ -923,10 +923,7 @@
                 for subjeid, objeid in eids_subj_obj:
                     print('ADD relation', subjeid, rtype, objeid)
             for subjeid, objeid in eids_subj_obj:
-                if rtype in relations_by_rtype:
-                    relations_by_rtype[rtype].append((subjeid, objeid))
-                else:
-                    relations_by_rtype[rtype] = [(subjeid, objeid)]
+                relations_by_rtype.setdefault(rtype, []).append((subjeid, objeid))
                 if not activintegrity:
                     continue
                 # take care to relation of cardinality '?1', as all eids will