]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Adding properties license, source and summary to class ModuleMetadata
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 4 Jan 2019 15:29:36 +0000 (16:29 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 4 Jan 2019 15:29:36 +0000 (16:29 +0100)
lib/webhooks/module_meta_info.py

index 24282d7f2613021136e0e484b2eef6a6f3da4d47..80e303a607667a16d60ccb8dd1be668ad538bbc0 100644 (file)
@@ -54,6 +54,9 @@ class ModuleMetadata(FbBaseObject):
         self._name = None
         self._version = None
         self._author = None
+        self._license = None
+        self._summary = None
+        self._source = None
 
         super(ModuleMetadata, self).__init__(
             appname=appname, verbose=verbose, version=version,
@@ -103,6 +106,45 @@ class ModuleMetadata(FbBaseObject):
             return
         self._author = to_str(value).strip()
 
+    # -------------------------------------------------------------------------
+    @property
+    def license(self):
+        """The license of the module."""
+        return self._license
+
+    @license.setter
+    def license(self, value):
+        if value is None:
+            self._license = None
+            return
+        self._license = to_str(value).strip()
+
+    # -------------------------------------------------------------------------
+    @property
+    def summary(self):
+        """The summary of the module."""
+        return self._summary
+
+    @summary.setter
+    def summary(self, value):
+        if value is None:
+            self._summary = None
+            return
+        self._summary = to_str(value).strip()
+
+    # -------------------------------------------------------------------------
+    @property
+    def source(self):
+        """The source of the module."""
+        return self._source
+
+    @source.setter
+    def source(self, value):
+        if value is None:
+            self._source = None
+            return
+        self._source = to_str(value).strip()
+
     # -------------------------------------------------------------------------
     def as_dict(self, short=True):
         """
@@ -117,6 +159,9 @@ class ModuleMetadata(FbBaseObject):
         res['name'] = self.name
         res['version'] = self.version
         res['author'] = self.author
+        res['license'] = self.license
+        res['summary'] = self.summary
+        res['source'] = self.source
 
         return res
 
@@ -131,6 +176,9 @@ class ModuleMetadata(FbBaseObject):
         required_props = {
             'name': 'Name',
             'version': 'Version',
+            'license': 'License',
+            'summary': 'Summary',
+            'source': 'Source',
         }
 
         for prop in required_props.keys():
@@ -147,6 +195,9 @@ class ModuleMetadata(FbBaseObject):
             metadata.author = json_data['author']
         else:
             metadata.author = metadata.author
+        metadata.license = json_data['license']
+        metadata.summary = json_data['summary']
+        metadata.source = json_data['source']
 
         metadata.initialized = True
         if verbose > 3:
@@ -162,6 +213,9 @@ class ModuleMetadata(FbBaseObject):
         new.name = self.name
         new.version = self.version
         new.author = self.author
+        new.license = self.license
+        new.summary = self.summary
+        new.source = self.source
 
         new.initialized = True
 
@@ -174,6 +228,9 @@ class ModuleMetadata(FbBaseObject):
         data['name'] = self.name
         data['version'] = self.version
         data['author'] = self.author
+        data['license'] = self.license
+        data['summary'] = self.summary
+        data['source'] = self.source
 
         if self.verbose > 4:
             LOG.debug("ModuleMetadata:\n{}".format(pp(data)))