mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib: Move find_modules_in_dir from util to plugable
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
parent
fe2accf776
commit
7715d5bb04
@ -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:
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user