summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-08-17 20:17:42 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-08-23 10:00:32 -0700
commitc1b31f899675bafd4b69e567299f968a0a52cc2e (patch)
tree1e561c08b3b682124d3e9bcaf86eb9bd2683164a /bitbake/lib
parent108220137bc51b10f4053df64f3c84195906b7a8 (diff)
downloadpoky-c1b31f899675bafd4b69e567299f968a0a52cc2e.tar.gz
bb/ui/crumbs/tasklistmodel: more robust checking for substrings
Relying on the count() method of Str to determine whether the string contains a substring is error prone purely because the return value doesn't strictly convert to a Boolean value. To that end take the more pythonic approach of using the in operator (foo in bar) to check for the substring. Further, add a helper method for the common case of testing whether a pn is -native, -cross or virtual/ (Bitbake rev: d7768cefcddd59a5102d7e9b67e4416bf8603f55) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/ui/crumbs/tasklistmodel.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/tasklistmodel.py b/bitbake/lib/bb/ui/crumbs/tasklistmodel.py
index 203b6284ac..fa16609678 100644
--- a/bitbake/lib/bb/ui/crumbs/tasklistmodel.py
+++ b/bitbake/lib/bb/ui/crumbs/tasklistmodel.py
@@ -124,6 +124,14 @@ class TaskListModel(gtk.ListStore):
124 gobject.TYPE_BOOLEAN, 124 gobject.TYPE_BOOLEAN,
125 gobject.TYPE_STRING) 125 gobject.TYPE_STRING)
126 126
127 """
128 Helper method to determine whether name is a target pn
129 """
130 def non_target_name(self, name):
131 if ('-native' in name) or ('-cross' in name) or name.startswith('virtual/'):
132 return True
133 return False
134
127 def contents_changed_cb(self, tree_model, path, it=None): 135 def contents_changed_cb(self, tree_model, path, it=None):
128 pkg_cnt = self.contents.iter_n_children(None) 136 pkg_cnt = self.contents.iter_n_children(None)
129 self.emit("contents-changed", pkg_cnt) 137 self.emit("contents-changed", pkg_cnt)
@@ -132,7 +140,7 @@ class TaskListModel(gtk.ListStore):
132 if not model.get_value(it, self.COL_INC) or model.get_value(it, self.COL_TYPE) == 'image': 140 if not model.get_value(it, self.COL_INC) or model.get_value(it, self.COL_TYPE) == 'image':
133 return False 141 return False
134 name = model.get_value(it, self.COL_NAME) 142 name = model.get_value(it, self.COL_NAME)
135 if name.count('-native') or name.count('-cross'): 143 if self.non_target_name(name):
136 return False 144 return False
137 else: 145 else:
138 return True 146 return True
@@ -196,7 +204,7 @@ class TaskListModel(gtk.ListStore):
196 return False 204 return False
197 else: 205 else:
198 name = model.get_value(it, self.COL_NAME) 206 name = model.get_value(it, self.COL_NAME)
199 if name.count('-native') or name.count('-cross'): 207 if self.non_target_name(name):
200 return False 208 return False
201 return True 209 return True
202 210
@@ -226,9 +234,9 @@ class TaskListModel(gtk.ListStore):
226 lic = event_model["pn"][item]["license"] 234 lic = event_model["pn"][item]["license"]
227 group = event_model["pn"][item]["section"] 235 group = event_model["pn"][item]["section"]
228 filename = event_model["pn"][item]["filename"] 236 filename = event_model["pn"][item]["filename"]
229 if name.count('task-') > 0: 237 if ('task-' in name):
230 atype = 'task' 238 atype = 'task'
231 elif name.count('-image-') > 0: 239 elif ('-image-' in name):
232 atype = 'image' 240 atype = 'image'
233 241
234 depends = event_model["depends"].get(item, []) 242 depends = event_model["depends"].get(item, [])
@@ -352,14 +360,14 @@ class TaskListModel(gtk.ListStore):
352 # If the iterated item is included and depends on the removed 360 # If the iterated item is included and depends on the removed
353 # item it should also be removed. 361 # item it should also be removed.
354 # FIXME: need to ensure partial name matching doesn't happen 362 # FIXME: need to ensure partial name matching doesn't happen
355 if inc and deps.count(marked_name) and itname not in removed: 363 if inc and marked_name in deps and itname not in removed:
356 # found a dependency, remove it 364 # found a dependency, remove it
357 removed.append(itname) 365 removed.append(itname)
358 self.mark(path) 366 self.mark(path)
359 367
360 # If the iterated item was brought in by the removed (passed) item 368 # If the iterated item was brought in by the removed (passed) item
361 # try and find an alternative dependee and update the binb column 369 # try and find an alternative dependee and update the binb column
362 if inc and binb.count(marked_name): 370 if inc and marked_name in binb:
363 bib = self.find_alt_dependency(itname) 371 bib = self.find_alt_dependency(itname)
364 self[path][self.COL_BINB] = bib 372 self[path][self.COL_BINB] = bib
365 373
@@ -411,7 +419,7 @@ class TaskListModel(gtk.ListStore):
411 deps = self.contents[path][self.COL_DEPS] 419 deps = self.contents[path][self.COL_DEPS]
412 itname = self.contents[path][self.COL_NAME] 420 itname = self.contents[path][self.COL_NAME]
413 inc = self.contents[path][self.COL_INC] 421 inc = self.contents[path][self.COL_INC]
414 if itname != name and inc and deps.count(name) > 0: 422 if itname != name and inc and name in deps:
415 # if this item depends on the item, return this items name 423 # if this item depends on the item, return this items name
416 return itname 424 return itname
417 it = self.contents.iter_next(it) 425 it = self.contents.iter_next(it)
@@ -471,7 +479,7 @@ class TaskListModel(gtk.ListStore):
471 def find_path_for_item(self, item_name): 479 def find_path_for_item(self, item_name):
472 # We don't include virtual/* or *-native items in the model so save a 480 # We don't include virtual/* or *-native items in the model so save a
473 # heavy iteration loop by exiting early for these items 481 # heavy iteration loop by exiting early for these items
474 if item_name.startswith("virtual/") or item_name.count('-native') or item_name.count('-cross'): 482 if self.non_target_name(item_name):
475 return None 483 return None
476 484
477 it = self.get_iter_first() 485 it = self.get_iter_first()
@@ -561,7 +569,7 @@ class TaskListModel(gtk.ListStore):
561 if not itype == 'package': 569 if not itype == 'package':
562 continue 570 continue
563 571
564 if deps.count(pn) != 0: 572 if pn not in deps:
565 revdeps.append(name) 573 revdeps.append(name)
566 574
567 if pn in revdeps: 575 if pn in revdeps: