From: Frank Brehm Date: Fri, 4 Jan 2019 16:07:51 +0000 (+0100) Subject: Using class ModuleDependency for a list of requirements in ModuleMetadata X-Git-Tag: 1.6.4^2~68 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=73b087604f337db7bad391da94d57b05fdd0ef35;p=pixelpark%2Fpuppetmaster-webhooks.git Using class ModuleDependency for a list of requirements in ModuleMetadata --- diff --git a/lib/webhooks/module_meta_info.py b/lib/webhooks/module_meta_info.py index ce56bee..8d31dce 100644 --- a/lib/webhooks/module_meta_info.py +++ b/lib/webhooks/module_meta_info.py @@ -27,7 +27,7 @@ from fb_tools.obj import FbBaseObjectError, FbBaseObject from .xlate import XLATOR -__version__ = '0.4.1' +__version__ = '0.4.2' LOG = logging.getLogger(__name__) @@ -106,6 +106,8 @@ class ModuleMetadata(FbBaseObject): self._source = None self.dependencies = [] self.requirements = [] + self._project_page = None + self._issues_url = None super(ModuleMetadata, self).__init__( appname=appname, verbose=verbose, version=version, @@ -194,6 +196,32 @@ class ModuleMetadata(FbBaseObject): return self._source = to_str(value).strip() + # ------------------------------------------------------------------------- + @property + def project_page(self): + """The project page of the module.""" + return self._project_page + + @project_page.setter + def project_page(self, value): + if value is None: + self._project_page = None + return + self._project_page = to_str(value).strip() + + # ------------------------------------------------------------------------- + @property + def issues_url(self): + """The link to the module's issue tracker.""" + return self._issues_url + + @issues_url.setter + def issues_url(self, value): + if value is None: + self._issues_url = None + return + self._issues_url = to_str(value).strip() + # ------------------------------------------------------------------------- def as_dict(self, short=True): """ @@ -217,6 +245,8 @@ class ModuleMetadata(FbBaseObject): res['requirements'] = [] for req in self.requirements: res['requirements'].append(req.as_dict()) + res['project_page'] = self.project_page + res['issues_url'] = self.issues_url return res @@ -270,6 +300,10 @@ class ModuleMetadata(FbBaseObject): for item in json_data['requirements']: req = ModuleDependency.from_data(item) metadata.requirements.append(req) + if 'project_page' in json_data: + metadata.project_page = json_data['project_page'] + if 'issues_url' in json_data: + metadata.issues_url = json_data['issues_url'] metadata.initialized = True if verbose > 3: @@ -292,6 +326,8 @@ class ModuleMetadata(FbBaseObject): new.dependencies.append(copy.copy(dep)) for req in self.requirements: new.requirements.append(copy.copy(req)) + new.project_page = self.project_page + new.issues_url = self.issues_url new.initialized = True @@ -314,6 +350,10 @@ class ModuleMetadata(FbBaseObject): data['requirements'] = [] for req in self.requirements: data['requirements'].append(req.to_data()) + if self.project_page: + data['project_page'] = self.project_page + if self.issues_url: + data['issues_url'] = self.issues_url if self.verbose > 4: LOG.debug("ModuleMetadata:\n{}".format(pp(data)))