Merge lp:~mvo/click/lp1324853-manifest into lp:click/devel

Proposed by Michael Vogt
Status: Merged
Merged at revision: 494
Proposed branch: lp:~mvo/click/lp1324853-manifest
Merge into: lp:click/devel
Diff against target: 48 lines (+22/-9)
1 file modified
click/commands/info.py (+22/-9)
To merge this branch: bzr merge lp:~mvo/click/lp1324853-manifest
Reviewer Review Type Date Requested Status
Colin Watson Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+224238@code.launchpad.net

Commit message

Add "click info" interface to get manifest corresponding to file in installed package.

Description of the change

This branch implements a CLI interface to get the manifest of the click package that the file given belongs to.

E.g.
$ click info /opt/click.ubuntu.com/com.ubuntu.calendar/0.4/EventListModel.qml
{
    "description": "Calendar application for Ubuntu devices",
...
}

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Oops, duplicate. Anyway, needs a test, but I can deal with that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click/commands/info.py'
2--- click/commands/info.py 2014-04-03 08:52:02 +0000
3+++ click/commands/info.py 2014-06-24 06:33:04 +0000
4@@ -26,6 +26,13 @@
5
6 from click.install import DebFile
7 from click.json_helpers import json_object_to_python
8+def _load_manifest(manifest_file):
9+ manifest = json.load(manifest_file)
10+ keys = list(manifest)
11+ for key in keys:
12+ if key.startswith("_"):
13+ del manifest[key]
14+ return manifest
15
16
17 def get_manifest(options, arg):
18@@ -38,15 +45,21 @@
19 if registry.has_package_name(arg):
20 return json_object_to_python(registry.get_manifest(arg))
21
22- with closing(DebFile(filename=arg)) as package:
23- with package.control.get_file(
24- "manifest", encoding="UTF-8") as manifest_file:
25- manifest = json.load(manifest_file)
26- keys = list(manifest)
27- for key in keys:
28- if key.startswith("_"):
29- del manifest[key]
30- return manifest
31+ if arg.endswith(".click"):
32+ with closing(DebFile(filename=arg)) as package:
33+ with package.control.get_file(
34+ "manifest", encoding="UTF-8") as manifest_file:
35+ return _load_manifest(manifest_file)
36+ else:
37+ import glob, os
38+ pkgdir = Click.find_package_directory(arg)
39+ manifest_path = glob.glob(
40+ os.path.join(pkgdir, ".click", "info", "*.manifest"))
41+ if len(manifest_path) > 1:
42+ raise Exception("Multiple manifest files found in '%s'" % (
43+ manifest_path))
44+ with open(manifest_path[0]) as f:
45+ return _load_manifest(f)
46
47
48 def run(argv):

Subscribers

People subscribed via source and target branches

to all changes: