]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Splitting method ModuleMetadata.from_json_data()
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 15 Mar 2019 12:48:39 +0000 (13:48 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 15 Mar 2019 12:48:39 +0000 (13:48 +0100)
lib/webhooks/module_meta_info.py

index 654f4527fcf462d4c114b72182697f0b0e8703ac..d63aadd87f8fb95e040e1af80910a247eeb8e592 100644 (file)
@@ -23,7 +23,7 @@ from fb_tools.obj import FbBaseObjectError, FbBaseObject
 
 from .xlate import XLATOR
 
-__version__ = '0.5.4'
+__version__ = '0.5.5'
 
 LOG = logging.getLogger(__name__)
 
@@ -346,42 +346,46 @@ class ModuleMetadata(FbBaseObject):
                 raise MetadataInitError(msg)
 
         metadata = cls(appname=appname, verbose=verbose, base_dir=base_dir)
+        metadata._apply_json_data(json_data)
 
-        metadata.name = json_data['name']
-        metadata.version = json_data['version']
+        return metadata
+
+    # -------------------------------------------------------------------------
+    def _apply_json_data(self, json_data):
+
+        self.name = json_data['name']
+        self.version = json_data['version']
         if 'author' in json_data:
-            metadata.author = json_data['author']
+            self.author = json_data['author']
         else:
-            metadata.author = metadata.author
-        metadata.license = json_data['license']
-        metadata.summary = json_data['summary']
-        metadata.source = json_data['source']
+            self.author = self.author
+        self.license = json_data['license']
+        self.summary = json_data['summary']
+        self.source = json_data['source']
         for item in json_data['dependencies']:
             dep = ModuleDependency.from_data(item)
-            metadata.dependencies.append(dep)
+            self.dependencies.append(dep)
         if 'requirements' in json_data:
             for item in json_data['requirements']:
                 req = ModuleDependency.from_data(item)
-                metadata.requirements.append(req)
+                self.requirements.append(req)
         if 'project_page' in json_data:
-            metadata.project_page = json_data['project_page']
+            self.project_page = json_data['project_page']
         if 'issues_url' in json_data:
-            metadata.issues_url = json_data['issues_url']
+            self.issues_url = json_data['issues_url']
         if 'operatingsystem_support' in json_data:
             for item in json_data['operatingsystem_support']:
                 supp = ModuleOsSupport.from_data(item)
-                metadata.operatingsystem_support.append(supp)
+                self.operatingsystem_support.append(supp)
         if 'tags' in json_data:
             for tag in json_data['tags']:
                 tg = str(tag).strip()
                 if tg:
-                    metadata.tags.append(tg)
+                    self.tags.append(tg)
 
-        metadata.initialized = True
-        if verbose > 3:
-            LOG.debug("ModuleMetadata:\n{}".format(pp(metadata.as_dict())))
-
-        return metadata
+        self.initialized = True
+        if self.verbose > 3:
+            LOG.debug("ModuleMetadata:\n{}".format(pp(self.as_dict())))
 
     # -------------------------------------------------------------------------
     def __copy__(self):