# HG changeset patch # User Paul Boddie # Date 1443546121 -7200 # Node ID 7cbf127b2711e7113a6246ca36f6dc8d08a6fd5e # Parent 6e70db2b1d38b1a0f3ba063a6c094ac97820a559 Added a CN (common name) setting and support for user attributes. diff -r 6e70db2b1d38 -r 7cbf127b2711 docs/preferences.txt --- a/docs/preferences.txt Tue Sep 29 14:04:57 2015 +0200 +++ b/docs/preferences.txt Tue Sep 29 19:02:01 2015 +0200 @@ -1,6 +1,15 @@ Preferences and Settings ======================== +CN +-- + +Default: (none) +Alternatives: (see below) + +The common name of the user, employed in iCalendar objects and user +interfaces. + LANG ---- diff -r 6e70db2b1d38 -r 7cbf127b2711 imiptools/client.py --- a/imiptools/client.py Tue Sep 29 14:04:57 2015 +0200 +++ b/imiptools/client.py Tue Sep 29 19:02:01 2015 +0200 @@ -74,6 +74,10 @@ self.preferences = Preferences(self.user, self.preferences_dir) return self.preferences + def get_user_attributes(self): + prefs = self.get_preferences() + return prefs and prefs.get_all(["CN"]) or {} + def get_tzid(self): prefs = self.get_preferences() return prefs and prefs.get("TZID") or get_default_timezone() diff -r 6e70db2b1d38 -r 7cbf127b2711 imiptools/profile.py --- a/imiptools/profile.py Tue Sep 29 14:04:57 2015 +0200 +++ b/imiptools/profile.py Tue Sep 29 19:02:01 2015 +0200 @@ -44,6 +44,30 @@ except KeyError: return default + def get_all(self, names): + + """ + Return a dictionary containing values for entries having the given + 'names'. Absent entries for names are omitted without error. + """ + + d = {} + for name in names: + value = self.get(name) + if value is not None: + d[name] = value + return d + + def has_key(self, name): + + "Return whether an entry exists for 'name'." + + try: + self[name] + return True + except KeyError: + return False + def __getitem__(self, name): "Return the value for 'name', raising a KeyError if absent."