from .app import PpApplication
-__version__ = '0.3.1'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
self.env_dir = None
self.modules_root_dir = None
self.modules = {}
+ self.dependencies = []
super(CheckPuppetEnvApp, self).__init__(
appname=appname, verbose=verbose, version=version, base_dir=base_dir,
self.collect_modules()
self.print_modules()
+ self.verify_dependencies()
+
+ # -------------------------------------------------------------------------
+ def verify_dependencies(self):
+
+ LOG.info("Verifying dependencies ...")
+
+ mods = {}
+ self.dependencies = []
+ re_name_split = re.compile(r'([^/_-]+)[/_-](.*)')
+ connectors = ('-', '_', '/')
+
+ for b_name in self.modules.keys():
+ module_info = self.modules[b_name]
+ base_name = str(b_name)
+ if module_info['name']:
+ mod_name = module_info['name']
+ mods[module_info['name']] = base_name
+ else:
+ LOG.warn("Did not found complete name of module {!r}.".format(base_name))
+
+ for b_name in self.modules.keys():
+ module_info = self.modules[b_name]
+ base_name = str(b_name)
+ if not module_info['dependencies']:
+ continue
+ if not module_info['name']:
+ LOG.debug("Did not found complete name of module {!r}.".format(base_name))
+ continue
+ if not module_info['vendor']:
+ LOG.warn("Did not found vendor of module {!r}.".format(base_name))
+ mod_name = module_info['name']
+
+ for dep_key in module_info['dependencies'].keys():
+ dep_mod = str(dep_key)
+ if dep_mod in mods:
+ dep = (dep_mod, mod_name)
+ self.dependencies.append(dep)
+ continue
+ match = re_name_split.match(dep_mod)
+ found = False
+ if match:
+ dep_mod_vendor = match.group(1)
+ dep_mod_base = match.group(2)
+ for connector in connectors:
+ dep_mod_name = dep_mod_vendor + connector + dep_mod_base
+ if dep_mod_name in mods:
+ dep = (dep_mod_name, mod_name)
+ self.dependencies.append(dep)
+ found = True
+ break
+ if found:
+ break
+ LOG.warn("Did not found dependency to {d!r} of module {m!r}.".format(
+ d=dep_mod, m=mod_name))
+
+ if self.verbose > 2:
+ LOG.debug("Found dependencies:\n{}".format(pp(self.dependencies)))
# -------------------------------------------------------------------------
def print_modules(self):