summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-15 10:53:22 +0000
committerJan Cholasta <jcholast@redhat.com>2015-07-01 13:05:30 +0000
commit7715d5bb044f891dcf420f230726b72d1695edb6 (patch)
treef7a814c48a333d4e254f7d6ec4fd16660bd9a13e
parentfe2accf77663693628835d7063da7d871b1ad268 (diff)
downloadfreeipa-7715d5bb044f891dcf420f230726b72d1695edb6.zip
freeipa-7715d5bb044f891dcf420f230726b72d1695edb6.tar.gz
freeipa-7715d5bb044f891dcf420f230726b72d1695edb6.tar.xz
ipalib: Move find_modules_in_dir from util to plugable
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
-rw-r--r--ipalib/plugable.py25
-rw-r--r--ipalib/util.py22
2 files changed, 23 insertions, 24 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index ad662e5..74ac62b 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -38,7 +38,6 @@ import textwrap
import collections
from config import Env
-import util
import text
from text import _
from base import ReadOnly, NameSpace, lock, islocked, check_name
@@ -61,6 +60,28 @@ def is_production_mode(obj):
return obj.env.mode == 'production'
+# FIXME: This function has no unit test
+def find_modules_in_dir(src_dir):
+ """
+ Iterate through module names found in ``src_dir``.
+ """
+ if not (os.path.abspath(src_dir) == src_dir and os.path.isdir(src_dir)):
+ return
+ if os.path.islink(src_dir):
+ return
+ suffix = '.py'
+ for name in sorted(os.listdir(src_dir)):
+ if not name.endswith(suffix):
+ continue
+ pyfile = os.path.join(src_dir, name)
+ if not os.path.isfile(pyfile):
+ continue
+ module = name[:-len(suffix)]
+ if module == '__init__':
+ continue
+ yield (module, pyfile)
+
+
class Registry(object):
"""A decorator that makes plugins available to the API
@@ -625,7 +646,7 @@ class API(DictProxy):
name=subpackage, file=plugins.__file__
)
self.log.debug('importing all plugin modules in %r...', plugins_dir)
- for (name, pyfile) in util.find_modules_in_dir(plugins_dir):
+ for (name, pyfile) in find_modules_in_dir(plugins_dir):
fullname = '%s.%s' % (subpackage, name)
self.log.debug('importing plugin module %r', pyfile)
try:
diff --git a/ipalib/util.py b/ipalib/util.py
index 7579722..649a487 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -76,28 +76,6 @@ def get_current_principal():
raise errors.CCacheError()
-# FIXME: This function has no unit test
-def find_modules_in_dir(src_dir):
- """
- Iterate through module names found in ``src_dir``.
- """
- if not (os.path.abspath(src_dir) == src_dir and os.path.isdir(src_dir)):
- return
- if os.path.islink(src_dir):
- return
- suffix = '.py'
- for name in sorted(os.listdir(src_dir)):
- if not name.endswith(suffix):
- continue
- pyfile = os.path.join(src_dir, name)
- if not os.path.isfile(pyfile):
- continue
- module = name[:-len(suffix)]
- if module == '__init__':
- continue
- yield (module, pyfile)
-
-
def validate_host_dns(log, fqdn):
"""
See if the hostname has a DNS A/AAAA record.