from .base_module_info import BaseModuleInfoError, BaseModuleInfo
-__version__ = '0.4.0'
+__version__ = '0.5.0'
LOG = logging.getLogger(__name__)
initialized=None, name=None, vendor=None, full_name=None):
self.releases = None
+ self._created_at = None
+ self._deprecated_at = None
+ self._deprecated_for = None
+ self._downloads = None
+ self._endorsement = None
super(ForgeModuleInfo, self).__init__(
appname=appname, verbose=verbose, version=version, base_dir=base_dir,
if initialized is not None:
self.initialized = initialized
+ # -------------------------------------------------------------------------
+ @property
+ def created_at(self):
+ """Creation date of this forge module."""
+ return self._created_at
+
+ @created_at.setter
+ def created_at(self, value):
+ if value is None:
+ self._created_at = None
+ return
+ if isinstance(value, datetime.datetime):
+ self._created_at = value
+ return
+ v = str(value).strip()
+ if value == '':
+ self._created_at = None
+ return
+ self._created_at = parse_forge_date(v)
+
+ # -------------------------------------------------------------------------
+ @property
+ def deprecated_at(self):
+ """Date of deprecation of this forge module."""
+ return self._deprecated_at
+
+ @deprecated_at.setter
+ def deprecated_at(self, value):
+ if value is None:
+ self._deprecated_at = None
+ return
+ if isinstance(value, datetime.datetime):
+ self._deprecated_at = value
+ return
+ v = str(value).strip()
+ if value == '':
+ self._deprecated_at = None
+ return
+ self._deprecated_at = parse_forge_date(v)
+
+ # -------------------------------------------------------------------------
+ @property
+ def deprecated_for(self):
+ """The reason of deprecation of this forge module.."""
+ return self._deprecated_for
+
+ @deprecated_for.setter
+ def deprecated_for(self, value):
+ if value is None:
+ self._deprecated_for = None
+ return
+ v = str(value).strip()
+ if value == '':
+ self._deprecated_for = None
+ return
+ self._deprecated_for = v
+
+ # -------------------------------------------------------------------------
+ @property
+ def endorsement(self):
+ """The endorsement of this forge module.."""
+ return self._endorsement
+
+ @endorsement.setter
+ def endorsement(self, value):
+ if value is None:
+ self._endorsement = None
+ return
+ v = str(value).strip()
+ if value == '':
+ self._endorsement = None
+ return
+ self._endorsement = 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 doenloads must be greater or equal to zero "
+ "(Given: {}).").format(value)
+ raise ValueError(msg)
+ self._downloads = v
+
# -------------------------------------------------------------------------
def as_dict(self, short=True):
res = super(ForgeModuleInfo, self).as_dict(short=short)
-# res['releases'] = []
-# for release in self.releases:
-# res['releases'].append(release.as_dict(short=short))
+ res['created_at'] = self.created_at
+ res['deprecated_at'] = self.deprecated_at
+ res['deprecated_for'] = self.deprecated_for
+ res['downloads'] = self.downloads
+ res['endorsement'] = self.endorsement
return res
res = {}
+ res['created_at'] = None
+ if self.created_at:
+ res['created_at'] = self.created_at.strftime('%Y-%m-%d %H:%M:%S %z')
+
+ res['deprecated_at'] = None
+ if self.deprecated_at:
+ res['deprecated_at'] = self.deprecated_at.strftime('%Y-%m-%d %H:%M:%S %z')
+
+ res['deprecated_for'] = self.deprecated_for
+ res['downloads'] = self.downloads
+ res['endorsement'] = self.endorsement
+
res['releases'] = []
for release in self.releases:
res['releases'].append(release.to_data())
module_info.releases = ModuleReleaseList(
appname=appname, verbose=verbose, base_dir=base_dir)
+ for prop_name in (
+ 'created_at', 'deprecated_at', 'deprecated_for', 'downloads', 'endorsement',):
+ 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 'releases' in js_info:
for rel in js_info['releases']:
release = ModuleReleaseInfo.get_from_forge(
if release:
module_info.releases.append(release)
- module_info.releases.imnitialized = True
+ module_info.releases.initialized = True
# if 'current_release' in js_info and js_info['current_release']:
# if 'version' in js_info['current_release']: