Merge lp:~gesha/linaro-license-protection/textile-view into lp:~linaro-infrastructure/linaro-license-protection/textile-view

Proposed by Georgy Redkozubov
Status: Merged
Merged at revision: 141
Proposed branch: lp:~gesha/linaro-license-protection/textile-view
Merge into: lp:~linaro-infrastructure/linaro-license-protection/textile-view
Diff against target: 95 lines (+33/-7) (has conflicts)
2 files modified
license_protected_downloads/render_text_files.py (+20/-5)
license_protected_downloads/tests/test_render_text_files.py (+13/-2)
Text conflict in license_protected_downloads/render_text_files.py
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/textile-view
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+129863@code.launchpad.net

Description of the change

These revs add sorting to the list of paths based on pre-defined list of files to display and pep8 fixes.

To post a comment you must log in.
Revision history for this message
Milo Casagrande (milo) wrote :

Gesha, there are some conflicts in the merge. Can you please take a look?

Revision history for this message
Stevan Radaković (stevanr) wrote :

Yea I updated the target branch directly yesterday.. Just remove those two comment lines (since we've implemented exceptions already) and you can resolve.
Other then that, approve +1.

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-15 11:14:42 +0000
3+++ license_protected_downloads/render_text_files.py 2012-10-16 12:07:32 +0000
4@@ -25,12 +25,25 @@
5 pass
6
7 @classmethod
8+ def sort_paths_list_by_files_list(cls, a, b):
9+ base_list = ANDROID_FILES + UBUNTU_FILES
10+ return base_list.index(os.path.basename(a)) - \
11+ base_list.index(os.path.basename(b))
12+
13+ @classmethod
14 def find_and_render(cls, path):
15
16 result = {}
17
18 try:
19+<<<<<<< TREE
20 filepaths = cls.find_relevant_files(path)
21+=======
22+ # This method should raise some custom error if there is more
23+ # then one file of the same type recursively found.
24+ filepaths = sorted(cls.find_relevant_files(path),
25+ cmp=cls.sort_paths_list_by_files_list)
26+>>>>>>> MERGE-SOURCE
27 except:
28 # This is ok, no tabs when none is returned.
29 return None
30@@ -64,12 +77,14 @@
31 # written above.
32 multiple = 0
33 filepaths = cls.dirEntries(path, True, UBUNTU_FILES, ANDROID_FILES)
34- if len(filepaths)>0:
35+ if len(filepaths) > 0:
36 for filepath in UBUNTU_FILES:
37- if len(cls.findall(filepaths, lambda x: re.search(filepath, x)))>1:
38+ if len(cls.findall(filepaths,
39+ lambda x: re.search(filepath, x))) > 1:
40 multiple += 1
41 for filepath in ANDROID_FILES:
42- if len(cls.findall(filepaths, lambda x: re.search(filepath, x)))>1:
43+ if len(cls.findall(filepaths,
44+ lambda x: re.search(filepath, x))) > 1:
45 multiple += 1
46 if multiple == 0:
47 return filepaths
48@@ -122,7 +137,7 @@
49 def findall(cls, L, test):
50 ''' Return indices of list items that pass the 'test'
51 '''
52- i=0
53+ i = 0
54 indices = []
55 while(True):
56 try:
57@@ -132,7 +147,7 @@
58 # by searching the value in L[i:]
59 indices.append(L.index(nextvalue, i))
60 # iterate i, that is the next index from where to search
61- i=indices[-1]+1
62+ i = indices[-1] + 1
63 # when there is no further "good value", filter returns [],
64 # hence there is an out of range exception
65 except IndexError:
66
67=== modified file 'license_protected_downloads/tests/test_render_text_files.py'
68--- license_protected_downloads/tests/test_render_text_files.py 2012-10-16 07:09:04 +0000
69+++ license_protected_downloads/tests/test_render_text_files.py 2012-10-16 12:07:32 +0000
70@@ -5,8 +5,8 @@
71 import re
72 from license_protected_downloads.render_text_files import RenderTextFiles
73 from license_protected_downloads.render_text_files import NoFilesException
74-from license_protected_downloads.render_text_files import \
75- MultipleFilesException
76+from license_protected_downloads.render_text_files \
77+ import MultipleFilesException
78 from license_protected_downloads.render_text_files import ANDROID_FILES
79 from license_protected_downloads.render_text_files import UBUNTU_FILES
80
81@@ -125,3 +125,14 @@
82 sorted(RenderTextFiles.find_relevant_files(android_path)))
83 self.assertEqual(sorted(full_ubuntu_files),
84 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))
85+
86+ def test_sort_paths_list_by_files_list(self):
87+ path = self.make_temp_dir(empty=False, file_list=UBUNTU_FILES)
88+ full_ubuntu_files = []
89+ for file in UBUNTU_FILES:
90+ full_ubuntu_files.append(os.path.join(path, file))
91+ paths_list = RenderTextFiles.find_relevant_files(path)
92+ self.assertEqual(full_ubuntu_files,
93+ sorted(paths_list,
94+ cmp=RenderTextFiles.sort_paths_list_by_files_list))
95+ self.assertNotEqual(full_ubuntu_files, paths_list)

Subscribers

People subscribed via source and target branches