Merge lp:~stevanr/linaro-license-protection/fix-fallback-textile-order into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Approved by: Georgy Redkozubov
Approved revision: 137
Merged at revision: 137
Proposed branch: lp:~stevanr/linaro-license-protection/fix-fallback-textile-order
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 51 lines (+14/-7)
1 file modified
license_protected_downloads/render_text_files.py (+14/-7)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/fix-fallback-textile-order
Reviewer Review Type Date Requested Status
Georgy Redkozubov Approve
Review via email: mp+130574@code.launchpad.net

Description of the change

Fix sorting when fallbacks kick in.

To post a comment you must log in.
Revision history for this message
Georgy Redkozubov (gesha) wrote :

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/render_text_files.py'
2--- license_protected_downloads/render_text_files.py 2012-10-19 12:36:15 +0000
3+++ license_protected_downloads/render_text_files.py 2012-10-19 15:21:22 +0000
4@@ -30,6 +30,11 @@
5 'FIRMWARE': 'Firmware Update',
6 'RTSM': 'RTSM'}
7
8+TAB_PRIORITY = ['Release Notes',
9+ 'Binary Image Installation',
10+ 'Building From Source',
11+ 'Firmware Update',
12+ 'RTSM']
13
14 class MultipleFilesException(Exception):
15 pass
16@@ -41,19 +46,17 @@
17 pass
18
19 @classmethod
20- def sort_paths_list_by_files_list(cls, a, b):
21- base_list = ANDROID_FILES + UBUNTU_FILES
22- return base_list.index(os.path.basename(a)) - \
23- base_list.index(os.path.basename(b))
24+ def sort_tabs_by_priority(cls, a, b):
25+ base_list = TAB_PRIORITY
26+ return base_list.index(a[0]) - base_list.index(b[0])
27
28 @classmethod
29 def find_and_render(cls, path):
30
31- result = OrderedDict()
32+ result = {}
33
34 try:
35- filepaths = sorted(cls.find_relevant_files(path),
36- cmp=cls.sort_paths_list_by_files_list)
37+ filepaths = cls.find_relevant_files(path)
38 except:
39 # This is ok, no tabs when multiple returned.
40 return None
41@@ -75,6 +78,10 @@
42 if not filepaths and len(result) == 0:
43 return None
44
45+ result_items = sorted(result.items(), cmp=cls.sort_tabs_by_priority)
46+ result = OrderedDict()
47+ for v, k in result_items:
48+ result[v] = k
49 return result
50
51 @classmethod

Subscribers

People subscribed via source and target branches