Projects
Kolab:Winterfell
pykolab
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 91
View file
pykolab.spec
Changed
@@ -42,8 +42,6 @@ Source0: pykolab-%{version}.tar.gz Source1: pykolab.logrotate -Patch0: 0001-Python-3-Use-0o-prefix-for-octal-numbers.patch - BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch @@ -233,7 +231,6 @@ %prep %setup -q -%patch0 -p1 %build autoreconf -v || automake --add-missing && autoreconf -v
View file
0001-Python-3-Use-0o-prefix-for-octal-numbers.patch
Deleted
@@ -1,121 +0,0 @@ -From 7750671314e6da19f65aaa95bb1095963fdc175a Mon Sep 17 00:00:00 2001 -Message-Id: <7750671314e6da19f65aaa95bb1095963fdc175a.1643911242.git.kolab@sicherha.de> -From: Christoph Erhardt <kolab@sicherha.de> -Date: Fri, 4 Jun 2021 16:16:55 +0200 -Subject: [PATCH] [Python 3] Use 0o prefix for octal numbers - -Summary: -The new 0o prefix was introduced in Python 2.6; the old 0 prefix was -deprecated in Python 3.0. - -Reviewers: machniak, mollekopf - -Reviewed By: mollekopf - -Subscribers: mollekopf - -Differential Revision: https://git.kolab.org/D3226 ---- - pykolab/auth/ldap/syncrepl.py | 2 +- - pykolab/logger.py | 2 +- - pykolab/setup/setup_mta.py | 2 +- - pykolab/setup/setup_mysql.py | 2 +- - pykolab/setup/setup_roundcube.py | 2 +- - pykolab/setup/setup_syncroton.py | 2 +- - saslauthd/__init__.py | 2 +- - 7 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/pykolab/auth/ldap/syncrepl.py b/pykolab/auth/ldap/syncrepl.py -index 03ab5ae..72f5f37 100644 ---- a/pykolab/auth/ldap/syncrepl.py -+++ b/pykolab/auth/ldap/syncrepl.py -@@ -22,7 +22,7 @@ class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer): - del kwargs['callback'] - - ldap.ldapobject.LDAPObject.__init__(self, *args, **kwargs) -- self.__db = anydbm.open(filename, 'c', 0640) -+ self.__db = anydbm.open(filename, 'c', 0o640) - self.__presentUUIDs = {} - - def syncrepl_set_cookie(self,cookie): -diff --git a/pykolab/logger.py b/pykolab/logger.py -index c2237cb..8e9c9b6 100644 ---- a/pykolab/logger.py -+++ b/pykolab/logger.py -@@ -213,7 +213,7 @@ class Logger(logging.Logger): - group_gid - ) - -- os.chmod(self.logfile, '0660') -+ os.chmod(self.logfile, 0o660) - - except Exception as errmsg: - self.error( -diff --git a/pykolab/setup/setup_mta.py b/pykolab/setup/setup_mta.py -index c3c4154..903acd7 100644 ---- a/pykolab/setup/setup_mta.py -+++ b/pykolab/setup/setup_mta.py -@@ -243,7 +243,7 @@ result_format = "shared+%%s" - ) - - if not os.path.isdir('/etc/postfix/ldap'): -- os.mkdir('/etc/postfix/ldap/', 0770) -+ os.mkdir('/etc/postfix/ldap/', 0o770) - - for filename in files.keys(): - fp = open(filename, 'w') -diff --git a/pykolab/setup/setup_mysql.py b/pykolab/setup/setup_mysql.py -index 08b7b7c..73c2245 100644 ---- a/pykolab/setup/setup_mysql.py -+++ b/pykolab/setup/setup_mysql.py -@@ -256,7 +256,7 @@ host=%s - - - fp = open('/tmp/kolab-setup-my.cnf', 'w') -- os.chmod('/tmp/kolab-setup-my.cnf', 0600) -+ os.chmod('/tmp/kolab-setup-my.cnf', 0o600) - fp.write(data) - fp.close() - -diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py -index 47ac8fc..869533f 100644 ---- a/pykolab/setup/setup_roundcube.py -+++ b/pykolab/setup/setup_roundcube.py -@@ -259,7 +259,7 @@ host=%s - """ % (mysql_root_password, conf.mysqlhost) - - fp = open('/tmp/kolab-setup-my.cnf', 'w') -- os.chmod('/tmp/kolab-setup-my.cnf', 0600) -+ os.chmod('/tmp/kolab-setup-my.cnf', 0o600) - fp.write(data) - fp.close() - -diff --git a/pykolab/setup/setup_syncroton.py b/pykolab/setup/setup_syncroton.py -index c7c03ce..1cccd0e 100644 ---- a/pykolab/setup/setup_syncroton.py -+++ b/pykolab/setup/setup_syncroton.py -@@ -109,7 +109,7 @@ host=%s - """ % (mysql_root_password, conf.mysqlhost) - - fp = open('/tmp/kolab-setup-my.cnf', 'w') -- os.chmod('/tmp/kolab-setup-my.cnf', 0600) -+ os.chmod('/tmp/kolab-setup-my.cnf', 0o600) - fp.write(data) - fp.close() - -diff --git a/saslauthd/__init__.py b/saslauthd/__init__.py -index 30e8189..e11296b 100644 ---- a/saslauthd/__init__.py -+++ b/saslauthd/__init__.py -@@ -204,7 +204,7 @@ class SASLAuthDaemon(object): - pass - - s.bind(conf.socketfile) -- os.chmod(conf.socketfile, 0777) -+ os.chmod(conf.socketfile, 0o777) - - s.listen(5) - --- -2.34.1 -
View file
debian.series
Changed
@@ -1,2 +1,1 @@ cyrus-imapd.conf-cert-paths.patch -p1 -0001-Python-3-Use-0o-prefix-for-octal-numbers.patch -p1
View file
pykolab-0.8.21.tar.gz/bin/kolab_smtp_access_policy.py
Changed
@@ -184,7 +184,7 @@ http://www.postfix.org/SMTPD_POLICY_README.html """ - for key in policy_request.keys(): + for key in policy_request: # Normalize email addresses (they may contain recipient delimiters) if key in self.email_address_keys: @@ -333,7 +333,7 @@ # mapping the rule onto a key in "special_rule_values", a # dictionary with the corresponding value set to a function to # execute. - if rule in special_rule_values.keys(): + if rule in special_rule_values: special_rules = special_rule_values[rule]() if rule.startswith("-"): rules['deny'].extend(special_rules) @@ -1599,7 +1599,7 @@ global auth, mydomains if mydomains is not None: - return domain in mydomains.keys() + return domain in mydomains auth.connect()
View file
pykolab-0.8.21.tar.gz/conf.py
Changed
@@ -22,6 +22,8 @@ Kolab configuration utility. """ +from __future__ import print_function + import logging import os import sys @@ -32,9 +34,9 @@ try: import pykolab.logger -except ImportError, e: - print >> sys.stderr, _("Cannot load pykolab/logger.py:") - print >> sys.stderr, "%s" % e +except ImportError as e: + print(_("Cannot load pykolab/logger.py:"), file=sys.stderr) + print("%s" % e, file=sys.stderr) sys.exit(1) import pykolab
View file
pykolab-0.8.21.tar.gz/cyruslib.py
Changed
@@ -18,9 +18,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # -# Requires python >= 2.3 +# Requires python >= 2.6 # +from __future__ import print_function + __version__ = '0.8.5' __all__ = [ 'CYRUS' ] __doc__ = """Cyrus admin wrapper @@ -35,8 +37,8 @@ import imaplib import re from binascii import b2a_base64 -except ImportError, e: - print e +except ImportError as e: + print(e) exit(1) Commands = { @@ -342,7 +344,7 @@ def __verbose(self, msg): if self.VERBOSE: - print >> self.LOGFD, msg + print(msg, file=self.LOGFD) def __doexception(self, function, msg=None, *args): if msg is None: @@ -382,7 +384,7 @@ res, msg = wrapped(*args) if ok(res): return res, msg - except Exception, info: + except Exception as info: error = str(info).split(':').pop().strip() if error.upper().startswith('BAD'): error = error.split('BAD', 1).pop().strip() @@ -413,7 +415,7 @@ self.AUTH = True self.id() admin = self.m.isadmin() - except Exception, info: + except Exception as info: self.AUTH = False error = str(info).split(':').pop().strip() self.__doexception("LOGIN", error) @@ -446,7 +448,7 @@ def logout(self): try: res, msg = self.m.logout() - except Exception, info: + except Exception as info: error = str(info).split(':').pop().strip() self.__doexception("LOGOUT", error) self.AUTH = False @@ -575,7 +577,7 @@ try: userid = self.encode(aclList[i]) rights = aclList[i + 1] - except Exception, info: + except Exception as info: self.__verbose( '[GETACL %s] BAD: %s' % (mailbox, info.args[0]) ) raise self.__doraise("GETACL") self.__verbose( '[GETACL %s] %s %s' % (mailbox, userid, rights) ) @@ -635,7 +637,7 @@ self.__prepare('SETQUOTA', mailbox) try: limit = int(limit) - except ValueError, e: + except ValueError: self.__verbose( '[SETQUOTA %s] BAD: %s %s' % (mailbox, self.ERROR.get("SETQUOTA")[1], limit) ) raise self.__doraise("SETQUOTA") res, msg = self.__docommand("setquota", self.decode(mailbox), limit) @@ -687,21 +689,21 @@ key = annotation.split('"')[3].replace('"','').replace("'","").strip() _annot = annotation.split('(')[1].split(')')[0].strip() - if not ann.has_key(folder): + if folder not in ann: ann[folder] = {} try: value_priv = _annot[(_annot.index('"value.priv"')+len('"value.priv"')):_annot.index('"size.priv"')].strip() - except ValueError, errmsg: + except ValueError: value_priv = None try: size_priv = _annot[(_annot.index('"size.priv"')+len('"size.priv"')):].strip().split('"')[1].strip() try: value_priv = value_priv[value_priv.index('{%s}' % (size_priv))+len('{%s}' % (size_priv)):].strip() - except Exception, errmsg: + except Exception: pass - except Exception, errmsg: + except Exception: pass if value_priv in empty_values: @@ -728,16 +730,16 @@ try: value_shared = _annot[(_annot.index('"value.shared"')+len('"value.shared"')):_annot.index('"size.shared"')].strip() - except ValueError, errmsg: + except ValueError: value_shared = None try: size_shared = _annot[(_annot.index('"size.shared"')+len('"size.shared"')):].strip().split('"')[1].strip() try: value_shared = value_shared[value_shared.index('{%s}' % (size_shared))+len('{%s}' % (size_shared)):].strip() - except Exception, errmsg: + except Exception: pass - except Exception, errmsg: + except Exception: pass if value_shared in empty_values:
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/checkextensions.py
Changed
@@ -18,7 +18,7 @@ for mod in unknown: for e in extensions: (mods, vars), liba = edict[e] - if not mods.has_key(mod): + if mod not in mods: continue modules.append(mod) if liba: @@ -28,7 +28,7 @@ if liba in files: break files.append(liba) - for m in mods.keys(): + for m in mods: files = files + select(e, mods, vars, m, 1) break @@ -84,7 +84,7 @@ break var = str[i:j] i = j+1 - if vars.has_key(var): + if var in vars: str = str[:k] + vars[var] + str[i:] i = k return str
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/checkextensions_win32.py
Changed
@@ -131,7 +131,7 @@ dsp_path, dsp_name = os.path.split(dsp) try: lines = open(dsp, "r").readlines() - except IOError, msg: + except IOError as msg: sys.stderr.write("%s: %s\n" % (dsp, msg)) return None for line in lines:
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/freeze.py
Changed
@@ -145,7 +145,7 @@ if sys.argv[pos] == '-i': try: options = open(sys.argv[pos+1]).read().split() - except IOError, why: + except IOError as why: usage("File name '%s' specified with the -i option " "can not be read - %s" % (sys.argv[pos+1], why) ) # Replace the '-i' and the filename with the read params. @@ -156,13 +156,13 @@ # Now parse the command line with the extras inserted. try: opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:b:qs:wX:x:l:') - except getopt.error, msg: + except getopt.error as msg: usage('getopt error: ' + str(msg)) # process option arguments for o, a in opts: if o == '-h': - print __doc__ + print(__doc__) return if o == '-b': binlib = a @@ -224,7 +224,7 @@ if win: extensions_c = 'frozen_extensions.c' if ishome: - print "(Using Python source directory)" + print("(Using Python source directory)") binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_h_dir = exec_prefix @@ -316,8 +316,8 @@ if odir and not os.path.isdir(odir): try: os.mkdir(odir) - print "Created output directory", odir - except os.error, msg: + print("Created output directory", odir) + except os.error as msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) base = '' if odir: @@ -339,7 +339,7 @@ try: custom_entry_point, python_entry_is_main = \ winmakemakefile.get_custom_entry_point(subsystem) - except ValueError, why: + except ValueError as why: usage(why) @@ -377,7 +377,7 @@ if debug > 0: mf.report() - print + print() dict = mf.modules if error_if_any_missing: @@ -467,7 +467,7 @@ somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) - for key in makevars.keys(): + for key in makevars: somevars[key] = makevars[key] somevars['CFLAGS'] = ' '.join(cflags) # override @@ -485,18 +485,18 @@ # Done! if odir: - print 'Now run "make" in', odir, - print 'to build the target:', base_target + print('Now run "make" in', odir, end=' ') + print('to build the target:', base_target) else: - print 'Now run "make" to build the target:', base_target + print('Now run "make" to build the target:', base_target) # Print usage message and exit def usage(msg): sys.stdout = sys.stderr - print "Error:", msg - print "Use ``%s -h'' for help" % sys.argv[0] + print("Error:", msg) + print("Use ``%s -h'' for help" % sys.argv[0]) sys.exit(2)
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/hello.py
Changed
@@ -1,1 +1,1 @@ -print 'Hello world...' +print('Hello world...')
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/makeconfig.py
Changed
@@ -40,8 +40,8 @@ def test(): import sys if not sys.argv[3:]: - print 'usage: python makeconfig.py config.c.in outputfile', - print 'modulename ...' + print('usage: python makeconfig.py config.c.in outputfile', end=' ') + print('modulename ...') sys.exit(2) if sys.argv[1] == '-': infp = sys.stdin
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/makefreeze.py
Changed
@@ -43,7 +43,7 @@ outfp = bkfile.open(base + file, 'w') files.append(file) if debug: - print "freezing", mod, "..." + print("freezing", mod, "...") str = marshal.dumps(m.__code__) size = len(str) if m.__path__: @@ -53,7 +53,7 @@ writecode(outfp, mangled, str) outfp.close() if debug: - print "generating table of frozen modules" + print("generating table of frozen modules") outfp = bkfile.open(base + 'frozen.c', 'w') for mod, mangled, size in done: outfp.write('extern unsigned char M_%s[];\n' % mangled)
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/parsesetup.py
Changed
@@ -84,29 +84,29 @@ import sys import os if not sys.argv[1:]: - print 'usage: python parsesetup.py Makefile*|Setup* ...' + print('usage: python parsesetup.py Makefile*|Setup* ...') sys.exit(2) for arg in sys.argv[1:]: base = os.path.basename(arg) if base[:8] == 'Makefile': - print 'Make style parsing:', arg + print('Make style parsing:', arg) v = getmakevars(arg) prdict(v) elif base[:5] == 'Setup': - print 'Setup style parsing:', arg + print('Setup style parsing:', arg) m, v = getsetupinfo(arg) prdict(m) prdict(v) else: - print arg, 'is neither a Makefile nor a Setup file' - print '(name must begin with "Makefile" or "Setup")' + print(arg, 'is neither a Makefile nor a Setup file') + print('(name must begin with "Makefile" or "Setup")') def prdict(d): keys = d.keys() keys.sort() for key in keys: value = d[key] - print "%-15s" % key, str(value) + print("%-15s" % key, str(value)) if __name__ == '__main__': test()
View file
pykolab-0.8.21.tar.gz/ext/python/Tools/freeze/winmakemakefile.py
Changed
@@ -39,7 +39,7 @@ try: return subsystem_details[subsystem][:2] except KeyError: - raise ValueError, "The subsystem %s is not known" % subsystem + raise ValueError("The subsystem %s is not known" % subsystem) def makemakefile(outfp, vars, files, target): @@ -52,29 +52,29 @@ def realwork(vars, moddefns, target): version_suffix = "%r%r" % sys.version_info[:2] - print "# Makefile for Microsoft Visual C++ generated by freeze.py script" - print - print 'target = %s' % target - print 'pythonhome = %s' % vars['prefix'] - print - print 'DEBUG=0 # Set to 1 to use the _d versions of Python.' - print '!IF $(DEBUG)' - print 'debug_suffix=_d' - print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG' - print 'l_debug=/DEBUG' - print 'temp_dir=Build\\Debug' - print '!ELSE' - print 'debug_suffix=' - print 'c_debug=/Ox' - print 'l_debug=' - print 'temp_dir=Build\\Release' - print '!ENDIF' - print - - print '# The following line assumes you have built Python using the standard instructions' - print '# Otherwise fix the following line to point to the library.' - print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix - print + print("# Makefile for Microsoft Visual C++ generated by freeze.py script") + print() + print('target = %s' % target) + print('pythonhome = %s' % vars['prefix']) + print() + print('DEBUG=0 # Set to 1 to use the _d versions of Python.') + print('!IF $(DEBUG)') + print('debug_suffix=_d') + print('c_debug=/Zi /Od /DDEBUG /D_DEBUG') + print('l_debug=/DEBUG') + print('temp_dir=Build\\Debug') + print('!ELSE') + print('debug_suffix=') + print('c_debug=/Ox') + print('l_debug=') + print('temp_dir=Build\\Release') + print('!ENDIF') + print() + + print('# The following line assumes you have built Python using the standard instructions') + print('# Otherwise fix the following line to point to the library.') + print('pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix) + print() # We only ever write one "entry point" symbol - either # "main" or "WinMain". Therefore, there is no need to @@ -88,59 +88,59 @@ target_ext = ".dll" - print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix - print "cdl = /MD" - print - print "all: $(target)$(debug_suffix)%s" % (target_ext) - print + print("# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix) + print("cdl = /MD") + print() + print("all: $(target)$(debug_suffix)%s" % (target_ext)) + print() - print '$(temp_dir):' - print ' if not exist $(temp_dir)\. mkdir $(temp_dir)' - print + print('$(temp_dir):') + print(' if not exist $(temp_dir)\. mkdir $(temp_dir)') + print() objects = [] libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"] for moddefn in moddefns: - print "# Module", moddefn.name + print("# Module", moddefn.name) for file in moddefn.sourceFiles: base = os.path.basename(file) base, ext = os.path.splitext(base) objects.append(base + ".obj") - print '$(temp_dir)\%s.obj: "%s"' % (base, file) - print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", - print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\' - print "\t\t$(cflags) $(cdebug) $(cinclude) \\" + print('$(temp_dir)\%s.obj: "%s"' % (base, file)) + print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ') + print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\') + print("\t\t$(cflags) $(cdebug) $(cinclude) \\") extra = moddefn.GetCompilerOptions() if extra: - print "\t\t%s \\" % (' '.join(extra),) - print '\t\t"%s"' % file - print + print("\t\t%s \\" % (' '.join(extra),)) + print('\t\t"%s"' % file) + print() # Add .lib files this module needs for modlib in moddefn.GetLinkerLibs(): if modlib not in libs: libs.append(modlib) - print "ADDN_LINK_FILES=", - for addn in vars['addn_link']: print '"%s"' % (addn), - print ; print - - print "OBJS=", - for obj in objects: print '"$(temp_dir)\%s"' % (obj), - print ; print - - print "LIBS=", - for lib in libs: print '"%s"' % (lib), - print ; print - - print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext) - print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), - print "\t$(OBJS) \\" - print "\t$(LIBS) \\" - print "\t$(ADDN_LINK_FILES) \\" - print "\t$(pythonlib) $(lcustom) $(l_debug)\\" - print "\t$(resources)" - print - print "clean:" - print "\t-rm -f *.obj" - print "\t-rm -f $(target).exe" + print("ADDN_LINK_FILES=", end=' ') + for addn in vars['addn_link']: print('"%s"' % (addn), end=' ') + print() ; print() + + print("OBJS=", end=' ') + for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ') + print() ; print() + + print("LIBS=", end=' ') + for lib in libs: print('"%s"' % (lib), end=' ') + print() ; print() + + print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)) + print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ') + print("\t$(OBJS) \\") + print("\t$(LIBS) \\") + print("\t$(ADDN_LINK_FILES) \\") + print("\t$(pythonlib) $(lcustom) $(l_debug)\\") + print("\t$(resources)") + print() + print("clean:") + print("\t-rm -f *.obj") + print("\t-rm -f $(target).exe")
View file
pykolab-0.8.21.tar.gz/kolab-cli.py
Changed
@@ -18,6 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import logging import os import sys @@ -30,9 +32,9 @@ try: import pykolab.logger -except ImportError, e: - print >> sys.stderr, _("Cannot load pykolab/logger.py:") - print >> sys.stderr, "%s" % e +except ImportError as e: + print(_("Cannot load pykolab/logger.py:"), file=sys.stderr) + print("%s" % e, file=sys.stderr) sys.exit(1) if __name__ == "__main__":
View file
pykolab-0.8.21.tar.gz/kolabd/__init__.py
Changed
@@ -316,7 +316,7 @@ for domain in all_domains: log.debug(_l("Checking for domain %s") % (domain), level=8) - if domain in domain_auth.keys() and domain in primary_domains: + if domain in domain_auth and domain in primary_domains: if not domain_auth[domain].is_alive(): log.debug(_l("Domain %s isn't alive anymore.") % (domain), level=8) domain_auth[domain].terminate() @@ -325,7 +325,7 @@ log.debug(_l("Domain %s already there and alive.") % (domain), level=8) continue - elif domain in domain_auth.keys(): + elif domain in domain_auth: log.debug(_l("Domain %s should not exist any longer.") % (domain), level=8) removed_domains.append(domain) else:
View file
pykolab-0.8.21.tar.gz/pykolab/auth/ldap/__init__.py
Changed
@@ -820,7 +820,7 @@ List alias domain name spaces for the current domain name space. """ if self.domains is not None: - return [s for s in self.domains.keys() if s not in self.domains.values()] + return [s for s in self.domains if s not in self.domains.values()] return [] @@ -923,7 +923,7 @@ attributes = self.get_entry_attributes(entry_dn, want_attrs) - for attribute in attributes.keys(): + for attribute in attributes: entry[attribute] = attributes[attribute] if 'preferredlanguage' not in entry: @@ -1259,7 +1259,7 @@ attrs = {} - for attribute in attributes.keys(): + for attribute in attributes: attrs[attribute.lower()] = attributes[attribute] modlist = [] @@ -2288,7 +2288,7 @@ entry_changes[result_attribute] ) - for key in entry_changes.keys(): + for key in entry_changes: entry[key] = entry_changes[key] self.set_entry_attribute(entry, key, entry[key]) @@ -2785,7 +2785,7 @@ entry = {'dn': entry_dn} entry_attrs = utils.normalize(entry_attrs) - for attr in entry_attrs.keys(): + for attr in entry_attrs: entry[attr.lower()] = entry_attrs[attr] # Ignore nstombstone objects @@ -2811,7 +2811,7 @@ # # log.debug(_l("Recipient Addresses: %r") % (rcpt_addrs), level=8) # -# for key in rcpt_addrs.keys(): +# for key in rcpt_addrs: # entry[key] = rcpt_addrs[key] # # cache.get_entry(self.domain, entry) @@ -3140,7 +3140,7 @@ ) if len(self.ldap.supported_controls) < 1: - for control_num in SUPPORTED_LDAP_CONTROLS.keys(): + for control_num in SUPPORTED_LDAP_CONTROLS: log.debug( _l("Checking for support for %s on %s") % ( SUPPORTED_LDAP_CONTROLS[control_num]['desc'], @@ -3157,7 +3157,7 @@ for (_result, _supported_controls) in _search: supported_controls = _supported_controls.values()[0] - for control_num in SUPPORTED_LDAP_CONTROLS.keys(): + for control_num in SUPPORTED_LDAP_CONTROLS: if SUPPORTED_LDAP_CONTROLS[control_num]['oid'] in \ supported_controls:
View file
pykolab-0.8.21.tar.gz/pykolab/auth/ldap/auth_cache.py
Changed
@@ -17,6 +17,7 @@ # import datetime +import os import sqlalchemy @@ -84,6 +85,11 @@ db = init_db() + if db is None: + return + + purge_entries() + try: db.query(Entry).filter_by(key=key).delete() except sqlalchemy.exc.OperationalError: @@ -102,6 +108,9 @@ db = init_db() + if db is None: + return None + try: _entries = db.query(Entry).filter_by(key=key).all() except sqlalchemy.exc.OperationalError: @@ -111,18 +120,32 @@ finally: _entries = db.query(Entry).filter_by(key=key).all() - if len(_entries) != 1: + __entries = [] + + for __entry in _entries: + if __entry.last_change <= datetime.datetime.now() - datetime.timedelta(0, 7200): + continue + + __entries.append(__entry) + + if len(__entries) != 1: return None - log.debug("Entry found: %r" % (_entries[0].__dict__)) - log.debug("Returning: %r" % (_entries[0].value)) + log.debug("Entry found: %r" % (__entries[0].__dict__)) + log.debug("Returning: %r" % (__entries[0].value)) - return _entries[0].value.encode('utf-8', 'latin1') + return __entries[0].value.encode('utf-8', 'latin1') def set_entry(key, value): + # pylint: disable=global-statement + global db + db = init_db() + if db is None: + return + try: _entries = db.query(Entry).filter_by(key=key).all() except sqlalchemy.exc.OperationalError: @@ -147,12 +170,18 @@ db.commit() -def purge_entries(db): - db.query(Entry).filter( - Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(1)) - ).delete() +def purge_entries(): + # pylint: disable=global-statement + global db - db.commit() + try: + db.query(Entry).filter( + Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(0, 7200)) + ).delete() + + db.commit() + except Exception: + return def init_db(reinit=False): @@ -167,11 +196,13 @@ db_uri = conf.get('ldap', 'auth_cache_uri') + if db_uri == "null": + return None + if db_uri is None: db_uri = 'sqlite:///%s/auth_cache.db' % (KOLAB_LIB_PATH) if reinit: - import os if os.path.isfile('%s/auth_cache.db' % (KOLAB_LIB_PATH)): os.unlink('%s/auth_cache.db' % (KOLAB_LIB_PATH)) @@ -181,6 +212,5 @@ Session = sessionmaker(bind=engine) db = Session() - purge_entries(db) return db
View file
pykolab-0.8.21.tar.gz/pykolab/auth/ldap/syncrepl.py
Changed
@@ -17,12 +17,12 @@ callback = None def __init__(self, filename, *args, **kwargs): - if kwargs.has_key('callback'): + if 'callback' in kwargs: self.callback = kwargs['callback'] del kwargs['callback'] ldap.ldapobject.LDAPObject.__init__(self, *args, **kwargs) - self.__db = anydbm.open(filename, 'c', 0640) + self.__db = anydbm.open(filename, 'c', 0o640) self.__presentUUIDs = {} def syncrepl_set_cookie(self,cookie): @@ -71,7 +71,7 @@ if uuids is None: if refreshDeletes is False: nonpresent = [] - for uuid in self.__db.keys(): + for uuid in self.__db: if uuid == 'cookie': continue if uuid in self.__presentUUIDs: continue nonpresent.append(uuid)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/__init__.py
Changed
@@ -51,12 +51,12 @@ for arg in sys.argv[1:]: arg_num += 1 if not arg.startswith('-') and len(sys.argv) >= arg_num: - if commands.commands.has_key(sys.argv[arg_num].replace('-','_')): + if sys.argv[arg_num].replace('-','_') in commands.commands: to_execute.append(sys.argv[arg_num].replace('-','_')) - if commands.commands.has_key("%s_%s" % ( + if "%s_%s" % ( '_'.join(to_execute),sys.argv[arg_num].replace('-','_') - )): + ) in commands.commands: to_execute.append(sys.argv[arg_num].replace('-','_'))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_acl_cleanup.py
Changed
@@ -52,7 +52,7 @@ acls = imap.list_acls(folder) if not aci_subject == None: - if aci_subject in acls.keys(): + if aci_subject in acls: log.debug(_("Deleting ACL %s for subject %s on folder %s") % ( acls[aci_subject], aci_subject, @@ -62,7 +62,7 @@ imap.set_acl(folder, aci_subject, '') #else: - #for _aci_subject in acls.keys(): + #for _aci_subject in acls: # connect to auth(!) # find recipient result_attr=aci_subject - # if no entry, expire acl \ No newline at end of file + # if no entry, expire acl
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_add_alias.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -39,10 +41,10 @@ try: secondary_rcpt_address = conf.cli_args.pop(0) except: - print >> sys.stderr, _("Specify the (new) alias address") + print(_("Specify the (new) alias address"), file=sys.stderr) sys.exit(1) except: - print >> sys.stderr, _("Specify the existing recipient address") + print(_("Specify the existing recipient address"), file=sys.stderr) sys.exit(1) if len(primary_rcpt_address.split('@')) > 1: @@ -62,29 +64,29 @@ secondary_rcpt_domain = conf.get('kolab', 'primary_domain') # Check if either is in fact a domain - if not primary_rcpt_domain.lower() in domains.keys(): - print >> sys.stderr, _("Domain %r is not a local domain") % (primary_rcpt_domain) + if not primary_rcpt_domain.lower() in domains: + print(_("Domain %r is not a local domain") % (primary_rcpt_domain), file=sys.stderr) sys.exit(1) - if not secondary_rcpt_domain.lower() in domains.keys(): - print >> sys.stderr, _("Domain %r is not a local domain") % (secondary_rcpt_domain) + if not secondary_rcpt_domain.lower() in domains: + print(_("Domain %r is not a local domain") % (secondary_rcpt_domain), file=sys.stderr) sys.exit(1) if not primary_rcpt_domain == secondary_rcpt_domain: if not domains[primary_rcpt_domain] == domains[secondary_rcpt_domain]: - print >> sys.stderr, _("Primary and secondary domain do not have the same parent domain") + print(_("Primary and secondary domain do not have the same parent domain"), file=sys.stderr) sys.exit(1) primary_recipient_dn = auth.find_recipient(primary_rcpt_address) if primary_recipient_dn == [] or len(primary_recipient_dn) == 0: - print >> sys.stderr, _("No such recipient %r") % (primary_rcpt_address) + print(_("No such recipient %r") % (primary_rcpt_address), file=sys.stderr) sys.exit(1) secondary_recipient_dn = auth.find_recipient(secondary_rcpt_address) if not secondary_recipient_dn == [] and not len(secondary_recipient_dn) == 0: - print >> sys.stderr, _("Recipient for alias %r already exists") % (secondary_rcpt_address) + print(_("Recipient for alias %r already exists") % (secondary_rcpt_address), file=sys.stderr) sys.exit(1) rcpt_attrs = conf.get_list('ldap', 'mail_attributes') @@ -94,18 +96,18 @@ if len(rcpt_attrs) >= 2: secondary_rcpt_attr = rcpt_attrs[1] else: - print >> sys.stderr, _("Environment is not configured for " + \ - "users to hold secondary mail attributes") + print(_("Environment is not configured for " + \ + "users to hold secondary mail attributes"), file=sys.stderr) sys.exit(1) primary_recipient = auth.get_entry_attributes(primary_rcpt_domain, primary_recipient_dn, rcpt_attrs) - if not primary_recipient.has_key(primary_rcpt_attr): - print >> sys.stderr, _("Recipient %r is not the primary recipient for address %r") % (primary_recipient, primary_rcpt_address) + if primary_rcpt_attr not in primary_recipient: + print(_("Recipient %r is not the primary recipient for address %r") % (primary_recipient, primary_rcpt_address), file=sys.stderr) sys.exit(1) - if not primary_recipient.has_key(secondary_rcpt_attr): + if secondary_rcpt_attr not in primary_recipient: auth.set_entry_attributes(primary_rcpt_domain, primary_recipient_dn, {secondary_rcpt_attr: [ secondary_rcpt_address ] }) else: if isinstance(primary_recipient[secondary_rcpt_attr], basestring):
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_add_domain.py
Changed
@@ -63,7 +63,7 @@ try: domain = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: domain = utils.ask_question(_("Domain name")) wap_client.domain_add(domain, conf.domains)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_add_user_subscription.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -48,10 +50,10 @@ user = conf.cli_args.pop(0) try: folder_pattern = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: folder_pattern = utils.ask_question(_("Folder pattern")) - except IndexError, errmsg: + except IndexError: user = utils.ask_question(_("User ID")) folder_pattern = utils.ask_question(_("Folder pattern")) @@ -73,9 +75,9 @@ imap.login_plain(admin_login, admin_password, user) if not imap.has_folder(folder_pattern): - print >> sys.stderr, \ - _("Cannot subscribe user to folder %r:") % (folder_pattern), \ - _("No such folder") + print(_("Cannot subscribe user to folder %r:") % (folder_pattern), \ + _("No such folder"), \ + file=sys.stderr) sys.exit(1) _folders = imap.lm(folder_pattern)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_check_quota.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -70,7 +72,7 @@ domains = auth.list_domains() folders = [] - for domain in domains.keys(): + for domain in domains: folders = imap.lm("user/%%@%s" % (domain)) domain_auth = Auth(domain=domain) @@ -81,7 +83,7 @@ user_dn = domain_auth.find_recipient(login) if user_dn == None: - print >> sys.stderr, _("No such user %s") % (login) + print(_("No such user %s") % (login), file=sys.stderr) continue if len(login.split('@')) > 1: @@ -95,14 +97,14 @@ user_quota = None if user_quota == None: - print >> sys.stderr, _("No quota for user %s") % (login) + print(_("No quota for user %s") % (login), file=sys.stderr) continue try: (used, quota) = imap.get_quota(folder) if not (int)(quota) == (int)(user_quota): - print >> sys.stderr, _("user quota does not match for %s (IMAP: %d, LDAP: %d)") % (login, (int)(quota), (int)(user_quota)) + print(_("user quota does not match for %s (IMAP: %d, LDAP: %d)") % (login, (int)(quota), (int)(user_quota)), file=sys.stderr) except: pass
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_count_domain_mailboxes.py
Changed
@@ -56,11 +56,11 @@ domains = auth.list_domains() folders = [] - for domain in domains.keys(): - print "%s: %d" % (domain,len(imap.lm("user/%%@%s" % (domain)))) + for domain in domains: + print("%s: %d" % (domain,len(imap.lm("user/%%@%s" % (domain))))) null_realm = len(imap.lm("user/%%")) if null_realm > 0: - print "null: %d" % (null_realm) + print("null: %d" % (null_realm))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_create_mailbox.py
Changed
@@ -56,7 +56,7 @@ def execute(*args, **kw): try: mailbox = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: log.error(_("Invalid argument")) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_delete_domain.py
Changed
@@ -63,7 +63,7 @@ try: domain = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: domain = utils.ask_question(_("Domain name")) if wap_client.domain_delete(domain, conf.force):
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_delete_mailbox.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -41,7 +43,7 @@ """ if len(conf.cli_args) < 1: - print >> sys.stderr, _("No mailbox specified") + print(_("No mailbox specified"), file=sys.stderr) sys.exit(1) imap = IMAP() @@ -54,17 +56,17 @@ folders = imap.list_folders(folder) if len(folders) < 1: - print >> sys.stderr, _("No such folder(s): %s") % (folder) + print(_("No such folder(s): %s") % (folder), file=sys.stderr) delete_folders.extend(folders) if len(delete_folders) == 0: - print >> sys.stderr, _("No folders to delete.") + print(_("No folders to delete."), file=sys.stderr) sys.exit(1) for delete_folder in delete_folders: try: imap.delete_mailfolder(delete_folder) - except Exception, errmsg: + except Exception: log.error(_("Could not delete mailbox '%s'") % (delete_folder))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_delete_mailbox_acl.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -41,10 +43,10 @@ folder = conf.cli_args.pop(0) try: identifier = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: identifier = utils.ask_question(_("ACI Subject")) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) quota = utils.ask_question(_("ACI Subject")) @@ -57,7 +59,7 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) else: folders = imap.list_folders(folder)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_export_mailbox.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import commands import pykolab @@ -115,8 +117,8 @@ stdout=subprocess.PIPE ).communicate()[0] - print >> sys.stderr, _("ZIP file at %s.zip") % (user) + print(_("ZIP file at %s.zip") % (user), file=sys.stderr) else: - print >> sys.stderr, _("No directories found for user %s") % (user) + print(_("No directories found for user %s") % (user), file=sys.stderr) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_find_domain.py
Changed
@@ -52,7 +52,7 @@ try: domain = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: domain = utils.ask_question(_("Domain name")) wap_client.domain_find(domain)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_deleted_mailboxes.py
Changed
@@ -101,7 +101,7 @@ log.debug(_("Appending folder search for %r") % (search), level=8) folders.extend(imap.lm(imap_utf7.encode(search))) - print "Deleted folders:" + print("Deleted folders:") for folder in folders: utf8_folder = imap_utf7.decode(folder).encode('utf-8') @@ -109,6 +109,6 @@ ts = datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)) if not conf.raw: - print "%s (Deleted at %s)" % (utf8_folder, ts) + print("%s (Deleted at %s)" % (utf8_folder, ts)) else: - print "%s (Deleted at %s)" % (folder, ts) + print("%s (Deleted at %s)" % (folder, ts))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_domain_mailboxes.py
Changed
@@ -75,10 +75,10 @@ for secondary in secondaries: folders.extend(imap.lm("user/%%@%s" % (secondary))) - print "Deleted folders:" + print("Deleted folders:") for folder in folders: if not conf.raw: - print imap_utf7.decode(folder) + print(imap_utf7.decode(folder)) else: - print folder + print(folder)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_domains.py
Changed
@@ -38,15 +38,15 @@ dna = conf.get('ldap', 'domain_name_attribute') - print "%-39s %-40s" % ("Primary Domain Name Space","Secondary Domain Name Space(s)") + print("%-39s %-40s" % ("Primary Domain Name Space","Secondary Domain Name Space(s)")) # TODO: Take a hint in --quiet, and otherwise print out a nice table # with headers and such. if isinstance(domains['list'], dict): - for domain_dn in domains['list'].keys(): + for domain_dn in domains['list']: if isinstance(domains['list'][domain_dn][dna], list): - print domains['list'][domain_dn][dna][0] + print(domains['list'][domain_dn][dna][0]) for domain_alias in domains['list'][domain_dn][dna][1:]: - print "%-39s %-40s" % ('', domain_alias) + print("%-39s %-40s" % ('', domain_alias)) else: - print domains['list'][domain_dn][dna] + print(domains['list'][domain_dn][dna])
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_mailbox_acls.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -39,7 +41,7 @@ def execute(*args, **kw): try: folder = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) if len(folder.split('@')) > 1: @@ -51,15 +53,15 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) else: acls = [] folders = imap.list_folders(folder) for folder in folders: - print "Folder", folder + print("Folder", folder) acls = imap.list_acls(folder) - for acl in acls.keys(): - print " %-13s %s" %(acls[acl], acl) + for acl in acls: + print(" %-13s %s" %(acls[acl], acl))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_mailbox_metadata.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -50,7 +52,7 @@ def execute(*args, **kw): try: folder = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) if len(folder.split('@')) > 1: @@ -77,19 +79,19 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) else: metadata = [] folders = imap.list_folders(folder) for folder in folders: - print "Folder", folder + print("Folder", folder) metadata = imap.get_metadata(folder) - if metadata.has_key(folder): - for annotation in metadata[folder].keys(): - print " %-49s %s" % ( + if folder in metadata: + for annotation in metadata[folder]: + print(" %-49s %s" % ( annotation, metadata[folder][annotation] - ) + ))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_mailboxes.py
Changed
@@ -98,6 +98,6 @@ for folder in folders: if not conf.raw: - print imap_utf7.decode(folder) + print(imap_utf7.decode(folder)) else: - print folder + print(folder)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_messages.py
Changed
@@ -118,17 +118,17 @@ if len(flags) >= 3: # Any flags are set if flags[2] == '(\\Deleted))': - print num, '\Deleted' + print(num, '\Deleted') elif flags[2] == '(\\Deleted': - print num, '\Deleted' + print(num, '\Deleted') elif '\\Deleted' in flags[3:]: - print num, '\Deleted' + print(num, '\Deleted') elif '\\Deleted))' in flags[3:]: - print num, '\Deleted' + print(num, '\Deleted') else: - print num + print(num) else: - print num + print(num) if conf.user == None: imap.set_acl(folder, 'cyrus-admin', '')
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_ous.py
Changed
@@ -36,4 +36,4 @@ wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw")) ous = wap_client.ous_list() - print '\n'.join(ous['list'].keys()) + print('\n'.join(ous['list'].keys()))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_quota.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -51,7 +53,7 @@ try: quota_folder = conf.cli_args.pop(0) - except IndexError, e: + except IndexError: quota_folder = '*' imap = IMAP() @@ -67,36 +69,36 @@ for quota_folder in quota_folders: try: (used, quota) = imap.get_quota(quota_folder) - print "Folder: %s" % (quota_folder) + print("Folder: %s" % (quota_folder)) if not used == None and not quota == None: if quota == 0: - print >> sys.stderr, _("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder) - print "%d (Used: %d, Percentage: %s)" % (quota, used, u'\u221E') + print(_("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder), file=sys.stderr) + print("%d (Used: %d, Percentage: %s)" % (quota, used, u'\u221E')) else: percentage = round(((float)(used)/(float)(quota)) * 100.0, 1) - print "%d (Used: %d, Percentage: %d)" % (quota, used, percentage) + print("%d (Used: %d, Percentage: %d)" % (quota, used, percentage)) else: if used == None: - print "%d (Used: %d, Percentage: %d)" % (quota, 0, 0) + print("%d (Used: %d, Percentage: %d)" % (quota, 0, 0)) else: - print "No quota" + print("No quota") except: try: (quota_root, used, quota) = imap.get_quota_root(quota_folder) - print "Folder: %s" % (quota_folder) + print("Folder: %s" % (quota_folder)) if not quota_root == None and not used == None and not quota == None: if quota == 0: - print >> sys.stderr, _("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder) - print "%d (Used: %d, Percentage: %d)" % (quota, used, u'\u221E') + print(_("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder), file=sys.stderr) + print("%d (Used: %d, Percentage: %d)" % (quota, used, u'\u221E')) else: percentage = round(((float)(used)/(float)(quota)) * 100.0, 1) - print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, used, percentage) + print("%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, used, percentage)) else: if used == None and not quota_root == None: - print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, 0, 0) + print("%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, 0, 0)) else: - print "No quota" + print("No quota") except: - print "Folder: %s" % (quota_folder) - print "No quota root" + print("Folder: %s" % (quota_folder)) + print("No quota root")
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_user_subscriptions.py
Changed
@@ -56,10 +56,10 @@ user = conf.cli_args.pop(0) try: folder_pattern = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: pass - except IndexError, errmsg: + except IndexError: user = utils.ask_question(_("User ID")) if len(user.split('@')) > 1: @@ -91,14 +91,14 @@ if len(unsubscribed_folders) > 0: if not conf.raw: - print "\n".join([imap_utf7.decode(x) for x in unsubscribed_folders]) + print("\n".join([imap_utf7.decode(x) for x in unsubscribed_folders])) else: - print "\n".join(unsubscribed_folders) + print("\n".join(unsubscribed_folders)) else: - print _("No unsubscribed folders for user %s") % (user) + print(_("No unsubscribed folders for user %s") % (user)) else: if not conf.raw: - print "\n".join([imap_utf7.decode(x) for x in subscribed_folders]) + print("\n".join([imap_utf7.decode(x) for x in subscribed_folders])) else: - print "\n".join(subscribed_folders) + print("\n".join(subscribed_folders))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_list_users.py
Changed
@@ -36,4 +36,4 @@ wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw")) users = wap_client.users_list() - print '\n'.join(users['list'].keys()) + print('\n'.join(users['list'].keys()))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_mailbox_cleanup.py
Changed
@@ -185,7 +185,7 @@ folder = imap_utf7.decode(folder) acls = imap.list_acls(folder) - for subject in acls.keys(): + for subject in acls: if subject == 'anyone': log.info( _("Skipping removal of ACL %s for subject %s on folder %s") % (
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_remove_mailaddress.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -39,7 +41,7 @@ def execute(*args, **kw): try: email_address = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: email_address = utils.ask_question("Email address to remove") # Get the domain from the email address @@ -72,7 +74,7 @@ attributes = auth.get_entry_attributes(domain, recipient, mail_attributes) # See which attribute holds the value we're trying to remove - for attribute in attributes.keys(): + for attribute in attributes: if isinstance(attributes[attribute], list): if email_address in attributes[attribute]: attributes[attribute].pop(attributes[attribute].index(email_address)) @@ -87,7 +89,7 @@ pass else: - print >> sys.stderr, _("Found the following recipients:") + print(_("Found the following recipients:"), file=sys.stderr) for recipient in recipients: - print recipient + print(recipient)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_remove_user_subscription.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -48,10 +50,10 @@ user = conf.cli_args.pop(0) try: folder_pattern = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: folder_pattern = utils.ask_question(_("Folder pattern")) - except IndexError, errmsg: + except IndexError: user = utils.ask_question(_("User ID")) folder_pattern = utils.ask_question(_("Folder pattern")) @@ -73,9 +75,9 @@ imap.login_plain(admin_login, admin_password, user) if not imap.has_folder(folder_pattern): - print >> sys.stderr, \ - _("Cannot subscribe user to folder %r:") % (folder_pattern), \ - _("No such folder") + print(_("Cannot subscribe user to folder %r:") % (folder_pattern), \ + _("No such folder"), \ + file=sys.stderr) sys.exit(1) _folders = imap.lm(folder_pattern) @@ -88,14 +90,14 @@ unsubscribed_folders.append(_folder) if len(unsubscribed_folders) > 0: - print _("Successfully unsubscribed user %s from the following folders:") % ( + print(_("Successfully unsubscribed user %s from the following folders:") % ( user - ) + )) - print "\n".join(unsubscribed_folders) + print("\n".join(unsubscribed_folders)) else: - print >> sys.stderr, _("User %s was not unsubscribed from any folders.") % ( + print(_("User %s was not unsubscribed from any folders.") % ( user - ) + ), file=sys.stderr) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_rename_mailbox.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -46,12 +48,12 @@ target_folder = conf.cli_args.pop(0) try: partition = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: partition = None - except IndexError, errmsg: - print >> sys.stderr, _("No target mailbox name specified") - except IndexError, errmsg: - print >> sys.stderr, _("No source mailbox name specified") + except IndexError: + print(_("No target mailbox name specified"), file=sys.stderr) + except IndexError: + print(_("No source mailbox name specified"), file=sys.stderr) sys.exit(1) if len(source_folder.split('@')) > 1: @@ -63,11 +65,11 @@ imap.connect(domain=domain) if not imap.has_folder(source_folder): - print >> sys.stderr, _("Source folder %r does not exist") % (source_folder) + print(_("Source folder %r does not exist") % (source_folder), file=sys.stderr) sys.exit(1) if imap.has_folder(target_folder) and partition == None: - print >> sys.stderr, _("Target folder %r already exists") % (target_folder) + print(_("Target folder %r already exists") % (target_folder), file=sys.stderr) sys.exit(1) imap.imap.rename(imap.folder_utf7(source_folder), imap.folder_utf7(target_folder), partition)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_server_info.py
Changed
@@ -55,4 +55,4 @@ else: imap.connect() - print imap.get_metadata("") + print(imap.get_metadata(""))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_set_mailbox_acl.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -43,14 +45,14 @@ identifier = conf.cli_args.pop(0) try: acl = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: acl = utils.ask_question(_("ACI Permissions")) - except IndexError, errmsg: + except IndexError: identifier = utils.ask_question(_("ACI Subject")) acl = utils.ask_question(_("ACI Permissions")) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) identifier = utils.ask_question(_("ACI Subject")) acl = utils.ask_question(_("ACI Permissions")) @@ -64,7 +66,7 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) else: folders = imap.list_folders(folder)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_set_mailbox_metadata.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -55,14 +57,14 @@ metadata_path = conf.cli_args.pop(0) try: metadata_value = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: metadata_value = utils.ask_question(_("Metadata value")) - except IndexError, errmsg: + except IndexError: metadata_path = utils.ask_question(_("Metadata path")) metadata_value = utils.ask_question(_("Metadata value")) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) metadata_path = utils.ask_question(_("Metadata path")) metadata_value = utils.ask_question(_("Metadata value")) @@ -91,7 +93,7 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) else: folders = imap.lm(imap_utf7.encode(folder))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_set_quota.py
Changed
@@ -17,6 +17,8 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # +from __future__ import print_function + import sys import commands @@ -41,10 +43,10 @@ folder = conf.cli_args.pop(0) try: quota = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: quota = utils.ask_question(_("New quota")) - except IndexError, errmsg: + except IndexError: folder = utils.ask_question(_("Folder name")) quota = utils.ask_question(_("New quota")) @@ -57,10 +59,10 @@ imap.connect(domain=domain) if not imap.has_folder(folder): - print >> sys.stderr, _("No such folder %r") % (folder) + print(_("No such folder %r") % (folder), file=sys.stderr) sys.exit(1) for _folder in imap.lm(imap.folder_utf7(folder)): imap.set_quota(_folder, quota) - print >> sys.stdout, "Quota for folder '%s' set to %d" % (_folder, int(quota)) + print("Quota for folder '%s' set to %d" % (_folder, int(quota)), file=sys.stdout)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_sync.py
Changed
@@ -139,7 +139,7 @@ imap.connect() if not imap.user_mailbox_exists(entry[mailbox_attribute]): - if entry.has_key('mailhost'): + if 'mailhost' in entry: server = entry['mailhost'] else: server = None
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_sync_mailhost_attrs.py
Changed
@@ -113,7 +113,7 @@ log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder)) try: imap.dm(folder) - except Exception, errmsg: + except Exception as errmsg: log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg)) else: log.info(_("Not automatically deleting shared folder '%s'") % (folder)) @@ -121,7 +121,7 @@ log.warning(_("No recipients for '%s' (use --delete to delete)!") % (r_folder)) for primary in list(set(domains.values())): - secondaries = [x for x in domains.keys() if domains[x] == primary] + secondaries = [x for x in domains if domains[x] == primary] folders = [] @@ -161,7 +161,7 @@ log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder)) try: imap.dm(folder) - except Exception, errmsg: + except Exception as errmsg: log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg)) else: log.info(_("Not automatically deleting shared folder '%s'") % (folder)) @@ -174,7 +174,7 @@ if not server == mailhost: if conf.dry_run: - print folder, server, mailhost + print(folder, server, mailhost) else: auth.set_entry_attribute(primary, recipient, 'mailhost', server) @@ -193,4 +193,4 @@ else: recipient = auth.find_recipient('/'.join(folder.split('/')[1:]), search_attrs=[result_attribute]) - print folder, server, recipient + print(folder, server, recipient)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/cmd_user_info.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys import commands @@ -37,7 +39,7 @@ try: user = conf.cli_args.pop(0) - except IndexError, errmsg: + except IndexError: user = utils.ask_question(_("Email address")) result = wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw")) @@ -48,13 +50,13 @@ user_info = wap_client.user_find({'mail':user}) if user_info == None or not user_info: - print >> sys.stderr, _("No such user %s") % (user) + print(_("No such user %s") % (user), file=sys.stderr) sys.exit(0) 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) + print("%s: %s" % (k,v)) else: - print "%s: %r" % (k,v) + print("%s: %r" % (k,v))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/commands.py
Changed
@@ -45,7 +45,7 @@ #print "exec(\"from %s import __init__ as %s_register\"" % (module_name,cmd_name) try: exec("from %s import __init__ as %s_register" % (module_name,cmd_name)) - except ImportError, errmsg: + except ImportError: pass exec("%s_register()" % (cmd_name)) @@ -68,7 +68,7 @@ __commands = {} - for command in commands.keys(): + for command in commands: if isinstance(command, tuple): command_group, command = command __commands[command_group] = { @@ -81,49 +81,49 @@ _commands.sort() for _command in _commands: - if __commands[_command].has_key('group'): + if 'group' in __commands[_command]: continue - if __commands[_command].has_key('function'): + if 'function' in __commands[_command]: # This is a top-level command if not __commands[_command]['description'] == None: - print "%-25s - %s" % (_command.replace('_','-'),__commands[_command]['description']) + print("%-25s - %s" % (_command.replace('_','-'),__commands[_command]['description'])) else: - print "%-25s" % (_command.replace('_','-')) + print("%-25s" % (_command.replace('_','-'))) for _command in _commands: - if not __commands[_command].has_key('function'): + if 'function' not in __commands[_command]: # This is a nested command - print "\n" + _("Command Group: %s") % (_command) + "\n" + print("\n" + _("Command Group: %s") % (_command) + "\n") ___commands = __commands[_command].keys() ___commands.sort() for __command in ___commands: if not __commands[_command][__command]['description'] == None: - print "%-4s%-21s - %s" % ('',__command.replace('_','-'),__commands[_command][__command]['description']) + print("%-4s%-21s - %s" % ('',__command.replace('_','-'),__commands[_command][__command]['description'])) else: - print "%-4s%-21s" % ('',__command.replace('_','-')) + print("%-4s%-21s" % ('',__command.replace('_','-'))) def execute(cmd_name, *args, **kw): if cmd_name == "": execute("help") sys.exit(0) - if not commands.has_key(cmd_name): + if cmd_name not in commands: log.error(_("No such command.")) sys.exit(1) - if not commands[cmd_name].has_key('function') and \ - not commands[cmd_name].has_key('group'): + if 'function' not in commands[cmd_name] and \ + 'group' not in commands[cmd_name]: log.error(_("No such command.")) sys.exit(1) - if commands[cmd_name].has_key('group'): + if 'group' in commands[cmd_name]: group = commands[cmd_name]['group'] command_name = commands[cmd_name]['cmd_name'] try: exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" % (group,command_name,group,command_name)) exec("%s_%s_cli_options()" % (group,command_name)) - except ImportError, e: + except ImportError: pass else: @@ -131,7 +131,7 @@ try: exec("from cmd_%s import cli_options as %s_cli_options" % (command_name,command_name)) exec("%s_cli_options()" % (command_name)) - except ImportError, errmsg: + except ImportError: pass conf.finalize_conf() @@ -163,7 +163,7 @@ if isinstance(aliases, basestring): aliases = [aliases] - if commands.has_key(command): + if command in commands: log.fatal(_("Command '%s' already registered") % (command)) sys.exit(1) @@ -197,5 +197,5 @@ ## def not_yet_implemented(*args, **kw): - print _("Not yet implemented") + print(_("Not yet implemented")) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/sieve/cmd_list.py
Changed
@@ -103,19 +103,19 @@ ) if not result: - print "LOGIN FAILED??" + print("LOGIN FAILED??") sieveclient.authenticated = True result = sieveclient.listscripts() if result == None: - print "No scripts" + print("No scripts") sys.exit(0) (active, scripts) = result - print "%s (active)" % (active) + print("%s (active)" % (active)) for script in scripts: - print script + print(script)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/sieve/cmd_refresh.py
Changed
@@ -125,28 +125,28 @@ if not vacation_text_attr == None: - if user.has_key(vacation_active_attr): + if vacation_active_attr in user: vacation_active = utils.true_or_false(user[vacation_active_attr]) else: vacation_active = False - if user.has_key(vacation_text_attr): + if vacation_text_attr in user: vacation_text = user[vacation_text_attr] else: vacation_active = False - if user.has_key(vacation_uce_attr): + if vacation_uce_attr in user: vacation_uce = utils.true_or_false(user[vacation_uce_attr]) else: vacation_uce = False - if user.has_key(vacation_react_domains_attr): + if vacation_react_domains_attr in user: if isinstance(user[vacation_react_domains_attr], list): vacation_react_domains = user[vacation_react_domains_attr] else: vacation_react_domains = [ user[vacation_react_domains_attr] ] else: - if user.has_key(vacation_noreact_domains_attr): + if vacation_noreact_domains_attr in user: if isinstance(user[vacation_noreact_domains_attr], list): vacation_noreact_domains = user[vacation_noreact_domains_attr] else: @@ -159,7 +159,7 @@ # dtf_active_attr = conf.get('sieve', 'deliver_to_folder_active') if not dtf_active_attr == None: - if user.has_key(dtf_active_attr): + if dtf_active_attr in user: dtf_active = utils.true_or_false(user[dtf_active_attr]) else: dtf_active = False @@ -172,7 +172,7 @@ if dtf_active: dtf_folder_name_attr = conf.get('sieve', 'deliver_to_folder_attr') if not dtf_folder_name_attr == None: - if user.has_key(dtf_folder_name_attr): + if dtf_folder_name_attr in user: dtf_folder = user[dtf_folder_name_attr] else: log.warning(_("Delivery to folder active, but no folder name attribute available for user %r") % (user)) @@ -204,14 +204,14 @@ forward_active_attr = conf.get('sieve', 'forward_address_active') if not forward_active_attr == None: - if user.has_key(forward_active_attr): + if forward_active_attr in user: forward_active = utils.true_or_false(user[forward_active_attr]) else: forward_active = False if not forward_active == False: forward_address_attr = conf.get('sieve', 'forward_address_attr') - if user.has_key(forward_address_attr): + if forward_address_attr in user: if isinstance(user[forward_address_attr], basestring): forward_addresses = [ user[forward_address_attr] ] elif isinstance(user[forward_address_attr], str): @@ -224,14 +224,14 @@ forward_keepcopy_attr = conf.get('sieve', 'forward_keepcopy_active') if not forward_keepcopy_attr == None: - if user.has_key(forward_keepcopy_attr): + if forward_keepcopy_attr in user: forward_keepcopy = utils.true_or_false(user[forward_keepcopy_attr]) else: forward_keepcopy = False forward_uce_attr = conf.get('sieve', 'forward_uce_active') if not forward_uce_attr == None: - if user.has_key(forward_uce_attr): + if forward_uce_attr in user: forward_uce = utils.true_or_false(user[forward_uce_attr]) else: forward_uce = False
View file
pykolab-0.8.21.tar.gz/pykolab/cli/sieve/cmd_test.py
Changed
@@ -89,7 +89,7 @@ active, scripts = sieveclient.listscripts() - print "%s (active)" % (active) + print("%s (active)" % (active)) _all_scripts = [ active ] + scripts _used_scripts = [ active ] @@ -97,7 +97,7 @@ _a_script = sieveclient.getscript(active) - print _a_script + print(_a_script) import sievelib.parser @@ -107,23 +107,23 @@ #print "%r" % (_a_parsed) if not _a_parsed: - print _a_parser.error + print(_a_parser.error) - print "%r" % (_a_parser.result) + print("%r" % (_a_parser.result)) for _a_command in _a_parser.result: - print _a_command.name, _a_command.arguments + print(_a_command.name, _a_command.arguments) if len(_a_command.children) > 0: for _a_child in _a_command.children: - print " ", _a_child.name, _a_child.arguments + print(" ", _a_child.name, _a_child.arguments) if _a_command.name == "include": if _a_command.arguments["script"].strip('"') in scripts: - print "OK" + print("OK") _used_scripts.append(_a_command.arguments["script"].strip('"')) else: - print "Not OK" + print("Not OK") for script in scripts: - print script + print(script)
View file
pykolab-0.8.21.tar.gz/pykolab/cli/telemetry/cmd_examine_command_issue.py
Changed
@@ -72,7 +72,7 @@ id=session.server_id ).first() - print _("Session by %s on server %s") % (user.sasl_username,server.fqdn) + print(_("Session by %s on server %s") % (user.sasl_username,server.fqdn)) command_issues = db.query( telemetry.TelemetryCommandIssue @@ -94,14 +94,14 @@ ).first() if command_issue.id == _command_issue.id: - print "=========" + print("=========") - print "Client(%d): %s %s %s" % ( + print("Client(%d): %s %s %s" % ( _command_issue.id, _command_issue.command_tag, command.command, command_arg.command_arg - ) + )) server_responses = db.query( telemetry.TelemetryServerResponse @@ -113,11 +113,11 @@ server_response_lines = server_response.response.split('\n'); for server_response_line in server_response_lines: - print "Server(%d): %s" % ( + print("Server(%d): %s" % ( server_response.id, server_response_line - ) + )) if command_issue.id == _command_issue.id: - print "=========" + print("=========")
View file
pykolab-0.8.21.tar.gz/pykolab/cli/telemetry/cmd_examine_session.py
Changed
@@ -97,7 +97,7 @@ return - print _("Session by %s on server %s") % (user.sasl_username,server.fqdn) + print(_("Session by %s on server %s") % (user.sasl_username,server.fqdn)) command_issues = db.query( telemetry.TelemetryCommandIssue @@ -118,12 +118,12 @@ id=command_issue.command_arg_id ).first() - print "Client(%d): %s %s %s" % ( + print("Client(%d): %s %s %s" % ( command_issue.id, command_issue.command_tag, command.command, command_arg.command_arg - ) + )) server_responses = db.query( telemetry.TelemetryServerResponse @@ -134,8 +134,8 @@ for server_response in server_responses: server_response_lines = server_response.response.split('\n'); for server_response_line in server_response_lines: - print "Server(%d): %s" % ( + print("Server(%d): %s" % ( server_response.id, server_response_line - ) + ))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/telemetry/cmd_list_sessions.py
Changed
@@ -55,9 +55,9 @@ id=session.user_id ).first() - print _("Session for user %s started at %s with ID %s") % ( + print(_("Session for user %s started at %s with ID %s") % ( user.sasl_username, session.start, session.id - ) + ))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/wap/cmd_system_capabilities.py
Changed
@@ -38,13 +38,13 @@ system_capabilities = wap_client.system_capabilities() if system_capabilities['count'] < 1: - print "No system capabilities" + print("No system capabilities") sys.exit(1) - for domain in system_capabilities['list'].keys(): - print "Domain capabilities for %s" % (domain) + for domain in system_capabilities['list']: + print("Domain capabilities for %s" % (domain)) domain_capabilities = system_capabilities['list'][domain] - for service in domain_capabilities['actions'].keys(): - print " %-15s - %r" % (service, domain_capabilities['actions'][service]['type']) + for service in domain_capabilities['actions']: + print(" %-15s - %r" % (service, domain_capabilities['actions'][service]['type']))
View file
pykolab-0.8.21.tar.gz/pykolab/cli/wap/cmd_user_types_list.py
Changed
@@ -37,4 +37,4 @@ for user_type in user_types['list']: type = user_types['list'][user_type] - print "%-15s - %s" % (type['key'], type['description']) + print("%-15s - %s" % (type['key'], type['description']))
View file
pykolab-0.8.21.tar.gz/pykolab/conf/__init__.py
Changed
@@ -85,7 +85,7 @@ self.defaults = Defaults(self.plugins) # But, they should be available in our class as well - for option in self.defaults.__dict__.keys(): + for option in self.defaults.__dict__: log.debug( _("Setting %s to %r (from defaults)") % ( option, @@ -103,7 +103,7 @@ # Also set the cli options if hasattr(self, 'cli_keywords') and self.cli_keywords is not None: - for option in self.cli_keywords.__dict__.keys(): + for option in self.cli_keywords.__dict__: retval = False if hasattr(self, "check_setting_%s" % (option)): exec( @@ -144,14 +144,14 @@ file and checks, then sets everything it can find. """ - for section in self.defaults.__dict__.keys(): + for section in self.defaults.__dict__: if section == 'testing': continue if not config.has_section(section): continue - for key in self.defaults.__dict__[section].keys(): + for key in self.defaults.__dict__[section]: retval = False if not config.has_option(section, key): continue @@ -530,7 +530,7 @@ ) def set_defaults_from_cli_options(self): - for long_opt in self.cli_parser.__dict__['_long_opt'].keys(): + for long_opt in self.cli_parser.__dict__['_long_opt']: if long_opt == "--help": continue @@ -541,7 +541,7 @@ ) # But, they should be available in our class as well - for option in self.cli_parser.defaults.keys(): + for option in self.cli_parser.defaults: log.debug( _("Setting %s to %r (from the default values for CLI options)") % ( option,
View file
pykolab-0.8.21.tar.gz/pykolab/conf/entitlement.py
Changed
@@ -54,8 +54,8 @@ ) if (bool)(ca_cert.has_expired()): - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s" % (ca_cert_file)) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s" % (ca_cert_file))) # TODO: Check validity and warn ~1-2 months in advance. @@ -77,8 +77,8 @@ ca_cert_issuer_hash_digest = hashlib.sha224(ca_cert_issuer_hash).hexdigest() if not ca_cert_issuer_hash_digest in self.entitlement_verification: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (ca_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (ca_cert_file)) ca_cert_subject_hash = subprocess.Popen( [ @@ -95,8 +95,8 @@ ca_cert_subject_hash_digest = hashlib.sha224(ca_cert_subject_hash).hexdigest() if not ca_cert_subject_hash_digest in self.entitlement_verification: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (ca_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (ca_cert_file)) customer_cert_issuer_hash = subprocess.Popen( [ @@ -113,14 +113,14 @@ customer_cert_issuer_hash_digest = hashlib.sha224(customer_cert_issuer_hash).hexdigest() if not customer_cert_issuer_hash_digest in self.entitlement_verification: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (customer_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (customer_cert_file)) if not ca_cert_issuer.countryName == ca_cert_subject.countryName: - raise Exception, _("Invalid entitlement certificate") + raise Exception(_("Invalid entitlement certificate")) if not ca_cert_issuer.organizationName == ca_cert_subject.organizationName: - raise Exception, _("Invalid entitlement certificate") + raise Exception(_("Invalid entitlement certificate")) if os.path.isdir('/etc/kolab/entitlement.d/') and \ os.access('/etc/kolab/entitlement.d/', os.R_OK): @@ -192,7 +192,7 @@ # log.error(_("Error reading entitlement certificate authority file")) def get(self): - if len(self.entitlement.keys()) == 0: + if len(self.entitlement) == 0: return None else: return self.entitlement @@ -227,8 +227,8 @@ ).communicate()[0].strip().split('=')[1] if not customer_cert_serial == cert_serial: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (customer_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (customer_cert_file)) customer_cert_issuer_hash = subprocess.Popen( [ @@ -243,8 +243,8 @@ ).communicate()[0].strip() if not customer_cert_issuer_hash == cert_issuer_hash: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (customer_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (customer_cert_file)) customer_cert_subject_hash = subprocess.Popen( [ @@ -259,8 +259,8 @@ ).communicate()[0].strip() if not customer_cert_subject_hash == cert_subject_hash: - raise Exception, _("Invalid entitlement verification " + \ - "certificate at %s") % (customer_cert_file) + raise Exception(_("Invalid entitlement verification " + \ + "certificate at %s") % (customer_cert_file)) def get(self): return self.entitlement
View file
pykolab-0.8.21.tar.gz/pykolab/constants.py.in
Changed
@@ -50,7 +50,7 @@ try: domain_parts = fqdn.split('.') if len(domain_parts) < 3: - print >> sys.stderr, _("WARNING") + ": " + _("The Fully Qualified Domain Name or FQDN for this system is incorrect. Falling back to 'localdomain'.") + print(_("WARNING") + ": " + _("The Fully Qualified Domain Name or FQDN for this system is incorrect. Falling back to 'localdomain'."), file=sys.stderr) domainname = "localdomain" else: domainname = '.'.join(domain_parts[1:])
View file
pykolab-0.8.21.tar.gz/pykolab/imap/__init__.py
Changed
@@ -70,7 +70,7 @@ # For each ACL entry, see if we think it is a current, valid # entry - for acl_entry in acls.keys(): + for acl_entry in acls: # If the key 'acl_entry' does not exist in the dictionary # of valid ACL entries, this ACL entry has got to go. if acl_entry == aci_subject: @@ -244,7 +244,7 @@ del self.imap # Empty out self._imap as well - for key in self._imap.keys(): + for key in self._imap: self._imap[key].disconnect() del self._imap[key] @@ -414,7 +414,7 @@ acl_map[mode] += char current_acls = self.imap.lam(self.folder_utf7(folder)) - for current_acl in current_acls.keys(): + for current_acl in current_acls: if current_acl == identifier: _acl = current_acls[current_acl] break @@ -572,7 +572,7 @@ auth.disconnect() - if len(domains.keys()) > 0: + if len(domains) > 0: if self.domain in domains: primary = domains[self.domain] @@ -654,7 +654,7 @@ time.sleep(0.5) - for additional_folder in additional_folders.keys(): + for additional_folder in additional_folders: _add_folder = {} folder_name = additional_folder @@ -671,7 +671,7 @@ continue if "annotations" in additional_folders[additional_folder]: - for annotation in additional_folders[additional_folder]["annotations"].keys(): + for annotation in additional_folders[additional_folder]["annotations"]: self.set_metadata( folder_name, "%s" % (annotation), @@ -679,7 +679,7 @@ ) if "acls" in additional_folders[additional_folder]: - for acl in additional_folders[additional_folder]["acls"].keys(): + for acl in additional_folders[additional_folder]["acls"]: self.set_acl( folder_name, "%s" % (acl), @@ -744,7 +744,7 @@ self.logout() self.connect(domain=self.domain) - for additional_folder in additional_folders.keys(): + for additional_folder in additional_folders: if additional_folder.startswith(personal) and not personal == '': folder_name = additional_folder.replace(personal, '') else:
View file
pykolab-0.8.21.tar.gz/pykolab/imap/cyrus.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import cyruslib import sys import time @@ -146,15 +148,15 @@ """ try: cyruslib.CYRUS.login(self, *args, **kw) - except cyruslib.CYRUSError, errmsg: + except cyruslib.CYRUSError as errmsg: log.error("Login to Cyrus IMAP server failed: %r", errmsg) - except Exception, errmsg: + except Exception as errmsg: log.exception(errmsg) self.separator = self.SEP try: self._id() - except Exception, errmsg: + except Exception: pass log.debug( @@ -217,7 +219,7 @@ level=8 ) - if self.mbox.has_key(mailfolder): + if mailfolder in self.mbox: log.debug( _( "Possibly reproducing the find " + @@ -246,8 +248,8 @@ ann_path ) - if annotations.has_key(mailfolder): - if annotations[mailfolder].has_key(s_ann_path): + if mailfolder in annotations: + if s_ann_path in annotations[mailfolder]: break if max_tries <= num_try: @@ -380,7 +382,7 @@ try: self.setannotation(mailfolder, annotation, value, shared) - except cyruslib.CYRUSError, errmsg: + except cyruslib.CYRUSError as errmsg: log.error( _("Could not set annotation %r on mail folder %r: %r") % ( annotation, @@ -499,18 +501,16 @@ self.rename(undelete_folder, target_folder) else: if not target_server == source_server: - print >> sys.stdout, \ - _("Would have transferred %s from %s to %s") % ( + print(_("Would have transferred %s from %s to %s") % ( undelete_folder, source_server, target_server - ) + ), file=sys.stdout) - print >> sys.stdout, \ - _("Would have renamed %s to %s") % ( + print(_("Would have renamed %s to %s") % ( undelete_folder, target_folder - ) + ), file=sys.stdout) def parse_mailfolder(self, mailfolder): """
View file
pykolab-0.8.21.tar.gz/pykolab/imap/dovecot.py
Changed
@@ -37,6 +37,8 @@ # are using need. # ----- +from __future__ import print_function + import cyruslib import imaplib import sys @@ -240,7 +242,7 @@ def __verbose(self, msg): if self.VERBOSE: - print >> self.LOGFD, msg + print(msg, file=self.LOGFD) def connect(self, uri): """ @@ -521,9 +523,9 @@ self.rename(undelete_folder,target_folder) else: if not target_server == self.server: - print >> sys.stdout, _("Would have transfered %s from %s to %s") % (undelete_folder, self.server, target_server) + print(_("Would have transfered %s from %s to %s") % (undelete_folder, self.server, target_server), file=sys.stdout) - print >> sys.stdout, _("Would have renamed %s to %s") % (undelete_folder, target_folder) + print(_("Would have renamed %s to %s") % (undelete_folder, target_folder), file=sys.stdout) def parse_mailfolder(self, mailfolder): """
View file
pykolab-0.8.21.tar.gz/pykolab/imap_utf7.py
Changed
@@ -31,7 +31,7 @@ if isinstance(s, str) and sum(n for n in (ord(c) for c in s) if n > 127): try: s = unicode(s, "UTF-8") - except Exception, errmsg: + except Exception: raise FolderNameError("%r contains characters not valid in a str folder name. " "Convert to unicode first?" % s)
View file
pykolab-0.8.21.tar.gz/pykolab/logger.py
Changed
@@ -213,7 +213,7 @@ group_gid ) - os.chmod(self.logfile, '0660') + os.chmod(self.logfile, 0o660) except Exception as errmsg: print(
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/__init__.py
Changed
@@ -67,15 +67,15 @@ exec("from pykolab.plugins import %s" % (plugin)) self.plugins[plugin] = True self.load_plugins(plugins=[plugin]) - except ImportError, e: + except ImportError as e: log.error(_("ImportError for plugin %s: %s") % (plugin, e)) traceback.print_exc() self.plugins[plugin] = False - except RuntimeError, e: + except RuntimeError as e: log.error( _("RuntimeError for plugin %s: %s") % (plugin, e)) traceback.print_exc() self.plugins[plugin] = False - except Exception, e: + except Exception as e: log.error(_("Plugin %s failed to load (%s: %s)") % (plugin, e.__class__, e)) traceback.print_exc() except: @@ -113,9 +113,9 @@ if hasattr(getattr(self, plugin), "set_defaults"): try: getattr(self, plugin).set_defaults(defaults) - except TypeError, e: + except TypeError as e: log.error(_("Cannot set defaults for plugin %s: %s") % (plugin, e)) - except RuntimeError, e: + except RuntimeError as e: log.error(_("Cannot set defaults for plugin %s: %s") % (plugin, e)) except: log.error(_("Cannot set defaults for plugin %s: Unknown Error") % (plugin)) @@ -139,7 +139,7 @@ if hasattr(getattr(self, plugin), "set_runtime"): try: getattr(self, plugin).set_runtime(runtime) - except RuntimeError, e: + except RuntimeError as e: log.error(_("Cannot set runtime for plugin %s: %s") % (plugin, e)) else: log.debug(_("Not setting runtime for plugin %s: No function 'set_runtime()'") % (plugin), level=5) @@ -160,9 +160,9 @@ if hasattr(getattr(self, plugin), "add_options"): try: exec("self.%s.add_options(parser)" % plugin) - except RuntimeError, e: + except RuntimeError as e: log.error(_("Cannot add options for plugin %s: %s") % (plugin, e)) - except TypeError, e: + except TypeError as e: log.error(_("Cannot add options for plugin %s: %s") % (plugin, e)) else: log.debug(_("Not adding options for plugin %s: No function 'add_options()'") % plugin, level=5) @@ -184,7 +184,7 @@ if hasattr(getattr(self, plugin), "check_options"): try: exec("self.%s.check_options()" % plugin) - except AttributeError, e: + except AttributeError as e: log.error(_("Cannot check options for plugin %s: %s") % (plugin, e)) else: log.debug(_("Not checking options for plugin %s: No function 'check_options()'") % (plugin), level=5) @@ -262,7 +262,7 @@ if hasattr(getattr(self, plugin), bool): try: exec("boolval = self.%s.%s" % (plugin, bool)) - except AttributeError, e: + except AttributeError: pass else: boolval = None
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/defaultfolders/__init__.py
Changed
@@ -43,13 +43,13 @@ user_folder - user folder """ - if not kw.has_key('additional_folders'): + if 'additional_folders' not in kw: log.error(_("Plugin %s called without required keyword %s.") % ("defaultfolders", "additional_folders")) return {} try: exec("additional_folders = %s" % (kw['additional_folders'])) - except Exception, e: + except Exception: log.error(_("Could not parse additional_folders")) return {}
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/dynamicquota/__init__.py
Changed
@@ -53,7 +53,7 @@ """ for keyword in [ 'used', 'imap_quota', 'ldap_quota', 'default_quota' ]: - if not kw.has_key(keyword): + if keyword not in kw: log.warning( _("No keyword %s passed to set_user_folder_quota") % ( keyword
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/recipientpolicy/__init__.py
Changed
@@ -56,12 +56,12 @@ user_attrs = utils.normalize(kw['entry']) - if not user_attrs.has_key('domain'): + if 'domain' not in user_attrs: user_attrs['domain'] = kw['primary_domain'] elif not user_attrs['domain'] == kw['primary_domain']: user_attrs['domain'] = kw['primary_domain'] - if not user_attrs.has_key('preferredlanguage'): + if 'preferredlanguage' not in user_attrs: default_locale = conf.get(user_attrs['domain'], 'default_locale') if default_locale == None: default_locale = conf.get('kolab', 'default_locale') @@ -75,9 +75,9 @@ mail = utils.translate(mail, user_attrs['preferredlanguage']) mail = mail.lower() return mail - except KeyError, e: + except KeyError: log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy")) - if user_attrs.has_key('mail'): + if 'mail' in user_attrs: return user_attrs['mail'] else: return None @@ -96,12 +96,12 @@ user_attrs = utils.normalize(kw['entry']) - if not user_attrs.has_key('domain'): + if 'domain' not in user_attrs: user_attrs['domain'] = kw['primary_domain'] elif not user_attrs['domain'] == kw['primary_domain']: user_attrs['domain'] = kw['primary_domain'] - if not user_attrs.has_key('preferredlanguage'): + if 'preferredlanguage' not in user_attrs: default_locale = conf.get(user_attrs['domain'], 'default_locale') if default_locale == None: default_locale = conf.get(user_attrs['domain'], 'default_locale') @@ -112,7 +112,7 @@ try: exec("alternative_mail_routines = %s" % kw['secondary_mail']) - except Exception, e: + except Exception: log.error(_("Could not parse the alternative mail routines")) alternative_mail = [] @@ -123,22 +123,22 @@ for attr in [ 'givenname', 'sn', 'surname' ]: try: user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage']) - except Exception, errmsg: + except Exception: log.error(_("An error occurred in composing the secondary mail attribute for entry %r") % (user_attrs['id'])) if conf.debuglevel > 8: import traceback traceback.print_exc() return [] - for number in alternative_mail_routines.keys(): - for routine in alternative_mail_routines[number].keys(): + for number in alternative_mail_routines: + for routine in alternative_mail_routines[number]: try: exec("retval = '%s'.%s" % (routine,alternative_mail_routines[number][routine] % user_attrs)) log.debug(_("Appending additional mail address: %s") % (retval), level=8) alternative_mail.append(retval) - except Exception, errmsg: + except Exception as errmsg: log.error(_("Policy for secondary email address failed: %r") % (errmsg)) if conf.debuglevel > 8: import traceback @@ -153,7 +153,7 @@ log.debug(_("Appending additional mail address: %s") % (retval), level=8) alternative_mail.append(retval) - except KeyError, e: + except KeyError: log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy")) alternative_mail = utils.normalize(alternative_mail)
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/roundcubedb/__init__.py
Changed
@@ -58,7 +58,7 @@ result_attribute = conf.get('cyrus-sasl', 'result_attribute') # execute Roundcube's bin/deluser.sh script to do the work - if kw.has_key('user') and kw['user'].has_key(result_attribute) and os.path.exists(rcpath + 'bin/deluser.sh'): + if 'user' in kw and result_attribute in kw['user'] and os.path.exists(rcpath + 'bin/deluser.sh'): proc = subprocess.Popen([ 'sudo -u apache', rcpath + 'bin/deluser.sh', kw['user'][result_attribute] ], stderr=subprocess.PIPE, stdout=subprocess.PIPE) procout, procerr = proc.communicate() if proc.returncode != 0:
View file
pykolab-0.8.21.tar.gz/pykolab/plugins/sievemgmt/__init__.py
Changed
@@ -47,7 +47,7 @@ user - the user identifier """ - if not len(kw.keys()) == 1 or not kw.has_key('user'): + if not len(kw) == 1 or 'user' not in kw: log.error(_("Wrong number of arguments for sieve management plugin")) return else: @@ -137,28 +137,28 @@ if not vacation_text_attr == None: - if user.has_key(vacation_active_attr): + if vacation_active_attr in user: vacation_active = utils.true_or_false(user[vacation_active_attr]) else: vacation_active = False - if user.has_key(vacation_text_attr): + if vacation_text_attr in user: vacation_text = user[vacation_text_attr] else: vacation_active = False - if user.has_key(vacation_uce_attr): + if vacation_uce_attr in user: vacation_uce = utils.true_or_false(user[vacation_uce_attr]) else: vacation_uce = False - if user.has_key(vacation_react_domains_attr): + if vacation_react_domains_attr in user: if isinstance(user[vacation_react_domains_attr], list): vacation_react_domains = user[vacation_react_domains_attr] else: vacation_react_domains = [ user[vacation_react_domains_attr] ] else: - if user.has_key(vacation_noreact_domains_attr): + if vacation_noreact_domains_attr in user: if isinstance(user[vacation_noreact_domains_attr], list): vacation_noreact_domains = user[vacation_noreact_domains_attr] else: @@ -171,7 +171,7 @@ # dtf_active_attr = conf.get('sieve', 'deliver_to_folder_active') if not dtf_active_attr == None: - if user.has_key(dtf_active_attr): + if dtf_active_attr in user: dtf_active = utils.true_or_false(user[dtf_active_attr]) else: dtf_active = False @@ -184,7 +184,7 @@ if dtf_active: dtf_folder_name_attr = conf.get('sieve', 'deliver_to_folder_attr') if not dtf_folder_name_attr == None: - if user.has_key(dtf_folder_name_attr): + if dtf_folder_name_attr in user: dtf_folder = user[dtf_folder_name_attr] else: log.warning(_("Delivery to folder active, but no folder name attribute available for user %r") % (user)) @@ -216,14 +216,14 @@ forward_active_attr = conf.get('sieve', 'forward_address_active') if not forward_active_attr == None: - if user.has_key(forward_active_attr): + if forward_active_attr in user: forward_active = utils.true_or_false(user[forward_active_attr]) else: forward_active = False if not forward_active == False: forward_address_attr = conf.get('sieve', 'forward_address_attr') - if user.has_key(forward_address_attr): + if forward_address_attr in user: if isinstance(user[forward_address_attr], basestring): forward_addresses = [ user[forward_address_attr] ] elif isinstance(user[forward_address_attr], str): @@ -236,14 +236,14 @@ forward_keepcopy_attr = conf.get('sieve', 'forward_keepcopy_active') if not forward_keepcopy_attr == None: - if user.has_key(forward_keepcopy_attr): + if forward_keepcopy_attr in user: forward_keepcopy = utils.true_or_false(user[forward_keepcopy_attr]) else: forward_keepcopy = False forward_uce_attr = conf.get('sieve', 'forward_uce_active') if not forward_uce_attr == None: - if user.has_key(forward_uce_attr): + if forward_uce_attr in user: forward_uce = utils.true_or_false(user[forward_uce_attr]) else: forward_uce = False
View file
pykolab-0.8.21.tar.gz/pykolab/setup/__init__.py
Changed
@@ -37,7 +37,7 @@ for arg in sys.argv[1:]: arg_num += 1 if not arg.startswith('-') and len(sys.argv) >= arg_num: - if components.components.has_key(sys.argv[arg_num].replace('-','_')): + if sys.argv[arg_num].replace('-','_') in components.components: to_execute.append(sys.argv[arg_num].replace('-','_')) def run(self):
View file
pykolab-0.8.21.tar.gz/pykolab/setup/components.py
Changed
@@ -64,7 +64,7 @@ __components = {} - for component in components.keys(): + for component in components: if isinstance(component, tuple): component_group, component = component __components[component_group] = { @@ -77,24 +77,24 @@ _components.sort() for _component in _components: - if __components[_component].has_key('function'): + if 'function' in __components[_component]: # This is a top-level component if not __components[_component]['description'] == None: - print "%-25s - %s" % (_component.replace('_','-'),__components[_component]['description']) + print("%-25s - %s" % (_component.replace('_','-'),__components[_component]['description'])) else: - print "%-25s" % (_component.replace('_','-')) + print("%-25s" % (_component.replace('_','-'))) for _component in _components: - if not __components[_component].has_key('function'): + if 'function' not in __components[_component]: # This is a nested component - print "\n" + _("Command Group: %s") % (_component) + "\n" + print("\n" + _("Command Group: %s") % (_component) + "\n") ___components = __components[_component].keys() ___components.sort() for __component in ___components: if not __components[_component][__component]['description'] == None: - print "%-4s%-21s - %s" % ('',__component.replace('_','-'),__components[_component][__component]['description']) + print("%-4s%-21s - %s" % ('',__component.replace('_','-'),__components[_component][__component]['description'])) else: - print "%-4s%-21s" % ('',__component.replace('_','-')) + print("%-4s%-21s" % ('',__component.replace('_','-'))) def _list_components(*args, **kw): """ @@ -104,7 +104,7 @@ __components = {} - for component in components.keys(): + for component in components: if isinstance(component, tuple): component_group, component = component __components[component_group] = { @@ -124,20 +124,20 @@ if component_name in components_included_in_cli: return - if components[component_name].has_key('group'): + if 'group' in components[component_name]: group = components[component_name]['group'] component_name = components[component_name]['component_name'] try: exec("from %s.setup_%s import cli_options as %s_%s_cli_options" % (group,component_name,group,component_name)) exec("%s_%s_cli_options()" % (group,component_name)) - except ImportError, e: + except ImportError: pass else: try: exec("from setup_%s import cli_options as %s_cli_options" % (component_name,component_name)) exec("%s_cli_options()" % (component_name)) - except ImportError, e: + except ImportError: pass components_included_in_cli.append(component_name) @@ -161,7 +161,7 @@ execute_this = False if execute_this: - if components[component].has_key('after'): + if 'after' in components[component]: for _component in components[component]['after']: if not _component in executed_components: execute_this = False @@ -183,12 +183,12 @@ for component in _list_components(): cli_options_from_component(component) - if not components.has_key(component_name): + if component_name not in components: log.error(_("No such component.")) sys.exit(1) - if not components[component_name].has_key('function') and \ - not components[component_name].has_key('group'): + if 'function' not in components[component_name] and \ + 'group' not in components[component_name]: log.error(_("No such component.")) sys.exit(1) @@ -227,7 +227,7 @@ if isinstance(aliases, basestring): aliases = [aliases] - if components.has_key(component): + if component in components: log.fatal(_("Command '%s' already registered") % (component)) sys.exit(1) @@ -262,5 +262,5 @@ ## def not_yet_implemented(*args, **kw): - print _("Not yet implemented") + print(_("Not yet implemented")) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_freebusy.py
Changed
@@ -164,12 +164,12 @@ cfg_parser = RawConfigParser() cfg_parser.read('/etc/kolab-freebusy/config.ini') - for section in freebusy_settings.keys(): - if len(freebusy_settings[section].keys()) < 1: + for section in freebusy_settings: + if len(freebusy_settings[section]) < 1: cfg_parser.remove_section(section) continue - for key in freebusy_settings[section].keys(): + for key in freebusy_settings[section]: if not cfg_parser.has_section(section): cfg_parser.add_section(section)
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_ldap.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import ldap import ldap.modlist import os @@ -102,7 +104,7 @@ ask_questions = False if conf.without_ldap: - print >> sys.stderr, _("Skipping setup of LDAP, as specified") + print(_("Skipping setup of LDAP, as specified"), file=sys.stderr) return _input = {} @@ -130,12 +132,12 @@ return elif conf.with_ad and conf.with_openldap: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" You can not configure Kolab to run against OpenLDAP and Active Directory simultaneously. """) - ) + ), file=sys.stderr) sys.exit(1) @@ -143,7 +145,7 @@ for path, directories, files in os.walk('/etc/dirsrv/'): for direct in directories: if direct.startswith('slapd-'): - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" It seems 389 Directory Server has an existing instance configured. This setup script does not @@ -151,20 +153,20 @@ make sure /etc/dirsrv/ and /var/lib/dirsrv/ are clean so that this setup does not have to worry. """) - ) + ), file=sys.stderr) sys.exit(1) _input = {} if ask_questions: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a password for the LDAP administrator user 'admin', used to login to the graphical console of 389 Directory server. """) - ) + ), file=sys.stderr) _input['admin_pass'] = utils.ask_question( _("Administrator password"), @@ -176,14 +178,14 @@ if conf.directory_manager_pwd is not None: _input['dirmgr_pass'] = conf.directory_manager_pwd else: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a password for the LDAP Directory Manager user, which is the administrator user you will be using to at least initially log in to the Web Admin, and that Kolab uses to perform administrative tasks. """) - ) + ), file=sys.stderr) _input['dirmgr_pass'] = utils.ask_question( _("Directory Manager password"), @@ -192,13 +194,13 @@ confirm=True ) - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please choose the system user and group the service should use to run under. These should be existing, unprivileged, local system POSIX accounts with no shell. """) - ) + ), file=sys.stderr) try: pw = pwd.getpwnam("dirsrv") @@ -241,7 +243,7 @@ _input['rootdn'] = utils.standard_root_dn(_input['domain']) if ask_questions: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" This setup procedure plans to set up Kolab Groupware for the following domain name space. This domain name is @@ -249,7 +251,7 @@ interface. Please confirm this is the appropriate domain name space. """) - ) + ), file=sys.stderr) answer = utils.ask_confirmation("%s" % (_input['domain'])) @@ -260,21 +262,21 @@ if not _input['domain'] == None and not _input['domain'] == "": positive_answer = True else: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Invalid input. Please try again. """) - ) + ), file=sys.stderr) _input['nodotdomain'] = _input['domain'].replace('.','_') _input['rootdn'] = utils.standard_root_dn(_input['domain']) - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" The standard root dn we composed for you follows. Please confirm this is the root dn you wish to use. """) - ) + ), file=sys.stderr) answer = utils.ask_confirmation("%s" % (_input['rootdn'])) @@ -285,11 +287,11 @@ if not _input['rootdn'] == None and not _input['rootdn'] == "": positive_answer = True else: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Invalid input. Please try again. """) - ) + ), file=sys.stderr) # TODO: Loudly complain if the fqdn does not resolve back to this system. @@ -344,13 +346,13 @@ '--file=%s' % (filename) ] - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Setup is now going to set up the 389 Directory Server. This may take a little while (during which period there is no output and no progress indication). """) - ) + ), file=sys.stderr) log.info(_("Setting up 389 Directory Server")) @@ -363,7 +365,7 @@ (stdoutdata, stderrdata) = setup_389.communicate() if not setup_389.returncode == 0: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" An error was detected in the setup procedure for 389 Directory Server. This setup will write out stderr and @@ -371,7 +373,7 @@ /var/log/kolab/setup.out.log respectively, before it exits. """) - ) + ), file=sys.stderr) fp = open('/var/log/kolab/setup.error.log', 'w') fp.write(stderrdata) @@ -441,7 +443,7 @@ "directory server service.")) if ask_questions: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a Cyrus Administrator password. This password is used by Kolab to execute administrative @@ -449,7 +451,7 @@ yourself to troubleshoot Cyrus IMAP and/or perform other administrative tasks against Cyrus IMAP directly. """) - ) + ), file=sys.stderr) _input['cyrus_admin_pass'] = utils.ask_question( _("Cyrus Administrator password"), @@ -458,14 +460,14 @@ confirm=True ) - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a Kolab Service account password. This account is used by various services such as Postfix, and Roundcube, as anonymous binds to the LDAP server will not be allowed. """) - ) + ), file=sys.stderr) _input['kolab_service_pass'] = utils.ask_question( _("Kolab Service password"),
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_mta.py
Changed
@@ -243,9 +243,9 @@ ) if not os.path.isdir('/etc/postfix/ldap'): - os.mkdir('/etc/postfix/ldap/', 0770) + os.mkdir('/etc/postfix/ldap/', 0o770) - for filename in files.keys(): + for filename in files: fp = open(filename, 'w') fp.write(files[filename]) fp.close() @@ -305,7 +305,7 @@ setting_base = '/files/etc/postfix/main.cf/' - for setting_key in postfix_main_settings.keys(): + for setting_key in postfix_main_settings: setting = os.path.join(setting_base,setting_key) current_value = myaugeas.get(setting)
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_mysql.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import os import subprocess import tempfile @@ -142,12 +144,12 @@ if answer == "1" or answer == 1: if not conf.mysqlrootpw: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply the root password for MySQL, so we can set up user accounts for other components that use MySQL. """) - ) + ), file=sys.stderr) mysql_root_password = utils.ask_question( _("MySQL root password"), @@ -161,7 +163,7 @@ mysql_root_password = 'unix_socket' else: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a root password for MySQL. This password will be the administrative user for this MySQL server, @@ -170,7 +172,7 @@ about this password, but you will need it for administrative tasks in MySQL. """) - ) + ), file=sys.stderr) mysql_root_password = utils.ask_question( _("MySQL root password"), @@ -256,7 +258,7 @@ fp = open('/tmp/kolab-setup-my.cnf', 'w') - os.chmod('/tmp/kolab-setup-my.cnf', 0600) + os.chmod('/tmp/kolab-setup-my.cnf', 0o600) fp.write(data) fp.close() @@ -276,13 +278,13 @@ p1.stdout.close() p2.communicate() - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply a password for the MySQL user 'kolab'. This password will be used by Kolab services, such as the Web Administration Panel. """) - ) + ), file=sys.stderr) mysql_kolab_password = utils.ask_question( _("MySQL kolab password"),
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_php.py
Changed
@@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function from augeas import Augeas import os import shutil @@ -66,13 +67,13 @@ def execute(*args, **kw): if conf.timezone is None: - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( _(""" Please supply the timezone PHP should be using. You have to use a Continent or Country / City locality name like 'Europe/Berlin', but not just 'CEST'. """) - ) + ), file=sys.stderr) conf.timezone = utils.ask_question( _("Timezone ID"),
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_roundcube.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import codecs import grp import hashlib @@ -51,13 +53,13 @@ def execute(*args, **kw): - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( """ Please supply a password for the MySQL user 'roundcube'. This password will be used by the Roundcube webmail interface. """ - ) + ), file=sys.stderr) mysql_roundcube_password = utils.ask_question( "MySQL roundcube password", @@ -223,9 +225,9 @@ break if not os.path.isfile('/tmp/kolab-setup-my.cnf'): - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( """Please supply the MySQL root password (use 'unix_socket' for socket based authentication)""" - ) + ), file=sys.stderr) mysql_root_password = utils.ask_question( _("MySQL root password"), @@ -259,7 +261,7 @@ """ % (mysql_root_password, conf.mysqlhost) fp = open('/tmp/kolab-setup-my.cnf', 'w') - os.chmod('/tmp/kolab-setup-my.cnf', 0600) + os.chmod('/tmp/kolab-setup-my.cnf', 0o600) fp.write(data) fp.close()
View file
pykolab-0.8.21.tar.gz/pykolab/setup/setup_syncroton.py
Changed
@@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import os import subprocess import sys @@ -66,9 +68,9 @@ break if not os.path.isfile('/tmp/kolab-setup-my.cnf'): - print >> sys.stderr, utils.multiline_message( + print(utils.multiline_message( """Please supply the MySQL root password (use 'unix_socket' for socket based authentication)""" - ) + ), file=sys.stderr) mysql_root_password = utils.ask_question( _("MySQL root password"), @@ -109,7 +111,7 @@ """ % (mysql_root_password, conf.mysqlhost) fp = open('/tmp/kolab-setup-my.cnf', 'w') - os.chmod('/tmp/kolab-setup-my.cnf', 0600) + os.chmod('/tmp/kolab-setup-my.cnf', 0o600) fp.write(data) fp.close()
View file
pykolab-0.8.21.tar.gz/pykolab/telemetry.py
Changed
@@ -642,7 +642,7 @@ try: metadata.create_all(engine) - except sqlalchemy.exc.OperationalError, e: + except sqlalchemy.exc.OperationalError as e: log.error(_("Operational Error in telemetry database: %s" % (e))) Session = sessionmaker(bind=engine)
View file
pykolab-0.8.21.tar.gz/pykolab/translit.py
Changed
@@ -98,7 +98,7 @@ } def transliterate(_input, lang, _output_expected=None): - if locale_translit_map.has_key(lang): + if lang in locale_translit_map: _translit_name = locale_translit_map[lang] else: _translit_name = lang @@ -107,22 +107,22 @@ if not isinstance(_input, unicode): for char in _input.decode('utf-8'): - if translit_map.has_key(_translit_name): - if translit_map[_translit_name].has_key(char): + if _translit_name in translit_map: + if char in translit_map[_translit_name]: _output += translit_map[_translit_name][char] - elif char in [repr(x) for x in translit_map[_translit_name].keys()]: - _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]] + elif char in [repr(x) for x in translit_map[_translit_name]]: + _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name]]][0]] else: _output += char else: _output += char else: for char in _input: - if translit_map.has_key(_translit_name): - if translit_map[_translit_name].has_key(char): + if _translit_name in translit_map: + if char in translit_map[_translit_name]: _output += translit_map[_translit_name][char] - elif char in [repr(x) for x in translit_map[_translit_name].keys()]: - _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]] + elif char in [repr(x) for x in translit_map[_translit_name]]: + _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name]]][0]] else: _output += char else:
View file
pykolab-0.8.21.tar.gz/pykolab/utils.py
Changed
@@ -198,7 +198,7 @@ str_format = "%%%ds" % max_key_length - if default == '' or default not in options.keys(): + if default == '' or default not in options: for key in keys: if options[key] == key: print(" - " + key) @@ -219,10 +219,10 @@ continue - if answer == '' and default in options.keys(): + if answer == '' and default in options: answer = default - if answer in [str(x) for x in options.keys()]: + if answer in [str(x) for x in options]: answer_correct = True return answer
View file
pykolab-0.8.21.tar.gz/pykolab/wap_client/__init__.py
Changed
@@ -70,7 +70,7 @@ if not response: return False - if response.has_key('session_token'): + if 'session_token' in response: session_id = response['session_token'] return True @@ -188,35 +188,35 @@ def get_group_input(): group_types = group_types_list() - if len(group_types.keys()) > 1: - for key in group_types.keys(): + if len(group_types) > 1: + for key in group_types: if not key == "status": - print "%s) %s" % (key,group_types[key]['name']) + print("%s) %s" % (key,group_types[key]['name'])) group_type_id = utils.ask_question("Please select the group type") - elif len(group_types.keys()) > 0: - print "Automatically selected the only group type available" + elif len(group_types) > 0: + print("Automatically selected the only group type available") group_type_id = group_types.keys()[0] else: - print "No group types available" + print("No group types available") sys.exit(1) - if group_types.has_key(group_type_id): + if group_type_id in group_types: group_type_info = group_types[group_type_id]['attributes'] else: - print "No such group type" + print("No such group type") sys.exit(1) params = { 'group_type_id': group_type_id } - for attribute in group_type_info['form_fields'].keys(): + for attribute in group_type_info['form_fields']: params[attribute] = utils.ask_question(attribute) - for attribute in group_type_info['auto_form_fields'].keys(): + for attribute in group_type_info['auto_form_fields']: exec("retval = group_form_value_generate_%s(params)" % (attribute)) params[attribute] = retval[attribute] @@ -226,26 +226,26 @@ user_types = user_types_list() if user_types['count'] > 1: - print "" - for key in user_types['list'].keys(): + print("") + for key in user_types['list']: if not key == "status": - print "%s) %s" % (key,user_types['list'][key]['name']) + print("%s) %s" % (key,user_types['list'][key]['name'])) - print "" + print("") user_type_id = utils.ask_question("Please select the user type") elif user_types['count'] > 0: - print "Automatically selected the only user type available" + print("Automatically selected the only user type available") user_type_id = user_types['list'].keys()[0] else: - print "No user types available" + print("No user types available") sys.exit(1) - if user_types['list'].has_key(user_type_id): + if user_type_id in user_types['list']: user_type_info = user_types['list'][user_type_id]['attributes'] else: - print "No such user type" + print("No such user type") sys.exit(1) params = { @@ -256,9 +256,9 @@ must_attrs = [] may_attrs = [] - for attribute in user_type_info['form_fields'].keys(): + for attribute in user_type_info['form_fields']: if isinstance(user_type_info['form_fields'][attribute], dict): - if user_type_info['form_fields'][attribute].has_key('optional') and user_type_info['form_fields'][attribute]['optional']: + if 'optional' in user_type_info['form_fields'][attribute] and user_type_info['form_fields'][attribute]['optional']: may_attrs.append(attribute) else: must_attrs.append(attribute) @@ -267,14 +267,14 @@ for attribute in must_attrs: if isinstance(user_type_info['form_fields'][attribute], dict) and \ - user_type_info['form_fields'][attribute].has_key('type'): + 'type' in user_type_info['form_fields'][attribute]: if user_type_info['form_fields'][attribute]['type'] == 'select': - if not user_type_info['form_fields'][attribute].has_key('values'): + if 'values' not in user_type_info['form_fields'][attribute]: attribute_values = form_value_select_options('user', user_type_id, attribute) default = '' - if attribute_values[attribute].has_key('default'): + if 'default' in attribute_values[attribute]: default = attribute_values[attribute]['default'] params[attribute] = utils.ask_menu( @@ -285,7 +285,7 @@ else: default = '' - if user_type_info['form_fields'][attribute].has_key('default'): + if 'default' in user_type_info['form_fields'][attribute]: default = user_type_info['form_fields'][attribute]['default'] params[attribute] = utils.ask_menu( @@ -300,11 +300,11 @@ else: params[attribute] = utils.ask_question(attribute) - for attribute in user_type_info['fields'].keys(): + for attribute in user_type_info['fields']: params[attribute] = user_type_info['fields'][attribute] exec("retval = user_form_value_generate(params)") - print retval + print(retval) return params @@ -337,7 +337,7 @@ 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_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)) @@ -436,7 +436,7 @@ try: response_data = json.loads(data) - except ValueError, e: + except ValueError: # Some data is not JSON log.error(_("Response data is not JSON")) @@ -459,7 +459,7 @@ 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)) @@ -497,7 +497,7 @@ 'role': role.keys()[0] } - if not params.has_key('role'): + if 'role' not in params: role = role_find_by_attribute(params) params = { 'role': role.keys()[0] @@ -591,7 +591,7 @@ user_info = request('GET', 'user.info', get=get) - for attribute in attributes.keys(): + for attribute in attributes: user_info[attribute] = attributes[attribute] post = json.dumps(user_info) @@ -615,7 +615,7 @@ 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)
View file
pykolab-0.8.21.tar.gz/pykolab/xml/attendee.py
Changed
@@ -25,7 +25,7 @@ } def participant_status_label(status): - return _(participant_status_labels[status]) if participant_status_labels.has_key(status) else _(status) + return _(participant_status_labels[status]) if status in participant_status_labels else _(status) class Attendee(kolabformat.Attendee): @@ -92,7 +92,7 @@ if isinstance(rsvp, bool): self.setRSVP(rsvp) else: - if self.rsvp_map.has_key(rsvp): + if rsvp in self.rsvp_map: self.setRSVP(self.rsvp_map[rsvp]) if not role == None: @@ -101,10 +101,10 @@ if not cutype == None: self.set_cutype(cutype) - if ical_params and ical_params.has_key('DELEGATED-FROM'): + if ical_params and 'DELEGATED-FROM' in ical_params: self.delegate_from(Attendee(str(ical_params['DELEGATED-FROM']), role=self.get_role(), cutype=self.get_cutype())) - if ical_params and ical_params.has_key('DELEGATED-TO'): + if ical_params and 'DELEGATED-TO' in ical_params: self.delegate_to(Attendee(str(ical_params['DELEGATED-TO']))) if not participant_status == None: @@ -132,14 +132,14 @@ for delegator in delegators: if not isinstance(delegator, Attendee): - raise ValueError, _("Not a valid attendee") + raise ValueError(_("Not a valid attendee")) else: self.set_role(delegator.get_role()) self.set_cutype(delegator.get_cutype()) crefs.append(delegator.contactreference) if len(crefs) == 0: - raise ValueError, _("No valid delegator references found") + raise ValueError(_("No valid delegator references found")) else: crefs += self.get_delegated_from() @@ -154,12 +154,12 @@ for delegatee in delegatees: if not isinstance(delegatee, Attendee): - raise ValueError, _("Not a valid attendee") + raise ValueError(_("Not a valid attendee")) else: crefs.append(delegatee.contactreference) if len(crefs) == 0: - raise ValueError, _("No valid delegatee references found") + raise ValueError(_("No valid delegatee references found")) else: crefs += self.get_delegated_to() @@ -210,36 +210,36 @@ return self.rsvp() def _translate_value(self, val, map): - name_map = dict([(v, k) for (k, v) in map.iteritems()]) - return name_map[val] if name_map.has_key(val) else 'UNKNOWN' + 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): - if cutype in self.cutype_map.keys(): + if cutype in self.cutype_map: self.setCutype(self.cutype_map[cutype]) elif cutype in self.cutype_map.values(): self.setCutype(cutype) else: - raise InvalidAttendeeCutypeError, _("Invalid cutype %r") % (cutype) + raise InvalidAttendeeCutypeError(_("Invalid cutype %r") % (cutype)) def set_name(self, name): self.contactreference.set_name(name) self.setContact(self.contactreference) def set_participant_status(self, participant_status): - if participant_status in self.participant_status_map.keys(): + if participant_status in self.participant_status_map: self.setPartStat(self.participant_status_map[participant_status]) elif participant_status in self.participant_status_map.values(): self.setPartStat(participant_status) else: - raise InvalidAttendeeParticipantStatusError, _("Invalid participant status %r") % (participant_status) + raise InvalidAttendeeParticipantStatusError(_("Invalid participant status %r") % (participant_status)) def set_role(self, role): - if role in self.role_map.keys(): + if role in self.role_map: self.setRole(self.role_map[role]) elif role in self.role_map.values(): self.setRole(role) else: - raise InvalidAttendeeRoleError, _("Invalid role %r") % (role) + raise InvalidAttendeeRoleError(_("Invalid role %r") % (role)) def set_rsvp(self, rsvp): self.setRSVP(rsvp) @@ -248,7 +248,7 @@ 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):
View file
pykolab-0.8.21.tar.gz/pykolab/xml/contact.py
Changed
@@ -23,7 +23,7 @@ contact = contact_from_string(payload) # append attachment parts to Contact object - elif contact and part.has_key('Content-ID'): + elif contact and 'Content-ID' in part: contact._attachment_parts.append(part) return contact @@ -160,8 +160,8 @@ return _gender def _translate_value(self, val, map): - name_map = dict([(v, k) for (k, v) in map.iteritems()]) - return name_map[val] if name_map.has_key(val) else 'UNKNOWN' + 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): if not self.isValid(): @@ -169,7 +169,7 @@ 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)() @@ -198,7 +198,7 @@ affiliations = self.affiliations() if len(affiliations) > 0: _affiliation = self._affiliation2dict(affiliations[0]) - if _affiliation.has_key('address'): + if 'address' in _affiliation: data['address'].extend(_affiliation['address']) _affiliation.pop('address', None) data.update(_affiliation) @@ -223,7 +223,7 @@ 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 @@ 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 @@ '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 @@ 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,13 +293,13 @@ 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() if reltype and val is not None: if aslist: - if not data.has_key(reltype): + if reltype not in data: data[reltype] = [] data[reltype].append(val) else: @@ -308,7 +308,7 @@ 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'): @@ -328,7 +328,7 @@ if error == None or not error: return xml else: - raise ContactIntegrityError, kolabformat.errorMessage() + raise ContactIntegrityError(kolabformat.errorMessage()) class ContactIntegrityError(Exception):
View file
pykolab-0.8.21.tar.gz/pykolab/xml/contact_reference.py
Changed
@@ -44,7 +44,7 @@ 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)()
View file
pykolab-0.8.21.tar.gz/pykolab/xml/event.py
Changed
@@ -39,7 +39,7 @@ event = event_from_string(payload) # append attachment parts to Event object - elif event and part.has_key('Content-ID'): + elif event and 'Content-ID' in part: event._attachment_parts.append(part) return event @@ -166,7 +166,7 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Rdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)) + raise InvalidEventDateError(_("Rdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))) self.event.addRecurrenceDate(xmlutils.to_cdatetime(_datetime, True)) @@ -183,14 +183,14 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Exdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)) + raise InvalidEventDateError(_("Exdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))) self.event.addExceptionDate(xmlutils.to_cdatetime(_datetime, True)) def add_exception(self, exception): recurrence_id = exception.get_recurrence_id() if recurrence_id is None: - raise EventIntegrityError, "Recurrence exceptions require a Recurrence-ID property" + raise EventIntegrityError("Recurrence exceptions require a Recurrence-ID property") # check if an exception with the given recurrence-id already exists append = True @@ -218,7 +218,7 @@ def del_exception(self, exception): recurrence_id = exception.get_recurrence_id() if recurrence_id is None: - raise EventIntegrityError, "Recurrence exceptions require a Recurrence-ID property" + raise EventIntegrityError("Recurrence exceptions require a Recurrence-ID property") updated = False vexceptions = self.event.exceptions() @@ -353,7 +353,7 @@ break # use the libkolab calendaring bindings to load the full iCal data - if ical_event.has_key('RRULE') or ical_event.has_key('ATTACH') \ + if 'RRULE' in ical_event or 'ATTACH' in ical_event \ or [part for part in ical_event.walk() if part.name == 'VALARM']: if raw is None or raw == "": raw = ical if isinstance(ical, str) else ical.to_ical() @@ -364,20 +364,20 @@ # TODO: Clause the timestamps for zulu suffix causing datetime.datetime # to fail substitution. for attr in list(set(ical_event.required)): - if ical_event.has_key(attr): + if attr in ical_event: self.set_from_ical(attr.lower(), ical_event[attr]) # NOTE: Make sure to list(set()) or duplicates may arise # NOTE: Keep the original order e.g. to read DTSTART before RECURRENCE-ID for attr in list(OrderedDict.fromkeys(ical_event.singletons)): - if ical_event.has_key(attr): + if attr in ical_event: if isinstance(ical_event[attr], list): ical_event[attr] = ical_event[attr][0]; self.set_from_ical(attr.lower(), ical_event[attr]) # NOTE: Make sure to list(set()) or duplicates may arise for attr in list(set(ical_event.multiple)): - if ical_event.has_key(attr): + if attr in ical_event: self.set_from_ical(attr.lower(), ical_event[attr]) def _xml_from_ical(self, ical): @@ -402,7 +402,7 @@ attendee = self.get_attendee_by_name(attendee) else: - raise ValueError, _("No attendee with email or name %r") %(attendee) + raise ValueError(_("No attendee with email or name %r") %(attendee)) return attendee @@ -410,7 +410,7 @@ return attendee else: - raise ValueError, _("Invalid argument value attendee %r, must be basestring or Attendee") % (attendee) + raise ValueError(_("Invalid argument value attendee %r, must be basestring or Attendee") % (attendee)) def find_attendee(self, attendee): try: @@ -422,13 +422,13 @@ if email in [x.get_email() for x in self.get_attendees()]: return [x for x in self.get_attendees() if x.get_email() == email][0] - raise ValueError, _("No attendee with email %r") %(email) + raise ValueError(_("No attendee with email %r") %(email)) def get_attendee_by_name(self, name): if name in [x.get_name() for x in self.get_attendees()]: return [x for x in self.get_attendees() if x.get_name() == name][0] - raise ValueError, _("No attendee with name %r") %(name) + raise ValueError(_("No attendee with name %r") %(name)) def get_attendees(self): return self._attendees @@ -551,31 +551,31 @@ delegators = attendee.get_delegated_from() delegatees = attendee.get_delegated_to() - if rsvp in attendee.rsvp_map.keys(): + 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.keys(): + 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.keys(): + 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.keys(): + 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 @@ -608,12 +608,12 @@ def get_ical_attendee_participant_status(self, attendee): attendee = self.get_attendee(attendee) - if attendee.get_participant_status() in attendee.participant_status_map.keys(): + 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") + raise ValueError(_("Invalid participant status")) def get_ical_created(self): return self.get_created() @@ -652,7 +652,7 @@ def get_ical_status(self): status = self.event.status() - if status in self.status_map.keys(): + if status in self.status_map: return status return self._translate_value(status, self.status_map) if status else None @@ -814,12 +814,12 @@ self.event.setAttendees(self._attendees) def set_classification(self, classification): - if classification in self.classification_map.keys(): + if classification in self.classification_map: self.event.setClassification(self.classification_map[classification]) elif classification in self.classification_map.values(): self.event.setClassification(classification) else: - raise ValueError, _("Invalid classification %r") % (classification) + raise ValueError(_("Invalid classification %r") % (classification)) def set_created(self, _datetime=None): if _datetime is None or isinstance(_datetime, datetime.time): @@ -850,7 +850,7 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Event end needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)) + raise InvalidEventDateError(_("Event end needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))) self.event.setEnd(xmlutils.to_cdatetime(_datetime, True)) @@ -864,7 +864,7 @@ def add_custom_property(self, name, value): if not name.upper().startswith('X-'): - raise ValueError, _("Invalid custom property name %r") % (name) + raise ValueError(_("Invalid custom property name %r") % (name)) props = self.event.customProperties() props.append(kolabformat.CustomProperty(name.upper(), value)) @@ -904,27 +904,27 @@ else: params = {} - if params.has_key('CN'): + if 'CN' in params: name = ustr(params['CN']) else: name = None - if params.has_key('ROLE'): + if 'ROLE' in params: role = params['ROLE'] else: role = None - if params.has_key('PARTSTAT'): + if 'PARTSTAT' in params: partstat = params['PARTSTAT'] else: partstat = None - if params.has_key('RSVP'): + if 'RSVP' in params: rsvp = params['RSVP'] else: rsvp = None - if params.has_key('CUTYPE'): + if 'CUTYPE' in params: cutype = params['CUTYPE'] else: cutype = kolabformat.CutypeIndividual @@ -963,7 +963,7 @@ else: params = {} - if params.has_key('CN'): + if 'CN' in params: cn = ustr(params['CN']) self.set_organizer(str(address), name=cn) @@ -1001,7 +1001,7 @@ try: self.thisandfuture = params.get('RANGE', '') == 'THISANDFUTURE' self.set_recurrence_id(value, self.thisandfuture) - except InvalidEventDateError, e: + except InvalidEventDateError: pass def set_lastmodified(self, _datetime=None): @@ -1017,7 +1017,7 @@ _datetime = datetime.datetime.utcnow() if not valid_datetime: - raise InvalidEventDateError, _("Event last-modified needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)) + raise InvalidEventDateError(_("Event last-modified needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))) self.event.setLastModified(xmlutils.to_cdatetime(_datetime, False, True)) @@ -1060,17 +1060,17 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Event start needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)) + raise InvalidEventDateError(_("Event start needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))) self.event.setStart(xmlutils.to_cdatetime(_datetime, True)) def set_status(self, status): - if status in self.status_map.keys(): + if status in self.status_map: self.event.setStatus(self.status_map[status]) elif status in self.status_map.values(): self.event.setStatus(status) elif not status == kolabformat.StatusUndefined: - raise InvalidEventStatusError, _("Invalid status set: %r") % (status) + raise InvalidEventStatusError(_("Invalid status set: %r") % (status)) def set_summary(self, summary): self.event.setSummary(summary) @@ -1093,7 +1093,7 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Event recurrence-id needs datetime.datetime instance") + raise InvalidEventDateError(_("Event recurrence-id needs datetime.datetime instance")) if _thisandfuture is None: _thisandfuture = self.thisandfuture @@ -1111,12 +1111,12 @@ if error == None or not error: return event_xml else: - raise EventIntegrityError, kolabformat.errorMessage() + raise EventIntegrityError(kolabformat.errorMessage()) 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,8 +1176,8 @@ return ret def _translate_value(self, val, map): - name_map = dict([(v, k) for (k, v) in map.iteritems()]) - return name_map[val] if name_map.has_key(val) else 'UNKNOWN' + 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): from email.MIMEMultipart import MIMEMultipart
View file
pykolab-0.8.21.tar.gz/pykolab/xml/note.py
Changed
@@ -19,7 +19,7 @@ note = note_from_string(payload) # append attachment parts to Note object - elif note and part.has_key('Content-ID'): + elif note and 'Content-ID' in part: note._attachment_parts.append(part) return note @@ -86,12 +86,12 @@ return _class def set_classification(self, classification): - if classification in self.classification_map.keys(): + if classification in self.classification_map: self.setClassification(self.classification_map[classification]) elif classification in self.classification_map.values(): self.setClassification(status) else: - raise ValueError, _("Invalid classification %r") % (classification) + raise ValueError(_("Invalid classification %r") % (classification)) def add_category(self, category): _categories = self.categories() @@ -99,8 +99,8 @@ self.setCategories(_categories) def _translate_value(self, val, map): - name_map = dict([(v, k) for (k, v) in map.iteritems()]) - return name_map[val] if name_map.has_key(val) else 'UNKNOWN' + 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): if not self.isValid(): @@ -108,7 +108,7 @@ 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)() @@ -131,7 +131,7 @@ if error == None or not error: return xml else: - raise NoteIntegrityError, kolabformat.errorMessage() + raise NoteIntegrityError(kolabformat.errorMessage()) class NoteIntegrityError(Exception): def __init__(self, message):
View file
pykolab-0.8.21.tar.gz/pykolab/xml/recurrence_rule.py
Changed
@@ -48,7 +48,7 @@ } def frequency_label(freq): - return _(frequency_labels[freq]) if frequency_labels.has_key(freq) else _(freq) + return _(frequency_labels[freq]) if freq in frequency_labels else _(freq) class RecurrenceRule(kolabformat.RecurrenceRule): @@ -114,11 +114,11 @@ } for prop,setter in vectorimap.items(): - if vrecur.has_key(prop): + if prop in vrecur: getattr(self, setter)([int(v) for v in vrecur[prop]]) for prop,setter in settermap.items(): - if vrecur.has_key(prop): + if prop in vrecur: getattr(self, setter)(vrecur[prop]) def set_count(self, count): @@ -150,7 +150,7 @@ occurrence = int(wday.relative) if str(wday)[0] == '-': occurrence = occurrence * -1 - if self.weekday_map.has_key(weekday): + if weekday in self.weekday_map: daypos.append(kolabformat.DayPos(occurrence, self.weekday_map[weekday])) self.setByday(daypos) @@ -175,14 +175,14 @@ def _set_map_value(self, val, pmap, setter): if isinstance(val, list): val = val[0] - if val in pmap.keys(): + if val in pmap: getattr(self, setter)(pmap[val]) elif val in pmap.values(): getattr(self, setter)(val) def _translate_value(self, val, map): - name_map = dict([(v, k) for (k, v) in map.iteritems()]) - return name_map[val] if name_map.has_key(val) else 'UNKNOWN' + 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): rrule = icalendar.vRecur(dict((k,v) for k,v in self.to_dict(True).items() if not (type(v) == str and v == '' or type(v) == list and len(v) == 0))) @@ -194,7 +194,7 @@ 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):
View file
pykolab-0.8.21.tar.gz/pykolab/xml/todo.py
Changed
@@ -29,7 +29,7 @@ todo = todo_from_string(payload) # append attachment parts to Todo object - elif todo and part.has_key('Content-ID'): + elif todo and 'Content-ID' in part: todo._attachment_parts.append(part) return todo @@ -82,11 +82,11 @@ ical_todo = c break - log.debug("Todo.from_ical(); %r, %r, %r" % (type(ical_todo), ical_todo.has_key('ATTACH'), ical_todo.has_key('ATTENDEE')), level=8) + log.debug("Todo.from_ical(); %r, %r, %r" % (type(ical_todo), 'ATTACH' in ical_todo, 'ATTENDEE' in ical_todo), level=8) # DISABLED: use the libkolab calendaring bindings to load the full iCal data # TODO: this requires support for iCal parsing in the kolab.calendaring bindings - if False and ical_todo.has_key('ATTACH') or [part for part in ical_todo.walk() if part.name == 'VALARM']: + if False and 'ATTACH' in ical_todo or [part for part in ical_todo.walk() if part.name == 'VALARM']: if raw is None or raw == "": raw = ical if isinstance(ical, str) else ical.to_ical() self._xml_from_ical(raw) @@ -94,21 +94,21 @@ self.event = kolabformat.Todo() for attr in list(set(ical_todo.required)): - if ical_todo.has_key(attr): + if attr in ical_todo: self.set_from_ical(attr.lower(), ical_todo[attr]) for attr in list(set(ical_todo.singletons)): - if ical_todo.has_key(attr): + if attr in ical_todo: if isinstance(ical_todo[attr], list): ical_todo[attr] = ical_todo[attr][0]; self.set_from_ical(attr.lower(), ical_todo[attr]) for attr in list(set(ical_todo.multiple)): - if ical_todo.has_key(attr): + if attr in ical_todo: self.set_from_ical(attr.lower(), ical_todo[attr]) # although specified by RFC 2445/5545, icalendar doesn't have this property listed - if ical_todo.has_key('PERCENT-COMPLETE'): + if 'PERCENT-COMPLETE' in ical_todo: self.set_from_ical('percentcomplete', ical_todo['PERCENT-COMPLETE']) def _xml_from_ical(self, ical): @@ -122,16 +122,16 @@ params = {} _attachment = kolabformat.Attachment() - if params.has_key('FMTTYPE'): + if 'FMTTYPE' in params: mimetype = str(params['FMTTYPE']) else: mimetype = 'application/octet-stream' - if params.has_key('X-LABEL'): + if 'X-LABEL' in params: _attachment.setLabel(str(params['X-LABEL'])) decode = False - if params.has_key('ENCODING'): + if 'ENCODING' in params: if params['ENCODING'] == "BASE64" or params['ENCODING'] == "B": decode = True @@ -162,7 +162,7 @@ valid_datetime = True if not valid_datetime: - raise InvalidEventDateError, _("Todo due needs datetime.date or datetime.datetime instance") + raise InvalidEventDateError(_("Todo due needs datetime.date or datetime.datetime instance")) self.event.setDue(xmlutils.to_cdatetime(_datetime, True)) @@ -259,7 +259,7 @@ if error == None or not error: return xml else: - raise TodoIntegrityError, kolabformat.errorMessage() + raise TodoIntegrityError(kolabformat.errorMessage()) class TodoIntegrityError(Exception):
View file
pykolab-0.8.21.tar.gz/pykolab/xml/utils.py
Changed
@@ -158,7 +158,7 @@ """ Return a localized name for the given object property """ - return _(property_labels[propname]) if property_labels.has_key(propname) else _(propname) + return _(property_labels[propname]) if propname in property_labels else _(propname) def property_to_string(propname, value): @@ -186,18 +186,18 @@ if isinstance(value, dict): if propname == 'attendee': from . import attendee - name = value['name'] if value.has_key('name') and not value['name'] == '' else value['email'] + name = value['name'] if 'name' in value and not value['name'] == '' else value['email'] return "%s, %s" % (name, attendee.participant_status_label(value['partstat'])) elif propname == 'organizer': - return value['name'] if value.has_key('name') and not value['name'] == '' else value['email'] + return value['name'] if 'name' in value and not value['name'] == '' else value['email'] elif propname == 'rrule': from . import recurrence_rule rrule = recurrence_rule.frequency_label(value['freq']) % (value['interval']) - if value.has_key('count') and value['count'] > 0: + if 'count' in value and value['count'] > 0: rrule += " " + _("for %d times") % (value['count']) - elif value.has_key('until') and (isinstance(value['until'], datetime.datetime) or isinstance(value['until'], datetime.date)): + elif 'until' in value and (isinstance(value['until'], datetime.datetime) or isinstance(value['until'], datetime.date)): rrule += " " + _("until %s") % (value['until'].strftime(date_format)) return rrule @@ -235,7 +235,7 @@ return alarm elif propname == 'attach': - return value['label'] if value.has_key('label') else value['fmttype'] + return value['label'] if 'label' in value else value['fmttype'] return None @@ -247,11 +247,11 @@ diff = [] properties = a.keys() - properties.extend([x for x in b.keys() if x not in properties]) + properties.extend([x for x in b if x not in properties]) for prop in properties: - aa = a[prop] if a.has_key(prop) else None - bb = b[prop] if b.has_key(prop) else None + aa = a[prop] if prop in a else None + bb = b[prop] if prop in b else None # compare two lists if isinstance(aa, list) or isinstance(bb, list): @@ -338,8 +338,8 @@ # accept partial match if partial: - for k,v in aa.iteritems(): - if bb.has_key(k) and bb[k] == v: + for k,v in aa.items(): + if k in bb and bb[k] == v: return True return False @@ -355,10 +355,10 @@ return (aa, bb) properties = aa.keys() - properties.extend([x for x in bb.keys() if x not in properties]) + properties.extend([x for x in bb if x not in properties]) for prop in properties: - if not aa.has_key(prop) or not bb.has_key(prop): + if prop not in aa or prop not in bb: continue if isinstance(aa[prop], dict) and isinstance(bb[prop], dict): (aa[prop], bb[prop]) = reduce_properties(aa[prop], bb[prop])
View file
pykolab-0.8.21.tar.gz/saslauthd.py
Changed
@@ -18,6 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import logging import os import sys @@ -30,8 +32,8 @@ try: import pykolab.logger except ImportError as e: - print >> sys.stderr, _("Cannot load pykolab/logger.py:") - print >> sys.stderr, "%s" % e + print(_("Cannot load pykolab/logger.py:"), file=sys.stderr) + print("%s" % e, file=sys.stderr) sys.exit(1) import saslauthd
View file
pykolab-0.8.21.tar.gz/saslauthd/__init__.py
Changed
@@ -25,6 +25,7 @@ backend. """ +from __future__ import print_function from optparse import OptionParser from ConfigParser import SafeConfigParser @@ -105,7 +106,7 @@ conf.process_username, conf.process_groupname ) - except Exception, errmsg: + except Exception as errmsg: log.error(_("Could not create %r: %r") % (os.path.dirname(conf.pidfile), errmsg)) sys.exit(1) @@ -161,25 +162,27 @@ self.write_pid() self.do_saslauthd() - except SystemExit, e: + except SystemExit as e: exitcode = e except KeyboardInterrupt: exitcode = 1 log.info(_("Interrupted by user")) - except AttributeError, e: + except AttributeError: exitcode = 1 traceback.print_exc() - print >> sys.stderr, _("Traceback occurred, please report a " + - "bug at https://issues.kolab.org") - except TypeError, e: + print(_("Traceback occurred, please report a " + + "bug at https://issues.kolab.org"), + file=sys.stderr) + except TypeError as e: exitcode = 1 traceback.print_exc() log.error(_("Type Error: %s") % e) except: exitcode = 2 traceback.print_exc() - print >> sys.stderr, _("Traceback occurred, please report a " + - "bug at https://issues.kolab.org") + print(_("Traceback occurred, please report a " + + "bug at https://issues.kolab.org"), + file=sys.stderr) sys.exit(exitcode) @@ -204,7 +207,7 @@ pass s.bind(conf.socketfile) - os.chmod(conf.socketfile, 0777) + os.chmod(conf.socketfile, 0o777) s.listen(5) @@ -217,7 +220,7 @@ try: (clientsocket, address) = s.accept() bound = True - except Exception, errmsg: + except Exception as errmsg: log.error( _("kolab-saslauthd could not accept " + "connections on socket: %r") % (errmsg) @@ -309,7 +312,7 @@ try: (ruid, euid, suid) = os.getresuid() (rgid, egid, sgid) = os.getresgid() - except AttributeError, errmsg: + except AttributeError: ruid = os.getuid() rgid = os.getgid() @@ -326,9 +329,9 @@ ) = grp.getgrnam(conf.process_groupname) except KeyError: - print >> sys.stderr, _("Group %s does not exist") % ( + print(_("Group %s does not exist") % ( conf.process_groupname - ) + ), file=sys.stderr) sys.exit(1) @@ -357,9 +360,9 @@ ) = pwd.getpwnam(conf.process_username) except KeyError: - print >> sys.stderr, _("User %s does not exist") % ( + print(_("User %s does not exist") % ( conf.process_username - ) + ), file=sys.stderr) sys.exit(1)
View file
pykolab-0.8.21.tar.gz/setup-kolab.py
Changed
@@ -19,6 +19,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import logging import os import sys @@ -33,9 +35,9 @@ try: from pykolab.constants import * -except ImportError, e: - print >> sys.stderr, _("Cannot load pykolab/constants.py:") - print >> sys.stderr, "%s" % e +except ImportError as e: + print(_("Cannot load pykolab/constants.py:"), file=sys.stderr) + print("%s" % e, file=sys.stderr) sys.exit(1) if __name__ == "__main__":
View file
pykolab-0.8.21.tar.gz/tests/functional/resource_func.py
Changed
@@ -30,7 +30,7 @@ type_id = 0 resource_types = wap_client.resource_types_list() - for key in resource_types['list'].keys(): + for key in resource_types['list']: if resource_types['list'][key]['key'] == type: type_id = key @@ -41,7 +41,7 @@ params = {} - for attribute in resource_type_info['form_fields'].keys(): + for attribute in resource_type_info['form_fields']: attr_details = resource_type_info['form_fields'][attribute] if isinstance(attr_details, dict): @@ -53,7 +53,7 @@ fvg_params = params fvg_params['object_type'] = 'resource' fvg_params['type_id'] = type_id - fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'].keys() if attr not in params] + fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'] if attr not in params] result = wap_client.resource_add(params) result['dn'] = "cn=" + result['cn'] + ",ou=Resources,dc=example,dc=org"
View file
pykolab-0.8.21.tar.gz/tests/functional/test_kolabd/test_001_user_sync.py
Changed
@@ -89,7 +89,7 @@ folders = imap.lm('user/%(local)s/*@%(domain)s' % (self.user)) - self.assertEqual(len(folders), len(ac_folders.keys())) + self.assertEqual(len(folders), len(ac_folders)) def test_005_user_folders_metadata_set(self): imap = IMAP() @@ -104,12 +104,12 @@ for folder in folders: metadata = imap.get_metadata(folder) - print metadata + print(metadata) folder_name = '/'.join(folder.split('/')[2:]).split('@')[0] if folder_name in ac_folders: if 'annotations' in ac_folders[folder_name]: - for _annotation in ac_folders[folder_name]['annotations'].keys(): + for _annotation in ac_folders[folder_name]['annotations']: if _annotation.startswith('/private'): continue
View file
pykolab-0.8.21.tar.gz/tests/functional/test_kolabd/test_002_user_rename.py
Changed
@@ -61,7 +61,7 @@ time.sleep(2) - print imap.lm() + print(imap.lm()) user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') if not user_info['mail'] == 'joe.sixpack@example.org': @@ -71,7 +71,7 @@ self.assertEqual(user_info['mail'], 'joe.sixpack@example.org') - print imap.lm() + print(imap.lm()) folders = imap.lm('user/john.doe@example.org') self.assertEqual(len(folders), 0, "INBOX for john.doe still exists")
View file
pykolab-0.8.21.tar.gz/tests/functional/test_wallace/test_002_footer.py
Changed
@@ -276,7 +276,7 @@ script_str = script.__str__() - print script_str + print(script_str) sieveclient.putscript("test_wallace_test_009_forward", script_str)
View file
pykolab-0.8.21.tar.gz/tests/functional/test_wallace/test_006_resource_performance.py
Changed
@@ -138,5 +138,5 @@ res = module_resources.read_resource_calendar(self.room1, [itip]) self.assertEqual(res, num) - print "\nREAD TIME:", time.time() - start - print "CONFLICTS:", self.room1['conflicting_events'] + print("\nREAD TIME:", time.time() - start) + print("CONFLICTS:", self.room1['conflicting_events'])
View file
pykolab-0.8.21.tar.gz/tests/functional/test_wap_client/test_002_user_add.py
Changed
@@ -48,10 +48,10 @@ folders = imap.lm('user/%(local)s/*@%(domain)s' % (self.user)) - print folders - print ac_folders.keys() + print(folders) + print(ac_folders.keys()) - self.assertEqual(len(folders), len(ac_folders.keys())) + self.assertEqual(len(folders), len(ac_folders)) def test_003_folders_metadata_set(self): imap = IMAP()
View file
pykolab-0.8.21.tar.gz/tests/functional/test_wap_client/test_003_user_add_fr_FR.py
Changed
@@ -50,7 +50,7 @@ self.assertEqual(recipient, "uid=mehul,ou=People,dc=example,dc=org") result = wap_client.user_info(recipient) - print result + print(result) self.assertEqual(result['mail'], 'etienne-nicolas.mehul@example.org') self.assertEqual(sorted(result['alias']), ['e.mehul@example.org', 'mehul@example.org'])
View file
pykolab-0.8.21.tar.gz/tests/functional/user_add.py
Changed
@@ -32,7 +32,7 @@ user_types = wap_client.user_types_list() - for key in user_types['list'].keys(): + for key in user_types['list']: if user_types['list'][key]['key'] == 'kolab': user_type_id = key @@ -42,7 +42,7 @@ 'user_type_id': user_type_id, } - for attribute in user_type_info['form_fields'].keys(): + for attribute in user_type_info['form_fields']: attr_details = user_type_info['form_fields'][attribute] if isinstance(attr_details, dict): @@ -54,6 +54,6 @@ fvg_params = params fvg_params['object_type'] = 'user' fvg_params['type_id'] = user_type_id - fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'].keys() if attr not in params] + fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'] if attr not in params] result = wap_client.user_add(params)
View file
pykolab-0.8.21.tar.gz/tests/unit/test-002-attendee.py
Changed
@@ -34,7 +34,7 @@ self.assertEqual(self.attendee.get_participant_status(), 0) def test_005_participant_status_map_length(self): - self.assertEqual(len(self.attendee.participant_status_map.keys()), 7) + self.assertEqual(len(self.attendee.participant_status_map), 7) def test_006_participant_status_map_forward_lookup(self): # Forward lookups @@ -48,19 +48,19 @@ def test_007_participant_status_map_reverse_lookup(self): # Reverse lookups - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 0][0], "NEEDS-ACTION") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 1][0], "ACCEPTED") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 2][0], "DECLINED") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 3][0], "TENTATIVE") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 4][0], "DELEGATED") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 5][0], "IN-PROCESS") - self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 6][0], "COMPLETED") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 0][0], "NEEDS-ACTION") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 1][0], "ACCEPTED") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 2][0], "DECLINED") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 3][0], "TENTATIVE") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 4][0], "DELEGATED") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 5][0], "IN-PROCESS") + self.assertEqual([k for k, v in self.attendee.participant_status_map.items() if v == 6][0], "COMPLETED") def test_008_default_rsvp(self): self.assertEqual(self.attendee.get_rsvp(), 0) def test_009_rsvp_map_length(self): - self.assertEqual(len(self.attendee.rsvp_map.keys()), 2) + self.assertEqual(len(self.attendee.rsvp_map), 2) def test_010_rsvp_map_forward_lookup_boolean(self): self.assertEqual(self.attendee.rsvp_map["TRUE"], True) @@ -71,18 +71,18 @@ self.assertEqual(self.attendee.rsvp_map["FALSE"], 0) def test_012_rsvp_map_reverse_lookup_boolean(self): - self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v is True][0], "TRUE") - self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v is False][0], "FALSE") + self.assertEqual([k for k, v in self.attendee.rsvp_map.items() if v is True][0], "TRUE") + self.assertEqual([k for k, v in self.attendee.rsvp_map.items() if v is False][0], "FALSE") def test_013_rsvp_map_reverse_lookup_integer(self): - self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v == 1][0], "TRUE") - self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v == 0][0], "FALSE") + self.assertEqual([k for k, v in self.attendee.rsvp_map.items() if v == 1][0], "TRUE") + self.assertEqual([k for k, v in self.attendee.rsvp_map.items() if v == 0][0], "FALSE") def test_014_default_role(self): self.assertEqual(self.attendee.get_role(), 0) def test_015_role_map_length(self): - self.assertEqual(len(self.attendee.role_map.keys()), 4) + self.assertEqual(len(self.attendee.role_map), 4) def test_016_role_map_forward_lookup(self): self.assertEqual(self.attendee.role_map["REQ-PARTICIPANT"], 0) @@ -91,13 +91,13 @@ self.assertEqual(self.attendee.role_map["NON-PARTICIPANT"], 3) def test_017_role_map_reverse_lookup(self): - self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 0][0], "REQ-PARTICIPANT") - self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 1][0], "CHAIR") - self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 2][0], "OPT-PARTICIPANT") - self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 3][0], "NON-PARTICIPANT") + self.assertEqual([k for k, v in self.attendee.role_map.items() if v == 0][0], "REQ-PARTICIPANT") + self.assertEqual([k for k, v in self.attendee.role_map.items() if v == 1][0], "CHAIR") + self.assertEqual([k for k, v in self.attendee.role_map.items() if v == 2][0], "OPT-PARTICIPANT") + self.assertEqual([k for k, v in self.attendee.role_map.items() if v == 3][0], "NON-PARTICIPANT") def test_015_cutype_map_length(self): - self.assertEqual(len(self.attendee.cutype_map.keys()), 5) + self.assertEqual(len(self.attendee.cutype_map), 5) def test_016_cutype_map_forward_lookup(self): self.assertEqual(self.attendee.cutype_map["GROUP"], kolabformat.CutypeGroup) @@ -107,11 +107,11 @@ self.assertEqual(self.attendee.cutype_map["UNKNOWN"], kolabformat.CutypeUnknown) def test_017_cutype_map_reverse_lookup(self): - self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeGroup][0], "GROUP") - self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeIndividual][0], "INDIVIDUAL") - self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeResource][0], "RESOURCE") - self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeRoom][0], "ROOM") - self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeUnknown][0], "UNKNOWN") + self.assertEqual([k for k, v in self.attendee.cutype_map.items() if v == kolabformat.CutypeGroup][0], "GROUP") + self.assertEqual([k for k, v in self.attendee.cutype_map.items() if v == kolabformat.CutypeIndividual][0], "INDIVIDUAL") + self.assertEqual([k for k, v in self.attendee.cutype_map.items() if v == kolabformat.CutypeResource][0], "RESOURCE") + self.assertEqual([k for k, v in self.attendee.cutype_map.items() if v == kolabformat.CutypeRoom][0], "ROOM") + self.assertEqual([k for k, v in self.attendee.cutype_map.items() if v == kolabformat.CutypeUnknown][0], "UNKNOWN") def test_018_partstat_label(self): self.assertEqual(participant_status_label('NEEDS-ACTION'), "Needs Action")
View file
pykolab-0.8.21.tar.gz/tests/unit/test-003-event.py
Changed
@@ -460,7 +460,7 @@ self.assertIsInstance(_tz.tzinfo, datetime.tzinfo) def test_016_start_with_timezone(self): - _start = datetime.datetime(2012, 05, 23, 11, 58, 00, tzinfo=pytz.timezone("Europe/Zurich")) + _start = datetime.datetime(2012, 5, 23, 11, 58, 00, tzinfo=pytz.timezone("Europe/Zurich")) _start_utc = _start.astimezone(pytz.utc) # self.assertEqual(_start.__str__(), "2012-05-23 11:58:00+01:00") # self.assertEqual(_start_utc.__str__(), "2012-05-23 10:58:00+00:00") @@ -469,7 +469,7 @@ self.assertEqual(_start.tzinfo, pytz.timezone("Europe/Zurich")) def test_017_allday_without_timezone(self): - _start = datetime.date(2012, 05, 23) + _start = datetime.date(2012, 5, 23) self.assertEqual(_start.__str__(), "2012-05-23") self.event.set_start(_start) self.assertEqual(hasattr(_start, 'tzinfo'), False) @@ -553,12 +553,12 @@ def test_019_as_string_itip(self): self.event.set_summary("test") - self.event.set_start(datetime.datetime(2014, 05, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) - self.event.set_end(datetime.datetime(2014, 05, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_start(datetime.datetime(2014, 5, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_end(datetime.datetime(2014, 5, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) self.event.set_sequence(3) self.event.set_classification('CONFIDENTIAL') self.event.add_custom_property('X-Custom', 'check') - self.event.set_recurrence_id(datetime.datetime(2014, 05, 23, 11, 0, 0), True) + self.event.set_recurrence_id(datetime.datetime(2014, 5, 23, 11, 0, 0), True) rrule = RecurrenceRule() rrule.set_frequency(kolabformat.RecurrenceRule.Weekly) @@ -592,8 +592,8 @@ def test_019_to_message_itip(self): self.event = Event() self.event.set_summary("test") - self.event.set_start(datetime.datetime(2014, 05, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) - self.event.set_end(datetime.datetime(2014, 05, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_start(datetime.datetime(2014, 5, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_end(datetime.datetime(2014, 5, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) self.event.set_organizer("me@kolab.org") self.event.add_attendee("john@doe.org") self.event.add_attendee("jane@doe.org") @@ -742,17 +742,17 @@ def test_021_ical_exceptions(self): self.event.set_summary("test") - self.event.set_start(datetime.datetime(2014, 05, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) - self.event.set_end(datetime.datetime(2014, 05, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_start(datetime.datetime(2014, 5, 23, 11, 00, 00, tzinfo=pytz.timezone("Europe/London"))) + self.event.set_end(datetime.datetime(2014, 5, 23, 12, 30, 00, tzinfo=pytz.timezone("Europe/London"))) rrule = kolabformat.RecurrenceRule() rrule.setFrequency(kolabformat.RecurrenceRule.Weekly) self.event.set_recurrence(rrule) xmlexception = Event(from_string=str(self.event)) - xmlexception.set_start(datetime.datetime(2014, 05, 30, 14, 00, 00, tzinfo=pytz.timezone("Europe/London"))) - xmlexception.set_end(datetime.datetime(2014, 05, 30, 16, 00, 00, tzinfo=pytz.timezone("Europe/London"))) - xmlexception.set_recurrence_id(datetime.datetime(2014, 05, 30, 11, 0, 0), False) + xmlexception.set_start(datetime.datetime(2014, 5, 30, 14, 00, 00, tzinfo=pytz.timezone("Europe/London"))) + xmlexception.set_end(datetime.datetime(2014, 5, 30, 16, 00, 00, tzinfo=pytz.timezone("Europe/London"))) + xmlexception.set_recurrence_id(datetime.datetime(2014, 5, 30, 11, 0, 0), False) self.event.add_exception(xmlexception) ical = icalendar.Calendar.from_ical(self.event.as_string_itip())
View file
pykolab-0.8.21.tar.gz/tests/unit/test-008-sievelib.py
Changed
@@ -53,5 +53,5 @@ i += 1 result = sieve_parser.parse(sieve_str) if not result: - print "Sieve line: %r" % (sieve_parser.lexer.text.split('\n')[(sieve_parser.lexer.text[:sieve_parser.lexer.pos].count('\n'))]) + print("Sieve line: %r" % (sieve_parser.lexer.text.split('\n')[(sieve_parser.lexer.text[:sieve_parser.lexer.pos].count('\n'))])) raise Exception("Failed parsing Sieve script #%d: %s" % (i, sieve_parser.error))
View file
pykolab-0.8.21.tar.gz/ucs/kolab_sieve.py
Changed
@@ -77,10 +77,10 @@ new = utils.normalize(args[1]) old = utils.normalize(args[2]) - if isinstance(old, dict) and len(old.keys()) > 0: + if isinstance(old, dict) and len(old) > 0: # Either the entry changed or was deleted - if isinstance(new, dict) and len(new.keys()) > 0: + if isinstance(new, dict) and len(new) > 0: # The entry was modified. result_attr = conf.get('cyrus-sasl', 'result_attribute') @@ -128,7 +128,7 @@ # Sieve Script Management return - elif isinstance(new, dict) and len(new.keys()) > 0: + elif isinstance(new, dict) and len(new) > 0: # Old is not a dict (or empty), so the entry is just created # See if the mailserver_attribute exists
View file
pykolab-0.8.21.tar.gz/ucs/listener.py
Changed
@@ -83,13 +83,13 @@ new = utils.normalize(args[1]) old = utils.normalize(args[2]) - if isinstance(old, dict) and len(old.keys()) > 0: + if isinstance(old, dict) and len(old) > 0: # Two options: # - entry changed # - entry deleted log.info("user %r, old is dict" % (dn)) - if isinstance(new, dict) and len(new.keys()) > 0: + if isinstance(new, dict) and len(new) > 0: log.info("Modify entry %r" % (dn)) mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower() @@ -160,7 +160,7 @@ entry=old ) - elif isinstance(new, dict) and len(new.keys()) > 0: + elif isinstance(new, dict) and len(new) > 0: # Old is not a dict (or empty), so the entry is just created log.info("Add entry %r" % (dn))
View file
pykolab-0.8.21.tar.gz/wallace.py
Changed
@@ -18,6 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + import sys # For development purposes @@ -27,9 +29,9 @@ try: from pykolab.constants import * -except ImportError, e: - print >> sys.stderr, _("Cannot load pykolab/constants.py:") - print >> sys.stderr, "%s" % e +except ImportError as e: + print(_("Cannot load pykolab/constants.py:"), file=sys.stderr) + print("%s" % e, file=sys.stderr) sys.exit(1) import wallace
View file
pykolab-0.8.21.tar.gz/wallace/module_gpgencrypt.py
Changed
@@ -102,7 +102,7 @@ if not os.path.isdir(os.path.join(mybasepath, stage)): os.makedirs(os.path.join(mybasepath, stage)) - if kw.has_key('stage'): + if 'stage' in kw: log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) if hasattr(modules, 'cb_action_%s' % (kw['stage'])): @@ -286,7 +286,7 @@ os.unlink(filepath) exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','gpgencrypt', new_filepath)) - except Exception, errmsg: + except Exception as errmsg: log.error(_("An error occurred: %r") % (errmsg)) if conf.debuglevel > 8: import traceback
View file
pykolab-0.8.21.tar.gz/wallace/module_invitationpolicy.py
Changed
@@ -138,7 +138,7 @@ 'ACT_SAVE_AND_FORWARD': ACT_SAVE_AND_FORWARD + COND_TYPE_EVENT, } -policy_value_map = dict([(v &~ COND_TYPE_ALL, k) for (k, v) in policy_name_map.iteritems()]) +policy_value_map = dict([(v &~ COND_TYPE_ALL, k) for (k, v) in policy_name_map.items()]) object_type_conditons = { 'event': COND_TYPE_EVENT, @@ -227,12 +227,12 @@ imap = IMAP() # ignore calls on lock files - if '/locks/' in filepath or kw.has_key('stage') and kw['stage'] == 'locks': + if '/locks/' in filepath or 'stage' in kw and kw['stage'] == 'locks': return False log.debug("Invitation policy executing for %r, %r" % (filepath, '/locks/' in filepath), level=8) - if kw.has_key('stage'): + if 'stage' in kw: log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) @@ -280,7 +280,7 @@ # is an iTip message by checking the length of this list. try: itip_events = objects_from_message(message, ['VEVENT','VTODO'], ['REQUEST', 'REPLY', 'CANCEL']) - except Exception, errmsg: + except Exception as errmsg: log.error(_("Failed to parse iTip objects from message: %r" % (errmsg))) itip_events = [] @@ -292,7 +292,7 @@ log.debug(_("iTip objects attached to this message contain the following information: %r") % (itip_events), level=8) # See if any iTip actually allocates a user. - if any_itips and len([x['uid'] for x in itip_events if x.has_key('attendees') or x.has_key('organizer')]) > 0: + if any_itips and len([x['uid'] for x in itip_events if 'attendees' in x or 'organizer' in x]) > 0: auth.connect() # we're looking at the first itip object @@ -329,7 +329,7 @@ # for replies, the organizer is the recipient if itip_event['method'] == 'REPLY': # Outlook can send iTip replies without an organizer property - if itip_event.has_key('organizer'): + if 'organizer' in itip_event: organizer_mailto = str(itip_event['organizer']).split(':')[-1] user_attendees = [organizer_mailto] if organizer_mailto in recipient_emails else [] else: @@ -337,10 +337,10 @@ else: # Limit the attendees to the one that is actually invited with the current message. - attendees = [str(a).split(':')[-1] for a in (itip_event['attendees'] if itip_event.has_key('attendees') else [])] + attendees = [str(a).split(':')[-1] for a in (itip_event['attendees'] if 'attendees' in itip_event else [])] user_attendees = [a for a in attendees if a in recipient_emails] - if itip_event.has_key('organizer'): + if 'organizer' in itip_event: sender_email = itip_event['xml'].get_organizer().email() # abort if no attendee matches the envelope recipient @@ -354,7 +354,7 @@ recipient_email = user_attendees[0] # change gettext language to the preferredlanguage setting of the receiving user - if receiving_user.has_key('preferredlanguage'): + if 'preferredlanguage' in receiving_user: pykolab.translate.setUserLanguage(receiving_user['preferredlanguage']) # find user's kolabInvitationPolicy settings and the matching policy values @@ -369,7 +369,7 @@ } done = None - if method_processing_map.has_key(itip_event['method']): + if itip_event['method'] in method_processing_map: processor_func = method_processing_map[itip_event['method']] # connect as cyrus-admin @@ -413,7 +413,7 @@ try: receiving_attendee = itip_event['xml'].get_attendee_by_email(recipient_email) log.debug(_("Receiving attendee: %r") % (receiving_attendee.to_dict()), level=8) - except Exception, errmsg: + except Exception as errmsg: log.error("Could not find envelope attendee: %r" % (errmsg)) return MESSAGE_FORWARD @@ -486,7 +486,7 @@ # if RSVP, send an iTip REPLY if rsvp or scheduling_required: # set attendee's CN from LDAP record if yet missing - if not receiving_attendee.get_name() and receiving_user.has_key('cn'): + if not receiving_attendee.get_name() and 'cn' in receiving_user: receiving_attendee.set_name(receiving_user['cn']) # send iTip reply @@ -542,7 +542,7 @@ try: sender_attendee = itip_event['xml'].get_attendee_by_email(sender_email) log.debug(_("Sender Attendee: %r") % (sender_attendee), level=8) - except Exception, errmsg: + except Exception as errmsg: log.error("Could not find envelope sender attendee: %r" % (errmsg)) return MESSAGE_FORWARD @@ -565,7 +565,7 @@ existing.set_attendee_participant_status(sender_email, sender_attendee.get_participant_status(), rsvp=False) existing_attendee = existing.get_attendee(sender_email) updated_attendees.append(existing_attendee) - except Exception, errmsg: + except Exception as errmsg: log.error("Could not find corresponding attende in organizer's copy: %r" % (errmsg)) # append delegated-from attendee ? @@ -598,7 +598,7 @@ existing.update_attendees([existing_attendee]) log.debug(_("Update delegator: %r") % (existing_attendee.to_dict()), level=8) - except Exception, errmsg: + except Exception as errmsg: log.error("Could not find delegated-to attendee: %r" % (errmsg)) # update the organizer's copy of the object @@ -693,7 +693,7 @@ auth.connect() # return cached value - if user_dn_from_email_address.cache.has_key(email_address): + if email_address in user_dn_from_email_address.cache: return user_dn_from_email_address.cache[email_address] local_domains = auth.list_domains() @@ -724,7 +724,7 @@ def get_matching_invitation_policies(receiving_user, sender_email, type_condition=COND_TYPE_ALL): # get user's kolabInvitationPolicy settings - policies = receiving_user['kolabinvitationpolicy'] if receiving_user.has_key('kolabinvitationpolicy') else [] + policies = receiving_user['kolabinvitationpolicy'] if 'kolabinvitationpolicy' in receiving_user else [] if policies and not isinstance(policies, list): policies = [policies] @@ -742,7 +742,7 @@ if domain == '' or domain == '*' or str(sender_email).endswith(domain): value = value.upper() - if policy_name_map.has_key(value): + if value in policy_name_map: val = policy_name_map[value] # append if type condition matches if val & type_condition: @@ -767,7 +767,7 @@ mail_attribute = mail_attribute.lower() - if not user_rec.has_key(mail_attribute): + if mail_attribute not in user_rec: log.error(_("User record doesn't have the mailbox attribute %r set" % (mail_attribute))) return False @@ -780,7 +780,7 @@ imap.disconnect() imap.connect(login=False) imap.login_plain(admin_login, admin_password, user_rec[mail_attribute]) - except Exception, errmsg: + except Exception as errmsg: log.error(_("IMAP proxy authentication failed: %r") % (errmsg)) return False @@ -910,7 +910,7 @@ try: msguid = re.search(r"\WUID (\d+)", data[0][0]).group(1) - except Exception, errmsg: + except Exception: log.error(_("No UID found in IMAP response: %r") % (data[0][0])) continue @@ -936,7 +936,7 @@ setattr(event, '_lock_key', lock_key) setattr(event, '_msguid', msguid) - except Exception, errmsg: + except Exception: log.error(_("Failed to parse %s from message %s/%s: %s") % (type, folder, num, traceback.format_exc())) event = None master = None @@ -961,7 +961,7 @@ conflict = False # return previously detected conflict - if itip_event.has_key('_conflicts'): + if '_conflicts' in itip_event: return not itip_event['_conflicts'] for folder in list_user_folders(receiving_user, 'event'): @@ -977,7 +977,7 @@ try: event = event_from_message(message_from_string(data[0][1])) - except Exception, errmsg: + except Exception as errmsg: log.error(_("Failed to parse event from message %s/%s: %r") % (folder, num, errmsg)) continue @@ -1087,12 +1087,12 @@ oc = object.get_classification() # use *.confidential/private folder for confidential/private invitations - if oc == kolabformat.ClassConfidential and user_rec.has_key('_confidential_folder'): + if oc == kolabformat.ClassConfidential and '_confidential_folder' in user_rec: targetfolder = user_rec['_confidential_folder'] - elif oc == kolabformat.ClassPrivate and user_rec.has_key('_private_folder'): + elif oc == kolabformat.ClassPrivate and '_private_folder' in user_rec: targetfolder = user_rec['_private_folder'] # use *.default folder if exists - elif user_rec.has_key('_default_folder'): + elif '_default_folder' in user_rec: targetfolder = user_rec['_default_folder'] # fallback to any existing folder of specified type elif targetfolders is not None and len(targetfolders) > 0: @@ -1122,7 +1122,7 @@ ) return result - except Exception, errmsg: + except Exception as errmsg: log.error(_("Failed to save %s to user folder at %r: %r") % ( saveobj.type, targetfolder, errmsg )) @@ -1160,7 +1160,7 @@ imap.imap.m.expunge() return True - except Exception, errmsg: + except Exception as errmsg: log.error(_("Failed to delete %s from folder %r: %r") % ( existing.type, targetfolder, errmsg )) @@ -1205,7 +1205,7 @@ for attendee in object.get_attendees(): parstat = attendee.get_participant_status(True) - if partstats.has_key(parstat): + if parstat in partstats: partstats[parstat].append(attendee.get_displayname()) else: partstats['PENDING'].append(attendee.get_displayname()) @@ -1243,7 +1243,7 @@ if itip_comment is not None: roundup += "\n" + itip_comment - for status,attendees in partstats.iteritems(): + for status,attendees in partstats.items(): if len(attendees) > 0: roundup += "\n" + participant_status_label(status) + ":\n\t" + "\n\t".join(attendees) + "\n" else:
View file
pykolab-0.8.21.tar.gz/wallace/module_optout.py
Changed
@@ -57,7 +57,7 @@ # TODO: Test for correct call. filepath = args[0] - if kw.has_key('stage'): + if 'stage' in kw: log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) if hasattr(modules, 'cb_action_%s' % (kw['stage'])): @@ -90,7 +90,7 @@ "Cc": [] } - for recipient_type in recipients.keys(): + for recipient_type in recipients: for recipient in recipients[recipient_type]: log.debug( _("Running opt-out consult from envelope sender '%s " + \ @@ -136,7 +136,7 @@ use_this = False - for recipient_type in _recipients[answer].keys(): + for recipient_type in _recipients[answer]: _message.__delitem__(recipient_type) if not len(_recipients[answer][recipient_type]) == 0: _message.__setitem__( @@ -177,7 +177,7 @@ try: f = urllib.urlopen(optout_url, params) - except Exception, e: + except Exception: log.error(_("Could not send request to optout_url %s") % (optout_url)) return "DEFER" @@ -185,8 +185,8 @@ try: response_data = json.loads(response) - except ValueError, e: + except ValueError: # Some data is not JSON - print "Response data is not JSON" + print("Response data is not JSON") return response_data['result']
View file
pykolab-0.8.21.tar.gz/wallace/module_resources.py
Changed
@@ -708,7 +708,7 @@ num_messages = 0 available_resource = None - for resource in resources.keys(): + for resource in resources: # skip this for resource collections if 'kolabtargetfolder' not in resources[resource]: continue
View file
pykolab-0.8.21.tar.gz/wallace/module_signature.py
Changed
@@ -163,7 +163,7 @@ if not signature_html and not signature_text and signature_rules is not None: for signature_rule in signature_rules: try: - for attr, regex in signature_rule.iteritems(): + for attr, regex in signature_rule.items(): if attr == "html": if not os.path.exists(signature_rule['html']): raise ValueError
View file
pykolab-0.8.21.tar.gz/wallace/modules.py
Changed
@@ -78,7 +78,7 @@ __modules = {} - for module in modules.keys(): + for module in modules: if isinstance(module, tuple): module_group, module = module __modules[module_group] = { @@ -133,10 +133,10 @@ log.exception(_("Module %r - Unknown error occurred; %r") % (name, errmsg)) def heartbeat(name, *args, **kw): - if not modules.has_key(name): + if name not in modules: log.warning(_("No such module %r in modules %r (1).") % (name, modules)) - if modules[name].has_key('heartbeat'): + if 'heartbeat' in modules[name]: return modules[name]['heartbeat'](*args, **kw) def _sendmail(sender, recipients, msg): @@ -426,7 +426,7 @@ if isinstance(aliases, basestring): aliases = [aliases] - if modules.has_key(module): + if module in modules: log.fatal(_("Module '%s' already registered") % (module)) sys.exit(1)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.