]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Using class ModuleDependency for a list of requirements in ModuleMetadata
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 4 Jan 2019 16:07:51 +0000 (17:07 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 4 Jan 2019 16:07:51 +0000 (17:07 +0100)
lib/webhooks/module_meta_info.py

index ce56beeb2ac6711a7d343e7ac1382cd46bea43a7..8d31dce66e3bdc461f587a40ac818de5387b6f23 100644 (file)
@@ -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)))