Skip to content
Snippets Groups Projects
Commit 33ff6151 authored by Matthieu Gonnet's avatar Matthieu Gonnet Committed by Sebastien Luttringer
Browse files

is extract -D generate a description file from the description.json file

parent 16c7e1e0
No related branches found
No related tags found
No related merge requests found
......@@ -177,7 +177,8 @@ def c_extract(parser, args):
'''
repoman = load_repositories(args)
img, repo = select_image(args.image, repoman, args.best)
img.extract(args.path, payload=args.payload, force=args.force)
img.extract(args.path, payload=args.payload, force=args.force,
gendescription=args.gendescription)
def c_get(parser, args):
'''
......@@ -398,6 +399,8 @@ p_diff.set_defaults(func=c_diff)
# extract command parser
p_extract = subparsers.add_parser("extract", help=c_extract.__doc__.lower())
p_extract.add_argument("-D", action="store_true", dest="gendescription", default=False,
help="generate a description file from metadata")
p_extract.add_argument("-p", action="store_true", dest="payload", default=False,
help="extract payloads")
p_extract.add_argument("-f", "--force", action="store_true", default=False,
......
......@@ -83,7 +83,11 @@ class SourceImage(Image):
# create dict of file to create
examples = {}
# create description example from template
examples["description"] = {"path": "description", "content": istemplate.description}
examples["description"] = {"path": "description",
"content": istemplate.description % {"name": "",
"version": "",
"description": "",
"author": ""}}
# create changelog example from template
examples["changelog"] = {"path": "changelog", "content": istemplate.changelog}
# create parser example from template
......@@ -618,7 +622,7 @@ class PackageImage(Image):
self.payload[payname].info
self.payload[payname].download(directory, force=force)
def extract(self, directory, force=False, payload=False):
def extract(self, directory, force=False, payload=False, gendescription=False):
'''
Extract content of the image inside a repository
'''
......@@ -630,6 +634,11 @@ class PackageImage(Image):
# extract content
arrow("Extracting image in %s" % directory)
self._tarball.extractall(directory)
# generate description file from description.json
if gendescription:
arrow("Generating description file in %s" % directory)
with open(os.path.join(directory, "description"), "w") as f:
f.write(istemplate.description % self._metadata)
# launch payload extract
if payload:
for payname in self.payload:
......
......@@ -3,10 +3,10 @@
# Started 12/05/2011 by Seblu <seblu@seblu.net>
description = u"""[image]
name =
version =
description =
author =
name = %(name)s
version = %(version)s
description = %(description)s
author = %(author)s
"""
changelog = u"""[1]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment