summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templatetags/projecttags.py')
-rw-r--r--bitbake/lib/toaster/toastergui/templatetags/projecttags.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index b1e573b16d..857680b350 100644
--- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
@@ -129,3 +129,62 @@ def check_filter_status(options, filter):
129 if filter == option[1]: 129 if filter == option[1]:
130 return "" 130 return ""
131 return "checked" 131 return "checked"
132
133@register.filter
134def variable_parent_name(value):
135 """ filter extended variable names to the parent name
136 """
137 value=re.sub('_\$.*', '', value)
138 return re.sub('_[a-z].*', '', value)
139
140@register.filter
141def filter_setin_files(file_list,matchstr):
142 """ filter/search the 'set in' file lists. Note
143 that this output is not autoescaped to allow
144 the <p> marks, but this is safe as the data
145 is file paths
146 """
147
148 # no filters, show last file (if any)
149 if matchstr == ":":
150 if file_list:
151 return file_list[len(file_list)-1].file_name
152 else:
153 return ''
154
155 search, filter = matchstr.partition(':')[::2]
156 htmlstr=""
157 # match only filters
158 if search == '':
159 for i in range(len(file_list)):
160 if file_list[i].file_name.find(filter) >= 0:
161 htmlstr += file_list[i].file_name + "<p>"
162 return htmlstr
163
164 # match only search string, plus always last file
165 if filter == "":
166 for i in range(len(file_list)-1):
167 if file_list[i].file_name.find(search) >= 0:
168 htmlstr += file_list[i].file_name + "<p>"
169 htmlstr += file_list[len(file_list)-1].file_name
170 return htmlstr
171
172 # match filter or search string
173 for i in range(len(file_list)):
174 if (file_list[i].file_name.find(filter) >= 0) or (file_list[i].file_name.find(search) >= 0):
175 htmlstr += file_list[i].file_name + "<p>"
176 return htmlstr
177
178
179@register.filter
180def string_slice(strvar,slicevar):
181 """ slice a string with |string_slice:'[first]:[last]'
182 """
183 first,last= slicevar.partition(':')[::2]
184 if first=='':
185 return strvar[:int(last)]
186 elif last=='':
187 return strvar[int(first):]
188 else:
189 return strvar[int(first):int(last)]
190