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
=== modified file 'license_protected_downloads/render_text_files.py'
--- license_protected_downloads/render_text_files.py 2012-10-15 11:14:42 +0000
+++ license_protected_downloads/render_text_files.py 2012-10-16 12:07:32 +0000
@@ -25,12 +25,25 @@
25 pass25 pass
2626
27 @classmethod27 @classmethod
28 def sort_paths_list_by_files_list(cls, a, b):
29 base_list = ANDROID_FILES + UBUNTU_FILES
30 return base_list.index(os.path.basename(a)) - \
31 base_list.index(os.path.basename(b))
32
33 @classmethod
28 def find_and_render(cls, path):34 def find_and_render(cls, path):
2935
30 result = {}36 result = {}
3137
32 try:38 try:
39<<<<<<< TREE
33 filepaths = cls.find_relevant_files(path)40 filepaths = cls.find_relevant_files(path)
41=======
42 # This method should raise some custom error if there is more
43 # then one file of the same type recursively found.
44 filepaths = sorted(cls.find_relevant_files(path),
45 cmp=cls.sort_paths_list_by_files_list)
46>>>>>>> MERGE-SOURCE
34 except:47 except:
35 # This is ok, no tabs when none is returned.48 # This is ok, no tabs when none is returned.
36 return None49 return None
@@ -64,12 +77,14 @@
64 # written above.77 # written above.
65 multiple = 078 multiple = 0
66 filepaths = cls.dirEntries(path, True, UBUNTU_FILES, ANDROID_FILES)79 filepaths = cls.dirEntries(path, True, UBUNTU_FILES, ANDROID_FILES)
67 if len(filepaths)>0:80 if len(filepaths) > 0:
68 for filepath in UBUNTU_FILES:81 for filepath in UBUNTU_FILES:
69 if len(cls.findall(filepaths, lambda x: re.search(filepath, x)))>1:82 if len(cls.findall(filepaths,
83 lambda x: re.search(filepath, x))) > 1:
70 multiple += 184 multiple += 1
71 for filepath in ANDROID_FILES:85 for filepath in ANDROID_FILES:
72 if len(cls.findall(filepaths, lambda x: re.search(filepath, x)))>1:86 if len(cls.findall(filepaths,
87 lambda x: re.search(filepath, x))) > 1:
73 multiple += 188 multiple += 1
74 if multiple == 0:89 if multiple == 0:
75 return filepaths90 return filepaths
@@ -122,7 +137,7 @@
122 def findall(cls, L, test):137 def findall(cls, L, test):
123 ''' Return indices of list items that pass the 'test'138 ''' Return indices of list items that pass the 'test'
124 '''139 '''
125 i=0140 i = 0
126 indices = []141 indices = []
127 while(True):142 while(True):
128 try:143 try:
@@ -132,7 +147,7 @@
132 # by searching the value in L[i:]147 # by searching the value in L[i:]
133 indices.append(L.index(nextvalue, i))148 indices.append(L.index(nextvalue, i))
134 # iterate i, that is the next index from where to search149 # iterate i, that is the next index from where to search
135 i=indices[-1]+1150 i = indices[-1] + 1
136 # when there is no further "good value", filter returns [],151 # when there is no further "good value", filter returns [],
137 # hence there is an out of range exception152 # hence there is an out of range exception
138 except IndexError:153 except IndexError:
139154
=== modified file 'license_protected_downloads/tests/test_render_text_files.py'
--- license_protected_downloads/tests/test_render_text_files.py 2012-10-16 07:09:04 +0000
+++ license_protected_downloads/tests/test_render_text_files.py 2012-10-16 12:07:32 +0000
@@ -5,8 +5,8 @@
5import re5import re
6from license_protected_downloads.render_text_files import RenderTextFiles6from license_protected_downloads.render_text_files import RenderTextFiles
7from license_protected_downloads.render_text_files import NoFilesException7from license_protected_downloads.render_text_files import NoFilesException
8from license_protected_downloads.render_text_files import \8from license_protected_downloads.render_text_files \
9 MultipleFilesException9 import MultipleFilesException
10from license_protected_downloads.render_text_files import ANDROID_FILES10from license_protected_downloads.render_text_files import ANDROID_FILES
11from license_protected_downloads.render_text_files import UBUNTU_FILES11from license_protected_downloads.render_text_files import UBUNTU_FILES
1212
@@ -125,3 +125,14 @@
125 sorted(RenderTextFiles.find_relevant_files(android_path)))125 sorted(RenderTextFiles.find_relevant_files(android_path)))
126 self.assertEqual(sorted(full_ubuntu_files),126 self.assertEqual(sorted(full_ubuntu_files),
127 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))127 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))
128
129 def test_sort_paths_list_by_files_list(self):
130 path = self.make_temp_dir(empty=False, file_list=UBUNTU_FILES)
131 full_ubuntu_files = []
132 for file in UBUNTU_FILES:
133 full_ubuntu_files.append(os.path.join(path, file))
134 paths_list = RenderTextFiles.find_relevant_files(path)
135 self.assertEqual(full_ubuntu_files,
136 sorted(paths_list,
137 cmp=RenderTextFiles.sort_paths_list_by_files_list))
138 self.assertNotEqual(full_ubuntu_files, paths_list)

Subscribers

People subscribed via source and target branches