summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorChristoph Erhardt <kolab@sicherha.de>2022-08-12 09:56:45 +0200
committerChristoph Erhardt <kolab@sicherha.de>2022-08-12 09:57:00 +0200
commite02d1240e6586d2950a3f8ad760b2225af07d0ad (patch)
tree0e77fb69f00e4f31e08e84126a9ae6dc0a8c737e /pykolab
parent289cf24e653f3186fb8066b7f8c0e8822601af42 (diff)
downloadpykolab-e02d1240e6586d2950a3f8ad760b2225af07d0ad.tar.gz
[Python 3]exec to eval where exec(" var = ...")
Summary: All exec() with (var = ...) exec() with (import ... ) or with (self.var = ..) or just with (function()) should work out of the box. If not worked as expected, they could be grouped and put into other diff s. Reviewers: #pykolab_developers, sicherha Reviewed By: #pykolab_developers, sicherha Differential Revision: https://git.kolab.org/D3638
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/conf/__init__.py8
-rw-r--r--pykolab/imap/__init__.py2
-rw-r--r--pykolab/plugins/__init__.py4
-rw-r--r--pykolab/plugins/defaultfolders/__init__.py2
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py6
-rw-r--r--pykolab/wap_client/__init__.py4
6 files changed, 13 insertions, 13 deletions
diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py
index ca19ac9..eb56bf9 100644
--- a/pykolab/conf/__init__.py
+++ b/pykolab/conf/__init__.py
@@ -171,7 +171,7 @@ class Conf(object):
value = eval(config.get(section, key))
if hasattr(self, "check_setting_%s_%s" % (section, key)):
- exec("retval = self.check_setting_%s_%s(%r)" % (section, key, value))
+ retval = eval("self.check_setting_%s_%s(%r)" % (section, key, value))
if not retval:
# We just don't set it, check_setting_%s should have
# taken care of the error messages
@@ -243,7 +243,7 @@ class Conf(object):
value = eval(config.get('testing', key))
if hasattr(self, "check_setting_%s_%s" % ('testing', key)):
- exec("retval = self.check_setting_%s_%s(%r)" % ('testing', key, value))
+ retval = eval("self.check_setting_%s_%s(%r)" % ('testing', key, value))
if not retval:
# We just don't set it, check_setting_%s should have
# taken care of the error messages
@@ -466,7 +466,7 @@ class Conf(object):
Pass me a section and key please.
"""
- exec("args = %r" % args)
+ args = eval("%r" % args)
print("%s/%s: %r" % (args[0], args[1], self.get(args[0], args[1])))
@@ -626,7 +626,7 @@ class Conf(object):
if hasattr(self, "get_%s_%s" % (section, key)):
try:
- exec("retval = self.get_%s_%s(quiet)" % (section, key))
+ retval = eval("self.get_%s_%s(quiet)" % (section, key))
except Exception:
log.error(
_("Could not execute configuration function: %s") % (
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index a773bfc..eb9acea 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -924,7 +924,7 @@ class IMAP(object):
old_acls = None
for acl in acls:
- exec("acl = %s" % (acl))
+ acl = eval("%s" % (acl))
subject = acl[0]
rights = acl[1]
if len(acl) == 3:
diff --git a/pykolab/plugins/__init__.py b/pykolab/plugins/__init__.py
index 96e0044..ab110fb 100644
--- a/pykolab/plugins/__init__.py
+++ b/pykolab/plugins/__init__.py
@@ -204,7 +204,7 @@ class KolabPlugins(object):
continue
if hasattr(getattr(self, plugin), "%s_%s" % (func, option)):
- exec("retval = getattr(self, plugin).%s_%s(val)" % (func, option))
+ retval = eval("getattr(self, plugin).%s_%s(val)" % (func, option))
return retval
return False
@@ -261,7 +261,7 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), bool):
try:
- exec("boolval = self.%s.%s" % (plugin, bool))
+ boolval = eval("self.%s.%s" % (plugin, bool))
except AttributeError:
pass
else:
diff --git a/pykolab/plugins/defaultfolders/__init__.py b/pykolab/plugins/defaultfolders/__init__.py
index a4a59b0..cfa6d28 100644
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -48,7 +48,7 @@ class KolabDefaultfolders(object):
return {}
try:
- exec("additional_folders = %s" % (kw['additional_folders']))
+ additional_folders = eval("%s" % (kw['additional_folders']))
except Exception:
log.error(_("Could not parse additional_folders"))
return {}
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 330ddfa..da1db06 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -111,7 +111,7 @@ class KolabRecipientpolicy(object):
user_attrs['preferredlanguage'] = default_locale
try:
- exec("alternative_mail_routines = %s" % kw['secondary_mail'])
+ alternative_mail_routines = eval("%s" % kw['secondary_mail'])
except Exception:
log.error(_("Could not parse the alternative mail routines"))
@@ -133,7 +133,7 @@ class KolabRecipientpolicy(object):
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))
+ retval = eval("'%s'.%s" % (routine, alternative_mail_routines[number][routine] % user_attrs))
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
@@ -148,7 +148,7 @@ class KolabRecipientpolicy(object):
for _domain in kw['secondary_domains']:
user_attrs['domain'] = _domain
try:
- exec("retval = '%s'.%s" % (routine,alternative_mail_routines[number][routine] % user_attrs))
+ retval = eval("'%s'.%s" % (routine, alternative_mail_routines[number][routine] % user_attrs))
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 176ac91..4ab941d 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -223,7 +223,7 @@ def get_group_input():
params[attribute] = utils.ask_question(attribute)
for attribute in group_type_info['auto_form_fields']:
- exec("retval = group_form_value_generate_%s(params)" % (attribute))
+ retval = eval("group_form_value_generate_%s(params)" % (attribute))
params[attribute] = retval[attribute]
return params
@@ -309,7 +309,7 @@ def get_user_input():
for attribute in user_type_info['fields']:
params[attribute] = user_type_info['fields'][attribute]
- exec("retval = user_form_value_generate(params)")
+ retval = eval("user_form_value_generate(params)")
print(retval)
return params