from .module_meta_info import ModuleMetadata
-from .forge.mod_dict import ForgeModuleDict
+from .forge.mod_dict import ForgeModuleDict, ForgeModuleDictError
from .xlate import __module_dir__ as __xlate_module_dir__
from .xlate import __base_dir__ as __xlate_base_dir__
return ModuleInfo.init_from_json(
json_data, env, appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+ # -------------------------------------------------------------------------
+ def read_all_module_infos(self, only_main_branches=False):
+
+ self.init_puppet_environments()
+ self.collect_local_modules()
+
+ if not self.read_forge_cache():
+ self.exit(7)
+ return
+
+ module_infos = ModuleInfoDict(
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+ sort_by_name=self.sort_by_name)
+
+ for env in self.env_modules.keys():
+ if only_main_branches and str(env) not in self.main_branches:
+ continue
+ for module_name in self.env_modules[env].keys():
+ mod = self.env_modules[env][module_name]
+ module_infos.merge(mod)
+
+ for m_name in module_infos.keys():
+ module_name = str(m_name)
+ if module_name in self.forge_modules:
+ forge_mod = self.forge_modules[module_name]
+ module_infos[m_name].forge_avail = True
+ if forge_mod.current_release:
+ f_version = forge_mod.current_release.release_version
+ module_infos[m_name].forge_version = f_version
+ if forge_mod.current_release.metadata:
+ s_url = forge_mod.current_release.metadata.source
+ module_infos[m_name].forge_source = s_url
+ module_infos[m_name].forge_homepage_url = forge_mod.homepage_url
+ module_infos[m_name].ts_checked = forge_mod.ts_checked
+ module_infos[m_name].forge_deprecated_at = forge_mod.deprecated_at
+ module_infos[m_name].forge_deprecated_for = forge_mod.deprecated_for
+ if forge_mod.superseded_by and forge_mod.superseded_by['slug']:
+ subst = forge_mod.superseded_by['slug']
+ module_infos[m_name].forge_superseded_by = subst
+
+ if self.verbose > 2:
+ LOG.debug(_("All modules infos:") + '\n' + pp(module_infos.as_list()))
+
+ return module_infos
+
+ # -------------------------------------------------------------------------
+ def read_forge_cache(self):
+
+ self.init_forge_module_dict()
+ try:
+ self.forge_modules.read_file()
+ except ForgeModuleDictError as e:
+ LOG.error(_("Got a {cn} reading input data as JSON: {e}").format(
+ cn=e.__class__.__name__, e=e))
+ return False
+ return True
+
# =============================================================================
if __name__ == "__main__":
self.print_out("#" * len_title)
self.print_out('')
- self.init_puppet_environments()
- self.collect_local_modules()
-
- if not self.read_forge_cache():
- self.exit(7)
- return
-
- exposed_modules = ModuleInfoDict(
- appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
- sort_by_name=self.sort_by_name)
-
- for env in self.env_modules.keys():
- if str(env) not in self.main_branches:
- continue
- for module_name in self.env_modules[env].keys():
- mod = self.env_modules[env][module_name]
- exposed_modules.merge(mod)
-
- for m_name in exposed_modules.keys():
- module_name = str(m_name)
- if module_name in self.forge_modules:
- forge_mod = self.forge_modules[module_name]
- exposed_modules[m_name].forge_avail = True
- if forge_mod.current_release:
- f_version = forge_mod.current_release.release_version
- exposed_modules[m_name].forge_version = f_version
- if forge_mod.current_release.metadata:
- s_url = forge_mod.current_release.metadata.source
- exposed_modules[m_name].forge_source = s_url
- exposed_modules[m_name].forge_homepage_url = forge_mod.homepage_url
- exposed_modules[m_name].ts_checked = forge_mod.ts_checked
- exposed_modules[m_name].forge_deprecated_at = forge_mod.deprecated_at
- exposed_modules[m_name].forge_deprecated_for = forge_mod.deprecated_for
- if forge_mod.superseded_by and forge_mod.superseded_by['slug']:
- subst = forge_mod.superseded_by['slug']
- exposed_modules[m_name].forge_superseded_by = subst
-
- if self.verbose > 2:
- LOG.debug(_("Modules to show:") + '\n' + pp(exposed_modules.as_list()))
-
- self.output_modules(exposed_modules)
-
- # -------------------------------------------------------------------------
- def read_forge_cache(self):
-
- self.init_forge_module_dict()
- try:
- self.forge_modules.read_file()
- except ForgeModuleDictError as e:
- LOG.error(_("Got a {cn} reading input data as JSON: {e}").format(
- cn=e.__class__.__name__, e=e))
- return False
- return True
+ module_infos = self.read_all_module_infos(only_main_branches=True)
+ self.output_modules(module_infos)
# -------------------------------------------------------------------------
def output_modules(self, module_infos):