Merge lp:~gesha/linaro-license-protection/1218356 into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Milo Casagrande
Approved revision: 217
Merged at revision: 216
Proposed branch: lp:~gesha/linaro-license-protection/1218356
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 80 lines (+34/-3)
2 files modified
license_protected_downloads/views.py (+32/-3)
settings.py (+2/-0)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/1218356
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+186059@code.launchpad.net

Description of the change

This branch adds git description tab on snapshots/releases with projects information from annotated source manifest.

To post a comment you must log in.
217. By Georgy Redkozubov

Adds git description tab with data from annotated source manifest for passing to android-build.l.o.

Revision history for this message
Milo Casagrande (milo) wrote :

Hey Georgy,

thanks for working on this.
It looks good to go, the only comment I have is here:

+ for i, n in enumerate(nodes):
+ if n.nodeType == n.COMMENT_NODE:
+ comment = nodes[i]
+ commentedNode = nodes[i + 2]
+ text += line % (commentedNode.getAttribute('name'),
+ comment.data.strip())
+

Can you give more meaningful name to "i" and "n"? "index" and "node" should be fine I guess.
In case, please do when merging.

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/views.py'
2--- license_protected_downloads/views.py 2013-07-30 08:58:14 +0000
3+++ license_protected_downloads/views.py 2013-09-17 16:38:31 +0000
4@@ -33,6 +33,7 @@
5 import config
6 from common import safe_path_join
7 from group_auth_common import GroupAuthError
8+import xml.dom.minidom as dom
9
10
11 LINARO_INCLUDE_FILE_RE = re.compile(
12@@ -528,6 +529,9 @@
13 download = None
14 if 'dl' in request.GET:
15 download = request.GET['dl']
16+ rendered_files = RenderTextFiles.find_and_render(path)
17+ if os.path.exists(os.path.join(path, settings.ANNOTATED_XML)):
18+ rendered_files["Git Descriptions"] = render_descriptions(path)
19
20 return render_to_response('dir_template.html',
21 {'dirlist': dir_list(url, path),
22@@ -536,8 +540,7 @@
23 'revno': bzr_version.get_my_bzr_revno(),
24 'header_content': header_content,
25 'request': request,
26- 'rendered_files':
27- RenderTextFiles.find_and_render(path)
28+ 'rendered_files': rendered_files
29 })
30
31 # If the file listing doesn't contain the file requested for download,
32@@ -583,7 +586,11 @@
33
34 path = result[1]
35
36- return HttpResponse(json.dumps(RenderTextFiles.find_and_render(path)))
37+ rendered_files = RenderTextFiles.find_and_render(path)
38+ if os.path.exists(os.path.join(path, settings.ANNOTATED_XML)):
39+ rendered_files["Git Descriptions"] = render_descriptions(path)
40+
41+ return HttpResponse(json.dumps(rendered_files))
42
43
44 def get_remote_static(request):
45@@ -669,3 +676,25 @@
46 data = json.dumps({"licenses": license_list})
47
48 return HttpResponse(data, mimetype='application/json')
49+
50+
51+def render_descriptions(path):
52+ """
53+ Extracts project name and its description from annotated source manifest
54+ and returns html string to include in tab.
55+ """
56+ text = '<br>'
57+ line = '<strong>Project:</strong> "%s", ' \
58+ '<strong>Description:</strong> "%s"<br>'
59+ filename = os.path.join(path, settings.ANNOTATED_XML)
60+ xmldoc = dom.parse(filename)
61+ nodes = xmldoc.documentElement.childNodes
62+
63+ for i, n in enumerate(nodes):
64+ if n.nodeType == n.COMMENT_NODE:
65+ comment = nodes[i]
66+ commentedNode = nodes[i + 2]
67+ text += line % (commentedNode.getAttribute('name'),
68+ comment.data.strip())
69+
70+ return text
71
72=== modified file 'settings.py'
73--- settings.py 2013-07-30 09:20:02 +0000
74+++ settings.py 2013-09-17 16:38:31 +0000
75@@ -255,3 +255,5 @@
76 f.write(local_settings_content)
77
78 from local_settings import *
79+
80+ANNOTATED_XML = 'source-manifest-ann.xml'

Subscribers

People subscribed via source and target branches