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
=== modified file 'license_protected_downloads/render_text_files.py'
--- license_protected_downloads/render_text_files.py 2012-10-19 12:36:15 +0000
+++ license_protected_downloads/render_text_files.py 2012-10-19 15:21:22 +0000
@@ -30,6 +30,11 @@
30 'FIRMWARE': 'Firmware Update',30 'FIRMWARE': 'Firmware Update',
31 'RTSM': 'RTSM'}31 'RTSM': 'RTSM'}
3232
33TAB_PRIORITY = ['Release Notes',
34 'Binary Image Installation',
35 'Building From Source',
36 'Firmware Update',
37 'RTSM']
3338
34class MultipleFilesException(Exception):39class MultipleFilesException(Exception):
35 pass40 pass
@@ -41,19 +46,17 @@
41 pass46 pass
4247
43 @classmethod48 @classmethod
44 def sort_paths_list_by_files_list(cls, a, b):49 def sort_tabs_by_priority(cls, a, b):
45 base_list = ANDROID_FILES + UBUNTU_FILES50 base_list = TAB_PRIORITY
46 return base_list.index(os.path.basename(a)) - \51 return base_list.index(a[0]) - base_list.index(b[0])
47 base_list.index(os.path.basename(b))
4852
49 @classmethod53 @classmethod
50 def find_and_render(cls, path):54 def find_and_render(cls, path):
5155
52 result = OrderedDict()56 result = {}
5357
54 try:58 try:
55 filepaths = sorted(cls.find_relevant_files(path),59 filepaths = cls.find_relevant_files(path)
56 cmp=cls.sort_paths_list_by_files_list)
57 except:60 except:
58 # This is ok, no tabs when multiple returned.61 # This is ok, no tabs when multiple returned.
59 return None62 return None
@@ -75,6 +78,10 @@
75 if not filepaths and len(result) == 0:78 if not filepaths and len(result) == 0:
76 return None79 return None
7780
81 result_items = sorted(result.items(), cmp=cls.sort_tabs_by_priority)
82 result = OrderedDict()
83 for v, k in result_items:
84 result[v] = k
78 return result85 return result
7986
80 @classmethod87 @classmethod

Subscribers

People subscribed via source and target branches