def write_package_in_zip(zip_file, path, package):
"""Write packages files in the zip file
:param zip_file: zip file where the files will get created
:type zip_file: zipfile.ZipFile
:param path: path for the package directory. E.g.
universe/repo/packages/M/marathon/0
:type path: pathlib.Path
:param package: package information dictionary
:type package: dict
:rtype: None
"""
package = package.copy()
package.pop('releaseVersion')
package.pop('minDcosReleaseVersion', None)
package['packagingVersion'] = "2.0"
resource = package.pop('resource', None)
if resource:
cli = resource.pop('cli', None)
if cli and 'command' not in package:
print(('WARNING: Removing binary CLI from ({}, {}) without a '
'Python CLI').format(package['name'], package['version']))
zip_file.writestr(
str(path / 'resource.json'),
json.dumps(resource))
marathon_template = package.pop(
'marathon',
{}
).get(
'v2AppMustacheTemplate'
)
if marathon_template:
zip_file.writestr(
str(path / 'marathon.json.mustache'),
base64.standard_b64decode(marathon_template))
config = package.pop('config', None)
if config:
zip_file.writestr(
str(path / 'config.json'),
json.dumps(config))
command = package.pop('command', None)
if command:
zip_file.writestr(
str(path / 'command.json'),
json.dumps(command))
zip_file.writestr(
str(path / 'package.json'),
json.dumps(package))
评论列表
文章目录