]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Adding definition of properties 'file_md5', 'license' and 'metadata' of class Current...
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Feb 2019 09:24:15 +0000 (10:24 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Feb 2019 09:24:15 +0000 (10:24 +0100)
lib/webhooks/forge_module_info.py

index d24a45a304f741a7b58b0e0072242c9814caeb96..8065e63520c0a5490ce0659521f554f0b0110f1c 100644 (file)
@@ -29,7 +29,9 @@ from .xlate import XLATOR
 
 from .base_module_info import BaseModuleInfoError, BaseModuleInfo
 
-__version__ = '0.5.1'
+from .module_meta_info import ModuleMetadata
+
+__version__ = '0.5.2'
 
 LOG = logging.getLogger(__name__)
 
@@ -398,7 +400,7 @@ class CurrentModuleReleaseInfo(ModuleReleaseInfo):
     # -------------------------------------------------------------------------
     @property
     def deleted_for(self):
-        """The reason, why this module release was deleted.."""
+        """The reason, why this module release was deleted."""
         return self._deleted_for
 
     @deleted_for.setter
@@ -431,6 +433,39 @@ class CurrentModuleReleaseInfo(ModuleReleaseInfo):
             LOG.error(_("Got a {c} setting {w}: {e}").format(
                 c=e.__class__.__name__, w='downloads', e=e))
 
+    # -------------------------------------------------------------------------
+    @property
+    def file_md5(self):
+        """The MD5-sum of the current release package."""
+        return self._file_md5
+
+    @file_md5.setter
+    def file_md5(self, value):
+        if value is None:
+            self._file_md5 = None
+            return
+        v = str(value).strip()
+        if v == '':
+            self._file_md5 = None
+            return
+        self._file_md5 = v
+
+    # -------------------------------------------------------------------------
+    @property
+    def license(self):
+        """The license of module source."""
+        return self._license
+
+    @license.setter
+    def license(self, value):
+        if value is None:
+            self._license = None
+            return
+        v = str(value).strip()
+        if v == '':
+            self._license = None
+            return
+        self._license = v
 
     # -------------------------------------------------------------------------
     def as_dict(self, short=True):
@@ -446,6 +481,8 @@ class CurrentModuleReleaseInfo(ModuleReleaseInfo):
         res['changelog'] = self.changelog
         res['deleted_for'] = self.deleted_for
         res['downloads'] = self.downloads
+        res['file_md5'] = self.file_md5
+        res['license'] = self.license
 
         return res
 
@@ -460,7 +497,15 @@ class CurrentModuleReleaseInfo(ModuleReleaseInfo):
             self.deleted_for = data['deleted_for']
         if 'downloads' in data and data['downloads']:
             self.downloads = data['downloads']
-
+        if 'file_md5' in data and data['file_md5']:
+            self.file_md5 = data['file_md5']
+        if 'license' in data and data['license']:
+            self.license = data['license']
+
+        if 'metadata' in data and data['metadata']:
+            self.metadata = ModuleMetadata.from_json_data(
+                data['metadata'], appname=self.appname,
+                verbose=self.verbose, base_dir=self.base_dir)
 
 # =============================================================================
 class ModuleReleaseList(collections.MutableSequence, FbBaseObject):