import grp
import errno
import sys
+import re
from operator import itemgetter
default_env = 'development'
+ re_env_name = re.compile(r'^[a-z0-9][a-z0-9_-]*[a-z0-9]$', re.IGNORECASE)
+
# -------------------------------------------------------------------------
def __init__(self, appname=None, verbose=0, version=__version__):
"""Constructor."""
in Puppet forge than in a defined environment
''').strip()
+ self._environment = self.default_env
+
super(GetModuleChangesApp, self).__init__(
appname=appname, verbose=verbose, version=version)
+ # -----------------------------------------------------------
+ @property
+ def environment(self):
+ """The environment, which should be compared with Puppet forge."""
+ return self._environment
+
+ @environment.setter
+ def environment(self, value):
+ if value is None:
+ raise TypeError("An environment may not be None.")
+ val = str(value).strip()
+ if val == '':
+ raise ValueError("Invalid environment name: {!r}.".format(value))
+
+ if not self.re_env_name.match(val):
+ raise ValueError("Invalid environment name: {!r}.".format(value))
+
+ self._environment = val
+
# -------------------------------------------------------------------------
def as_dict(self, short=True):
"""
res = super(GetModuleChangesApp, self).as_dict(short=short)
res['default_env'] = self.default_env
+ res['environment'] = self.environment
return res
+ # -------------------------------------------------------------------------
+ def init_arg_parser(self, arg_parser):
+
+ arg_parser.add_argument(
+ '-E', '--env', '--environment', metavar='ENVIRONMENT', dest='env',
+ help=(
+ "The Puppet environmment, which to compare with Puppet forge, "
+ "default: {!r}.").format(self.default_env),
+ )
+
+ # -------------------------------------------------------------------------
+ def perform_args(self, arg_parser):
+
+ if self.cmdline_args.env:
+ self.environment = self.cmdline_args.env
+
# -------------------------------------------------------------------------
def evaluate_config(self, config, yaml_file):
LOG.error(str(e))
self.exit(7)
+ mod_list = self.get_newer_modules(module_infos)
+
+ # -------------------------------------------------------------------------
+ def get_newer_modules(self, module_infos):
+
+ env_found = False
+
+
# =============================================================================