from .xlate import XLATOR
-__version__ = '0.3.1'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
self._summary = None
self._source = None
self.dependencies = []
+ self.requirements = []
super(ModuleMetadata, self).__init__(
appname=appname, verbose=verbose, version=version,
res['dependencies'] = []
for dep in self.dependencies:
res['dependencies'].append(dep.as_dict())
+ res['requirements'] = []
+ for req in self.requirements:
+ res['requirements'].append(req.as_dict())
return res
raise MetadataInitError(msg)
if not is_sequence(json_data['dependencies']):
- msg = _("Invalid dependencies - not a list.")
+ msg = _("Invalid item {} - not a list.").format('dependencies')
raise MetadataInitError(msg)
+ if 'requirements' in json_data:
+ if not is_sequence(json_data['requirements']):
+ msg = _("Invalid item {} - not a list.").format('requirements')
+ raise MetadataInitError(msg)
+
metadata = cls(appname=appname, verbose=verbose, base_dir=base_dir)
metadata.name = json_data['name']
for item in json_data['dependencies']:
dep = ModuleDependency.from_data(item)
metadata.dependencies.append(dep)
+ if 'requirements' in json_data:
+ for item in json_data['requirements']:
+ req = ModuleDependency.from_data(item)
+ metadata.requirements.append(req)
metadata.initialized = True
if verbose > 3:
new.source = self.source
for dep in self.dependencies:
new.dependencies.append(copy.copy(dep))
+ for req in self.requirements:
+ new.requirements.append(copy.copy(req))
new.initialized = True
data['dependencies'] = []
for dep in self.dependencies:
data['dependencies'].append(dep.to_data())
+ if self.requirements:
+ data['requirements'] = []
+ for req in self.requirements:
+ data['requirements'].append(req.to_data())
if self.verbose > 4:
LOG.debug("ModuleMetadata:\n{}".format(pp(data)))