loaded_base_name and mod_type_check default to None and in that case, to what's defined for salt.

This commit is contained in:
Pedro Algarvio 2013-04-18 03:40:13 +01:00
parent ad94c1b550
commit c9ad4e7ca8

View File

@ -27,8 +27,8 @@ def _create_loader(
ext_dirs=True, ext_dirs=True,
ext_type_dirs=None, ext_type_dirs=None,
base_path=None, base_path=None,
loaded_base_name=LOADED_BASE_NAME, loaded_base_name=None,
mod_type_check=_mod_type): mod_type_check=None):
''' '''
Creates Loader instance Creates Loader instance
@ -64,6 +64,12 @@ def _create_loader(
if (os.path.isdir(maybe_dir)): if (os.path.isdir(maybe_dir)):
cli_module_dirs.insert(0, maybe_dir) cli_module_dirs.insert(0, maybe_dir)
if loaded_base_name is None:
loaded_base_name = LOADED_BASE_NAME
if mod_type_check is None:
mod_type_check = _mod_type
module_dirs = cli_module_dirs + ext_type_types + [ext_types, sys_types] module_dirs = cli_module_dirs + ext_type_types + [ext_types, sys_types]
_generate_module('{0}.int'.format(loaded_base_name)) _generate_module('{0}.int'.format(loaded_base_name))
_generate_module('{0}.int.{1}'.format(loaded_base_name, tag)) _generate_module('{0}.int.{1}'.format(loaded_base_name, tag))
@ -317,7 +323,7 @@ class Loader(object):
call modules in an arbitrary directory directly. call modules in an arbitrary directory directly.
''' '''
def __init__(self, module_dirs, opts=dict(), tag='module', def __init__(self, module_dirs, opts=dict(), tag='module',
loaded_base_name=LOADED_BASE_NAME, mod_type_check=_mod_type): loaded_base_name=None, mod_type_check=None):
self.module_dirs = module_dirs self.module_dirs = module_dirs
if '_' in tag: if '_' in tag:
raise LoaderError('Cannot tag loader with an "_"') raise LoaderError('Cannot tag loader with an "_"')
@ -331,8 +337,8 @@ class Loader(object):
else: else:
self.pillar = {} self.pillar = {}
self.opts = self.__prep_mod_opts(opts) self.opts = self.__prep_mod_opts(opts)
self.loaded_base_name = loaded_base_name self.loaded_base_name = loaded_base_name or LOADED_BASE_NAME
self.mod_type_check = mod_type_check self.mod_type_check = mod_type_check or _mod_type
def __prep_mod_opts(self, opts): def __prep_mod_opts(self, opts):
''' '''