--- /dev/null
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import sys
+
+if sys.version_info[0] != 3:
+ print("This script is intended to use with Python3.", file=sys.stderr)
+ print("You are using Python: {0}.{1}.{2}-{3}-{4}.\n".format(
+ *sys.version_info), file=sys.stderr)
+ sys.exit(1)
+
+if sys.version_info[1] < 4:
+ print("A minimal Python version of 3.4 is necessary to execute this script.", file=sys.stderr)
+ print("You are using Python: {0}.{1}.{2}-{3}-{4}.\n".format(
+ *sys.version_info), file=sys.stderr)
+ sys.exit(1)
+
+import os
+import logging
+import locale
+
+# own modules:
+cur_dir = os.getcwd()
+base_dir = cur_dir
+
+if sys.argv[0] != '' and sys.argv[0] != '-c':
+ bin_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
+else:
+ bin_dir = os.path.dirname(os.path.realpath(__file__))
+base_dir = os.path.abspath(os.path.join(bin_dir, '..'))
+lib_dir = os.path.join(base_dir, 'lib')
+module_dir = os.path.join(lib_dir, 'dpx_puppettools')
+if os.path.exists(module_dir):
+ sys.path.insert(0, lib_dir)
+
+from dpx_puppettools.app.get_forge_module import GetForgeModuleApplication
+
+log = logging.getLogger(__name__)
+
+__author__ = 'Frank Brehm <frank@brehm-online.com>'
+__copyright__ = '(C) 2023 by Frank Brehm, Berlin'
+
+appname = os.path.basename(sys.argv[0])
+
+locale.setlocale(locale.LC_ALL, '')
+
+app = GetForgeModuleApplication(appname=appname, base_dir=base_dir)
+app.initialized = True
+
+if app.verbose > 2:
+ print("{c}-Object:\n{a}".format(c=app.__class__.__name__, a=app))
+
+app()
+
+sys.exit(0)
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+@summary: An application module for 'get-forge-mode'.
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2023 by Frank Brehm, Berlin
+"""
+from __future__ import absolute_import
+
+# Standard modules
+import logging
+
+# Third party modules
+
+# Own modules
+from .. import pp
+
+from ..xlate import XLATOR
+
+from . import BaseDPXPuppetApplication
+
+from ..forge.mod_info import ForgeModuleInfo
+
+LOG = logging.getLogger(__name__)
+
+_ = XLATOR.gettext
+ngettext = XLATOR.ngettext
+
+__version__ = '0.3.0'
+
+
+# =============================================================================
+class GetForgeModuleApplication(BaseDPXPuppetApplication):
+ """Application class for 'get-forge-mode'. It retrieves the given module from Puppet forge,
+ writes the found information into its cache file and displays the most important
+ information."""
+
+ show_assume_options = False
+ show_console_timeout_option = False
+ # show_force_option = False
+ show_simulate_option = False
+
+ # -------------------------------------------------------------------------
+ def __init__(self, appname=None, verbose=0, base_dir=None, initialized=False):
+
+ self.write_cache = True
+ self.module_name = None
+ self.module_info = None
+
+ desc = _(
+ "This application retrieves information about the given module "
+ "from Puppet forge, writes the found information into its cache file and "
+ "displays the most important.")
+
+ super(GetForgeModuleApplication, self).__init__(
+ appname=appname, verbose=verbose, base_dir=base_dir,
+ description=desc, initialized=initialized)
+
+ # -------------------------------------------------------------------------
+ def init_arg_parser(self):
+ """
+ Public available method to initiate the argument parser.
+ """
+
+ forge_group = self.arg_parser.add_argument_group(_('Options for Puppet forge operations'))
+
+ forge_group.add_argument(
+ '-n', '--no-write', dest='no_write', action="store_true",
+ help=_("Don't write the cache file after retrieving the infos from Puppet forge."),
+ )
+
+ forge_group.add_argument(
+ 'module_name', nargs=1,
+ help=_("The name of the module, which data should be retrieved from Puppet forge."),
+ )
+
+ super(GetForgeModuleApplication, self).init_arg_parser()
+
+ # -------------------------------------------------------------------------
+ def post_init(self):
+ """Method to execute before calling run(). Here could be done some
+ finishing actions after reading in commandline parameters,
+ configuration a.s.o."""
+
+ super(GetForgeModuleApplication, self).post_init()
+
+ if getattr(self.args, 'no_write', False):
+ self.write_cache = False
+
+ self.module_name = self.args.module_name[0]
+
+ self.module_info = ForgeModuleInfo(
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+ full_name=self.module_name, initialized=True,)
+
+ # -------------------------------------------------------------------------
+ def _run(self):
+
+ LOG.info("Run, baby run, baby run run run ...")
+ self.module_info.retrieve_forge_data()
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+ pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list