summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorChristoph Erhardt <kolab@sicherha.de>2021-06-05 14:44:05 +0200
committerChristoph Erhardt <kolab@sicherha.de>2022-01-10 20:51:35 +0100
commitcfdb3e4f7f150bd01b73622662766459f390f10d (patch)
tree6e5d710d6b49ac2f0324d91faae1d325cd6d75b4 /pykolab
parent9a5f92139d3fbe7fa1945d38198a9cdc74831ac5 (diff)
downloadpykolab-cfdb3e4f7f150bd01b73622662766459f390f10d.tar.gz
[Python 3] Use .items() instead of .iteritems()
Summary: .iteritems() was dropped in Python 3.0. This commit may have a negative performance impact on Python 2 since .items() returns a copy of the dictionary's item list. In Python 3, .items() returns a view object, so no performance drop should be noticeable there. Reviewers: machniak, mollekopf Reviewed By: mollekopf Subscribers: mollekopf Differential Revision: https://git.kolab.org/D3244
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/cli/cmd_user_info.py2
-rw-r--r--pykolab/wap_client/__init__.py8
-rw-r--r--pykolab/xml/attendee.py4
-rw-r--r--pykolab/xml/contact.py16
-rw-r--r--pykolab/xml/contact_reference.py2
-rw-r--r--pykolab/xml/event.py14
-rw-r--r--pykolab/xml/note.py4
-rw-r--r--pykolab/xml/recurrence_rule.py4
-rw-r--r--pykolab/xml/utils.py2
9 files changed, 28 insertions, 28 deletions
diff --git a/pykolab/cli/cmd_user_info.py b/pykolab/cli/cmd_user_info.py
index e8a5766..beaeb40 100644
--- a/pykolab/cli/cmd_user_info.py
+++ b/pykolab/cli/cmd_user_info.py
@@ -55,7 +55,7 @@ def execute(*args, **kw):
unic_attrs = ['displayname', 'givenname', 'cn', 'sn', 'ou', 'entrydn']
- for (k,v) in user_info.iteritems():
+ for (k,v) in user_info.items():
if k in unic_attrs:
print("%s: %s" % (k,v))
else:
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index bfb2e2c..f3cf1d7 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -337,7 +337,7 @@ def group_form_value_generate_mail(params=None):
def group_find(params=None):
post = { 'search': { 'params': {} } }
- for (k,v) in params.iteritems():
+ for (k,v) in params.items():
post['search']['params'][k] = { 'value': v, 'type': 'exact' }
return request('POST', 'group.find', post=json.dumps(post))
@@ -371,7 +371,7 @@ def ou_edit(params={}):
def ou_find(params=None):
post = { 'search': { 'params': {} } }
- for (k,v) in params.iteritems():
+ for (k,v) in params.items():
post['search']['params'][k] = { 'value': v, 'type': 'exact' }
return request('POST', 'ou.find', post=json.dumps(post))
@@ -459,7 +459,7 @@ def resource_delete(params=None):
def resource_find(params=None):
post = { 'search': { 'params': {} } }
- for (k,v) in params.iteritems():
+ for (k,v) in params.items():
post['search']['params'][k] = { 'value': v, 'type': 'exact' }
return request('POST', 'resource.find', post=json.dumps(post))
@@ -615,7 +615,7 @@ def user_find(attribs=None):
else:
post = { 'search': { 'params': {} } }
- for (k,v) in attribs.iteritems():
+ for (k,v) in attribs.items():
post['search']['params'][k] = { 'value': v, 'type': 'exact' }
post = json.dumps(post)
diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py
index f82f96e..050a1d5 100644
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -210,7 +210,7 @@ class Attendee(kolabformat.Attendee):
return self.rsvp()
def _translate_value(self, val, map):
- name_map = dict([(v, k) for (k, v) in map.iteritems()])
+ name_map = dict([(v, k) for (k, v) in map.items()])
return name_map[val] if val in name_map else 'UNKNOWN'
def set_cutype(self, cutype):
@@ -248,7 +248,7 @@ class Attendee(kolabformat.Attendee):
data = self.contactreference.to_dict()
data.pop('type', None)
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
args = {}
if hasattr(self, getter):
diff --git a/pykolab/xml/contact.py b/pykolab/xml/contact.py
index f5053e6..7b0a2a7 100644
--- a/pykolab/xml/contact.py
+++ b/pykolab/xml/contact.py
@@ -160,7 +160,7 @@ class Contact(kolabformat.Contact):
return _gender
def _translate_value(self, val, map):
- name_map = dict([(v, k) for (k, v) in map.iteritems()])
+ name_map = dict([(v, k) for (k, v) in map.items()])
return name_map[val] if val in name_map else 'UNKNOWN'
def to_dict(self):
@@ -169,7 +169,7 @@ class Contact(kolabformat.Contact):
data = self._names2dict(self.nameComponents())
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
if hasattr(self, getter):
val = getattr(self, getter)()
@@ -223,7 +223,7 @@ class Contact(kolabformat.Contact):
data = dict()
- for p, getter in names_map.iteritems():
+ for p, getter in names_map.items():
val = None
if hasattr(namecomp, getter):
val = getattr(namecomp, getter)()
@@ -243,7 +243,7 @@ class Contact(kolabformat.Contact):
data = dict()
- for p, getter in props_map.iteritems():
+ for p, getter in props_map.items():
val = None
if hasattr(affiliation, getter):
val = getattr(affiliation, getter)()
@@ -269,7 +269,7 @@ class Contact(kolabformat.Contact):
'code': 'code',
'country': 'country',
}
- addresstype_map = dict([(v, k) for (k, v) in self.addresstype_map.iteritems()])
+ addresstype_map = dict([(v, k) for (k, v) in self.addresstype_map.items()])
data = dict()
@@ -279,7 +279,7 @@ class Contact(kolabformat.Contact):
if adrtype is not None:
data['type'] = adrtype
- for p, getter in props_map.iteritems():
+ for p, getter in props_map.items():
val = None
if hasattr(adr, getter):
val = getattr(adr, getter)()
@@ -293,7 +293,7 @@ class Contact(kolabformat.Contact):
def _relateds2dict(self, relateds, aslist=True):
data = dict()
- related_map = dict([(v, k) for (k, v) in self.related_map.iteritems()])
+ related_map = dict([(v, k) for (k, v) in self.related_map.items()])
for rel in relateds:
reltype = related_map.get(rel.relationTypes(), None)
val = rel.uri() if rel.type() == kolabformat.Related.Uid else rel.text()
@@ -308,7 +308,7 @@ class Contact(kolabformat.Contact):
return data
def _struct2dict(self, struct, propname, map):
- type_map = dict([(v, k) for (k, v) in map.iteritems()])
+ type_map = dict([(v, k) for (k, v) in map.items()])
result = dict()
if hasattr(struct, 'types'):
diff --git a/pykolab/xml/contact_reference.py b/pykolab/xml/contact_reference.py
index 42d9919..6b40817 100644
--- a/pykolab/xml/contact_reference.py
+++ b/pykolab/xml/contact_reference.py
@@ -44,7 +44,7 @@ class ContactReference(kolabformat.ContactReference):
def to_dict(self):
data = dict()
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
if hasattr(self, getter):
val = getattr(self, getter)()
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index e957a19..a80fe20 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -554,28 +554,28 @@ class Event(object):
if rsvp in attendee.rsvp_map:
_rsvp = rsvp
elif rsvp in attendee.rsvp_map.values():
- _rsvp = [k for k, v in attendee.rsvp_map.iteritems() if v == rsvp][0]
+ _rsvp = [k for k, v in attendee.rsvp_map.items() if v == rsvp][0]
else:
_rsvp = None
if role in attendee.role_map:
_role = role
elif role in attendee.role_map.values():
- _role = [k for k, v in attendee.role_map.iteritems() if v == role][0]
+ _role = [k for k, v in attendee.role_map.items() if v == role][0]
else:
_role = None
if partstat in attendee.participant_status_map:
_partstat = partstat
elif partstat in attendee.participant_status_map.values():
- _partstat = [k for k, v in attendee.participant_status_map.iteritems() if v == partstat][0]
+ _partstat = [k for k, v in attendee.participant_status_map.items() if v == partstat][0]
else:
_partstat = None
if cutype in attendee.cutype_map:
_cutype = cutype
elif cutype in attendee.cutype_map.values():
- _cutype = [k for k, v in attendee.cutype_map.iteritems() if v == cutype][0]
+ _cutype = [k for k, v in attendee.cutype_map.items() if v == cutype][0]
else:
_cutype = None
@@ -611,7 +611,7 @@ class Event(object):
if attendee.get_participant_status() in attendee.participant_status_map:
return attendee.get_participant_status()
elif attendee.get_participant_status() in attendee.participant_status_map.values():
- return [k for k, v in attendee.participant_status_map.iteritems() if v == attendee.get_participant_status()][0]
+ return [k for k, v in attendee.participant_status_map.items() if v == attendee.get_participant_status()][0]
else:
raise ValueError(_("Invalid participant status"))
@@ -1116,7 +1116,7 @@ class Event(object):
def to_dict(self):
data = dict()
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
if hasattr(self, getter):
val = getattr(self, getter)()
@@ -1176,7 +1176,7 @@ class Event(object):
return ret
def _translate_value(self, val, map):
- name_map = dict([(v, k) for (k, v) in map.iteritems()])
+ name_map = dict([(v, k) for (k, v) in map.items()])
return name_map[val] if val in name_map else 'UNKNOWN'
def to_message(self, creator=None):
diff --git a/pykolab/xml/note.py b/pykolab/xml/note.py
index 735a098..936315b 100644
--- a/pykolab/xml/note.py
+++ b/pykolab/xml/note.py
@@ -99,7 +99,7 @@ class Note(kolabformat.Note):
self.setCategories(_categories)
def _translate_value(self, val, map):
- name_map = dict([(v, k) for (k, v) in map.iteritems()])
+ name_map = dict([(v, k) for (k, v) in map.items()])
return name_map[val] if val in name_map else 'UNKNOWN'
def to_dict(self):
@@ -108,7 +108,7 @@ class Note(kolabformat.Note):
data = dict()
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
if hasattr(self, getter):
val = getattr(self, getter)()
diff --git a/pykolab/xml/recurrence_rule.py b/pykolab/xml/recurrence_rule.py
index 52058ca..cbe164d 100644
--- a/pykolab/xml/recurrence_rule.py
+++ b/pykolab/xml/recurrence_rule.py
@@ -181,7 +181,7 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
getattr(self, setter)(val)
def _translate_value(self, val, map):
- name_map = dict([(v, k) for (k, v) in map.iteritems()])
+ name_map = dict([(v, k) for (k, v) in map.items()])
return name_map[val] if val in name_map else 'UNKNOWN'
def to_ical(self):
@@ -194,7 +194,7 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
data = dict()
- for p, getter in self.properties_map.iteritems():
+ for p, getter in self.properties_map.items():
val = None
args = {}
if hasattr(self, getter):
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index 3e3fc9e..821295f 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -338,7 +338,7 @@ def compare_values(aa, bb, partial=False):
# accept partial match
if partial:
- for k,v in aa.iteritems():
+ for k,v in aa.items():
if k in bb and bb[k] == v:
return True