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
=== modified file 'license_protected_downloads/views.py'
--- license_protected_downloads/views.py 2013-07-30 08:58:14 +0000
+++ license_protected_downloads/views.py 2013-09-17 16:38:31 +0000
@@ -33,6 +33,7 @@
33import config33import config
34from common import safe_path_join34from common import safe_path_join
35from group_auth_common import GroupAuthError35from group_auth_common import GroupAuthError
36import xml.dom.minidom as dom
3637
3738
38LINARO_INCLUDE_FILE_RE = re.compile(39LINARO_INCLUDE_FILE_RE = re.compile(
@@ -528,6 +529,9 @@
528 download = None529 download = None
529 if 'dl' in request.GET:530 if 'dl' in request.GET:
530 download = request.GET['dl']531 download = request.GET['dl']
532 rendered_files = RenderTextFiles.find_and_render(path)
533 if os.path.exists(os.path.join(path, settings.ANNOTATED_XML)):
534 rendered_files["Git Descriptions"] = render_descriptions(path)
531535
532 return render_to_response('dir_template.html',536 return render_to_response('dir_template.html',
533 {'dirlist': dir_list(url, path),537 {'dirlist': dir_list(url, path),
@@ -536,8 +540,7 @@
536 'revno': bzr_version.get_my_bzr_revno(),540 'revno': bzr_version.get_my_bzr_revno(),
537 'header_content': header_content,541 'header_content': header_content,
538 'request': request,542 'request': request,
539 'rendered_files':543 'rendered_files': rendered_files
540 RenderTextFiles.find_and_render(path)
541 })544 })
542545
543 # If the file listing doesn't contain the file requested for download,546 # If the file listing doesn't contain the file requested for download,
@@ -583,7 +586,11 @@
583586
584 path = result[1]587 path = result[1]
585588
586 return HttpResponse(json.dumps(RenderTextFiles.find_and_render(path)))589 rendered_files = RenderTextFiles.find_and_render(path)
590 if os.path.exists(os.path.join(path, settings.ANNOTATED_XML)):
591 rendered_files["Git Descriptions"] = render_descriptions(path)
592
593 return HttpResponse(json.dumps(rendered_files))
587594
588595
589def get_remote_static(request):596def get_remote_static(request):
@@ -669,3 +676,25 @@
669 data = json.dumps({"licenses": license_list})676 data = json.dumps({"licenses": license_list})
670677
671 return HttpResponse(data, mimetype='application/json')678 return HttpResponse(data, mimetype='application/json')
679
680
681def render_descriptions(path):
682 """
683 Extracts project name and its description from annotated source manifest
684 and returns html string to include in tab.
685 """
686 text = '<br>'
687 line = '<strong>Project:</strong> "%s", ' \
688 '<strong>Description:</strong> "%s"<br>'
689 filename = os.path.join(path, settings.ANNOTATED_XML)
690 xmldoc = dom.parse(filename)
691 nodes = xmldoc.documentElement.childNodes
692
693 for i, n in enumerate(nodes):
694 if n.nodeType == n.COMMENT_NODE:
695 comment = nodes[i]
696 commentedNode = nodes[i + 2]
697 text += line % (commentedNode.getAttribute('name'),
698 comment.data.strip())
699
700 return text
672701
=== modified file 'settings.py'
--- settings.py 2013-07-30 09:20:02 +0000
+++ settings.py 2013-09-17 16:38:31 +0000
@@ -255,3 +255,5 @@
255 f.write(local_settings_content)255 f.write(local_settings_content)
256256
257 from local_settings import *257 from local_settings import *
258
259ANNOTATED_XML = 'source-manifest-ann.xml'

Subscribers

People subscribed via source and target branches