diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-05-18 12:03:00 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-29 11:59:44 +0100 |
commit | 6a9efefbba615b48d82024487d1ea7f3e4c101ef (patch) | |
tree | 5300465b9a236615893ffce9f2e6e3279e8a33f9 /bitbake/lib/toaster/toastergui/templatetags/projecttags.py | |
parent | 9dcfa32cf122d8748579043f68d447079bc5bf0c (diff) | |
download | poky-6a9efefbba615b48d82024487d1ea7f3e4c101ef.tar.gz |
bitbake: toastergui: show relative paths in configvars view
Reworked filtering of config paths.
Stripped clone paths, topdir and its parent directory from the paths
to config files in configvars view.
[YOCTO #7463]
(Bitbake rev: 873087b11653848ec2704d67de5680a265b71eaa)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templatetags/projecttags.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index 54700e3842..1bc3bc2319 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py | |||
@@ -20,6 +20,7 @@ | |||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 | 21 | ||
22 | from datetime import datetime, timedelta | 22 | from datetime import datetime, timedelta |
23 | from os.path import relpath | ||
23 | import re | 24 | import re |
24 | from django import template | 25 | from django import template |
25 | from django.utils import timezone | 26 | from django.utils import timezone |
@@ -182,47 +183,23 @@ def variable_parent_name(value): | |||
182 | return re.sub('_[a-z].*', '', value) | 183 | return re.sub('_[a-z].*', '', value) |
183 | 184 | ||
184 | @register.filter | 185 | @register.filter |
185 | def filter_setin_files(file_list,matchstr): | 186 | def filter_setin_files(file_list, matchstr): |
186 | """ filter/search the 'set in' file lists. Note | 187 | """Filter/search the 'set in' file lists.""" |
187 | that this output is not autoescaped to allow | 188 | result = [] |
188 | the <p> marks, but this is safe as the data | 189 | search, filter = matchstr.split(':') |
189 | is file paths | 190 | for pattern in (search, filter): |
190 | """ | 191 | if pattern: |
191 | 192 | for fobj in file_list: | |
192 | # no filters, show last file (if any) | 193 | fname = fobj.file_name |
193 | if matchstr == ":": | 194 | if fname not in result and re.search(pattern, fname): |
194 | if file_list: | 195 | result.append(fname) |
195 | return file_list[len(file_list)-1].file_name | 196 | |
196 | else: | 197 | # no filter, show last file (if any) |
197 | return '' | 198 | last = list(file_list)[-1].file_name |
198 | 199 | if not filter and last not in result: | |
199 | search, filter = matchstr.partition(':')[::2] | 200 | result.append(last) |
200 | htmlstr="" | 201 | |
201 | # match only filters | 202 | return result |
202 | if search == '': | ||
203 | for i in range(len(file_list)): | ||
204 | if re.search(filter, file_list[i].file_name): | ||
205 | if htmlstr.find(file_list[i].file_name + "<p>") < 0: | ||
206 | htmlstr += file_list[i].file_name + "<p>" | ||
207 | return htmlstr | ||
208 | |||
209 | # match only search string, plus always last file | ||
210 | if filter == "": | ||
211 | for i in range(len(file_list)-1): | ||
212 | if re.search(search,file_list[i].file_name): | ||
213 | if htmlstr.find(file_list[i].file_name + "<p>") < 0: | ||
214 | htmlstr += file_list[i].file_name + "<p>" | ||
215 | if htmlstr.find(file_list[len(file_list)-1].file_name) < 0: | ||
216 | htmlstr += file_list[len(file_list)-1].file_name | ||
217 | return htmlstr | ||
218 | |||
219 | # match filter or search string | ||
220 | for i in range(len(file_list)): | ||
221 | if re.search(filter, file_list[i].file_name) or re.search(search,file_list[i].file_name): | ||
222 | if htmlstr.find(file_list[i].file_name + "<p>") < 0: | ||
223 | htmlstr += file_list[i].file_name + "<p>" | ||
224 | return htmlstr | ||
225 | |||
226 | 203 | ||
227 | @register.filter | 204 | @register.filter |
228 | def string_slice(strvar,slicevar): | 205 | def string_slice(strvar,slicevar): |
@@ -313,16 +290,9 @@ def is_shaid(text): | |||
313 | return False | 290 | return False |
314 | 291 | ||
315 | @register.filter | 292 | @register.filter |
316 | def cut_layer_path_prefix(fullpath,layer_names): | 293 | def cut_path_prefix(fullpath, prefixes): |
317 | ### if some part of the full local path to a layer matches | 294 | """Cut path prefix from fullpath.""" |
318 | ### an entry in layer_names (sorted desc), return the layer | 295 | for prefix in prefixes: |
319 | ### name relative path. | 296 | if fullpath.startswith(prefix): |
320 | for lname in layer_names: | 297 | return relpath(fullpath, prefix) |
321 | # import rpdb; rpdb.set_trace() | ||
322 | # only try layer names that are non-trivial to avoid false matches | ||
323 | if len(lname) >= 4: | ||
324 | # match layer name with as a subdir / or for remote layers /_ | ||
325 | if re.search('/' + lname, fullpath) or re.search('/_' + lname, fullpath): | ||
326 | parts = re.split(lname, fullpath, 1) | ||
327 | return lname + parts[1] | ||
328 | return fullpath | 298 | return fullpath |