From: Frank Brehm Date: Tue, 26 Feb 2019 15:43:38 +0000 (+0100) Subject: Starting with failing properties of class ForgeModuleInfo X-Git-Tag: 1.6.4^2~44 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=80fccef5ade0a07b18abdc7e98b791c9cf47d90f;p=pixelpark%2Fpuppetmaster-webhooks.git Starting with failing properties of class ForgeModuleInfo --- diff --git a/lib/webhooks/forge_module_info.py b/lib/webhooks/forge_module_info.py index 7b99147..35a8e03 100644 --- a/lib/webhooks/forge_module_info.py +++ b/lib/webhooks/forge_module_info.py @@ -31,7 +31,7 @@ from .base_module_info import BaseModuleInfoError, BaseModuleInfo from .module_meta_info import ModuleMetadata -__version__ = '0.5.5' +__version__ = '0.6.1' LOG = logging.getLogger(__name__) @@ -1259,14 +1259,24 @@ class ForgeModuleInfo(BaseModuleInfo): self, appname=None, verbose=0, version=__version__, base_dir=None, initialized=None, name=None, vendor=None, full_name=None): + self.current_release = None self.releases = None + self.owner = None + self._created_at = None self._deprecated_at = None self._deprecated_for = None self._downloads = None self._endorsement = None - - self.current_release = None + self._feedback_score = None + self._homepage_url = None + self._issues_url = None + self._module_group = None + self._slug = None + self._superseded_by = None + self._supported = None + self._updated_at = None + self._uri = None super(ForgeModuleInfo, self).__init__( appname=appname, verbose=verbose, version=version, base_dir=base_dir, @@ -1333,6 +1343,25 @@ class ForgeModuleInfo(BaseModuleInfo): return self._deprecated_for = v + # ------------------------------------------------------------------------- + @property + def downloads(self): + """The number of downloads of this module.""" + return self._downloads + + @downloads.setter + def downloads(self, value): + if value is None: + self._downloads = None + return + v = int(value) + if v < 0: + msg = _( + "The number of {w!r} must be greater or equal to zero " + "(Given: {v}).").format(w='downloads', v=value) + raise ValueError(msg) + self._downloads = v + # ------------------------------------------------------------------------- @property def endorsement(self): @@ -1352,22 +1381,22 @@ class ForgeModuleInfo(BaseModuleInfo): # ------------------------------------------------------------------------- @property - def downloads(self): - """The number of downloads of this module.""" - return self._downloads + def feedback_score(self): + """The number of feedback_scores of this module.""" + return self._feedback_score - @downloads.setter - def downloads(self, value): + @feedback_score.setter + def feedback_score(self, value): if value is None: - self._downloads = None + self._feedback_score = None return v = int(value) if v < 0: msg = _( - "The number of doenloads must be greater or equal to zero " - "(Given: {}).").format(value) + "The number of {w!r} must be greater or equal to zero " + "(Given: {v}).").format(w='feedback_score', v=value) raise ValueError(msg) - self._downloads = v + self._feedback_score = v # ------------------------------------------------------------------------- def as_dict(self, short=True): @@ -1379,6 +1408,7 @@ class ForgeModuleInfo(BaseModuleInfo): res['deprecated_for'] = self.deprecated_for res['downloads'] = self.downloads res['endorsement'] = self.endorsement + res['feedback_score'] = self.feedback_score return res @@ -1399,11 +1429,21 @@ class ForgeModuleInfo(BaseModuleInfo): res['deprecated_for'] = self.deprecated_for res['downloads'] = self.downloads res['endorsement'] = self.endorsement + res['feedback_score'] = self.feedback_score + res['name'] = self.name res['releases'] = [] for release in self.releases: res['releases'].append(release.to_data()) + res['current_release'] = None + if self.current_release: + res['current_release'] = self.current_release.to_data() + + res['owner'] = None + if self.owner: + res['owner'] = self.owner.to_data() + return res # ------------------------------------------------------------------------- @@ -1460,16 +1500,11 @@ class ForgeModuleInfo(BaseModuleInfo): appname=appname, verbose=verbose, base_dir=base_dir) for prop_name in ( - 'created_at', 'deprecated_at', 'deprecated_for', 'downloads', 'endorsement',): + 'created_at', 'deprecated_at', 'deprecated_for', 'downloads', 'endorsement', + 'feedback_score',): if prop_name in js_info and js_info[prop_name]: setattr(module_info, prop_name, js_info[prop_name]) -# if 'created_at' in js_info and js_info['created_at']: -# module_info.created_at = js_info['created_at'] - -# if 'deprecated_at' in js_info and js_info['deprecated_at']: -# module_info.deprecated_at = js_info['deprecated_at'] - if 'current_release' in js_info and js_info['current_release']: module_info.current_release = CurrentModuleReleaseInfo.get_from_forge( js_info['current_release'], appname=appname, verbose=verbose, base_dir=base_dir) @@ -1483,21 +1518,9 @@ class ForgeModuleInfo(BaseModuleInfo): module_info.releases.initialized = True -# if 'current_release' in js_info and js_info['current_release']: -# if 'version' in js_info['current_release']: -# version = js_info['current_release']['version'] -# else: -# msg = _("Did not found version of current release of module {}.").format(full_name) -# LOG.warn(msg) -# if 'metadata' in js_info['current_release'] and js_info['current_release']['metadata']: -# if ('source' in js_info['current_release']['metadata'] and -# js_info['current_release']['metadata']['source']): -# source = str(js_info['current_release']['metadata']['source']).strip() -# if not source: -# LOG.warn(_("Did not found source information of module {}.").format(full_name)) -# else: -# msg = _("Did not found current release of module {}.").format(full_name) -# LOG.warn(msg) + if 'owner' in js_info and js_info['owner']: + module_info.owner = ForgeOwnerInfo.from_data( + js_info['owner'], appname=appname, verbose=verbose, base_dir=base_dir) # LOG.debug("Current version of module {name} is {version}.".format( # name=full_name, version=version))