from .module_meta_info import ModuleMetadata
-__version__ = '0.5.5'
+__version__ = '0.6.1'
LOG = logging.getLogger(__name__)
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,
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):
# -------------------------------------------------------------------------
@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):
res['deprecated_for'] = self.deprecated_for
res['downloads'] = self.downloads
res['endorsement'] = self.endorsement
+ res['feedback_score'] = self.feedback_score
return res
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
# -------------------------------------------------------------------------
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)
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))