diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-20 16:39:09 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-20 16:39:09 -0700 |
commit | f7bfe4aaae9850ab179a39436d4b6a9c9da707a5 (patch) | |
tree | e5ef14bb609a2841dbf33ee395bdc70f08c20a71 /cloudinit/config/__init__.py | |
parent | 787377dbc08f689e4de2a112b5446f89b46d769e (diff) | |
download | vyos-cloud-init-f7bfe4aaae9850ab179a39436d4b6a9c9da707a5.tar.gz vyos-cloud-init-f7bfe4aaae9850ab179a39436d4b6a9c9da707a5.zip |
Renamed back to 'cc_*' with the reasoning being that 'cc_' provides
some protection against module name collisions when importing.
Diffstat (limited to 'cloudinit/config/__init__.py')
-rw-r--r-- | cloudinit/config/__init__.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/cloudinit/config/__init__.py b/cloudinit/config/__init__.py index 5cd08575..74e2f275 100644 --- a/cloudinit/config/__init__.py +++ b/cloudinit/config/__init__.py @@ -25,29 +25,32 @@ from cloudinit import log as logging LOG = logging.getLogger(__name__) -# TODO remove this from being a prefix?? -TRANSFORM_PREFIX = '' # "cc_" +# This prefix is used to make it less +# of a change that when importing +# we will not find something else with the same +# name in the lookup path... +MOD_PREFIX = "cc_" -def form_transform_name(name, mod=__name__): +def form_module_name(name): canon_name = name.replace("-", "_") if canon_name.lower().endswith(".py"): canon_name = canon_name[0:(len(canon_name) - 3)] canon_name = canon_name.strip() if not canon_name: return None - if not canon_name.startswith(TRANSFORM_PREFIX): - canon_name = '%s%s' % (TRANSFORM_PREFIX, canon_name) - return ".".join([str(mod), str(canon_name)]) + if not canon_name.startswith(MOD_PREFIX): + canon_name = '%s%s' % (MOD_PREFIX, canon_name) + return canon_name -def fixup_transform(mod, def_freq=PER_INSTANCE): +def fixup_module(mod, def_freq=PER_INSTANCE): if not hasattr(mod, 'frequency'): setattr(mod, 'frequency', def_freq) else: freq = mod.frequency if freq and freq not in FREQUENCIES: - LOG.warn("Transform %s has an unknown frequency %s", mod, freq) + LOG.warn("Module %s has an unknown frequency %s", mod, freq) if not hasattr(mod, 'handle'): def empty_handle(_name, _cfg, _cloud, _log, _args): pass |