summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-03-16 13:40:41 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-20 15:21:33 +0000
commit9ecdbc377c6ab6848afb0a378c5804918951f6b7 (patch)
tree6a399868e8e832298e94bd8a03eaf0b7728b7950 /bitbake/lib
parentdab638e150fb2af56f54f0752383965b016f4960 (diff)
downloadpoky-9ecdbc377c6ab6848afb0a378c5804918951f6b7.tar.gz
Hob: change the code style to enumerate a list in a for-loop
We use the more common style to enumerate a list in a for-loop (http://docs.python.org/library/functions.html#enumerate), that is: try to use for item in mylist, and try to use for i, item in enumerate(list) rather than for i in range(len(mylist)) (From Poky rev: 33c21bc60bd1542f81d33c328f116dec424728cd) (Bitbake rev: 9b168239a5d9693573438eb6514938b81de85af3) Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobwidget.py30
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/packageselectionpage.py10
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/recipeselectionpage.py10
3 files changed, 25 insertions, 25 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 2c3d8311d1..247bbd1de4 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -109,38 +109,38 @@ class HobViewTable (gtk.VBox):
109 self.toggle_columns = [] 109 self.toggle_columns = []
110 self.table_tree.connect("row-activated", self.row_activated_cb) 110 self.table_tree.connect("row-activated", self.row_activated_cb)
111 111
112 for i in range(len(columns)): 112 for i, column in enumerate(columns):
113 col = gtk.TreeViewColumn(columns[i]['col_name']) 113 col = gtk.TreeViewColumn(column['col_name'])
114 col.set_clickable(True) 114 col.set_clickable(True)
115 col.set_resizable(True) 115 col.set_resizable(True)
116 col.set_sort_column_id(columns[i]['col_id']) 116 col.set_sort_column_id(column['col_id'])
117 if 'col_min' in columns[i].keys(): 117 if 'col_min' in column.keys():
118 col.set_min_width(columns[i]['col_min']) 118 col.set_min_width(column['col_min'])
119 if 'col_max' in columns[i].keys(): 119 if 'col_max' in column.keys():
120 col.set_max_width(columns[i]['col_max']) 120 col.set_max_width(column['col_max'])
121 self.table_tree.append_column(col) 121 self.table_tree.append_column(col)
122 122
123 if (not 'col_style' in columns[i].keys()) or columns[i]['col_style'] == 'text': 123 if (not 'col_style' in column.keys()) or column['col_style'] == 'text':
124 cell = gtk.CellRendererText() 124 cell = gtk.CellRendererText()
125 col.pack_start(cell, True) 125 col.pack_start(cell, True)
126 col.set_attributes(cell, text=columns[i]['col_id']) 126 col.set_attributes(cell, text=column['col_id'])
127 elif columns[i]['col_style'] == 'check toggle': 127 elif column['col_style'] == 'check toggle':
128 cell = gtk.CellRendererToggle() 128 cell = gtk.CellRendererToggle()
129 cell.set_property('activatable', True) 129 cell.set_property('activatable', True)
130 cell.connect("toggled", self.toggled_cb, i, self.table_tree) 130 cell.connect("toggled", self.toggled_cb, i, self.table_tree)
131 self.toggle_id = i 131 self.toggle_id = i
132 col.pack_end(cell, True) 132 col.pack_end(cell, True)
133 col.set_attributes(cell, active=columns[i]['col_id']) 133 col.set_attributes(cell, active=column['col_id'])
134 self.toggle_columns.append(columns[i]['col_name']) 134 self.toggle_columns.append(column['col_name'])
135 elif columns[i]['col_style'] == 'radio toggle': 135 elif column['col_style'] == 'radio toggle':
136 cell = gtk.CellRendererToggle() 136 cell = gtk.CellRendererToggle()
137 cell.set_property('activatable', True) 137 cell.set_property('activatable', True)
138 cell.set_radio(True) 138 cell.set_radio(True)
139 cell.connect("toggled", self.toggled_cb, i, self.table_tree) 139 cell.connect("toggled", self.toggled_cb, i, self.table_tree)
140 self.toggle_id = i 140 self.toggle_id = i
141 col.pack_end(cell, True) 141 col.pack_end(cell, True)
142 col.set_attributes(cell, active=columns[i]['col_id']) 142 col.set_attributes(cell, active=column['col_id'])
143 self.toggle_columns.append(columns[i]['col_name']) 143 self.toggle_columns.append(column['col_name'])
144 144
145 scroll = gtk.ScrolledWindow() 145 scroll = gtk.ScrolledWindow()
146 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) 146 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
index 3cd1c5e725..23e460caa0 100755
--- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -105,16 +105,16 @@ class PackageSelectionPage (HobPage):
105 self.ins = HobNotebook() 105 self.ins = HobNotebook()
106 self.tables = [] # we need to modify table when the dialog is shown 106 self.tables = [] # we need to modify table when the dialog is shown
107 # append the tab 107 # append the tab
108 for i in range(len(self.pages)): 108 for page in self.pages:
109 columns = self.pages[i]['columns'] 109 columns = page['columns']
110 tab = HobViewTable(columns) 110 tab = HobViewTable(columns)
111 filter = self.pages[i]['filter'] 111 filter = page['filter']
112 tab.set_model(self.package_model.tree_model(filter)) 112 tab.set_model(self.package_model.tree_model(filter))
113 tab.connect("toggled", self.table_toggled_cb) 113 tab.connect("toggled", self.table_toggled_cb)
114 if self.pages[i]['name'] == "Included": 114 if page['name'] == "Included":
115 tab.connect("row-activated", self.tree_row_activated_cb) 115 tab.connect("row-activated", self.tree_row_activated_cb)
116 116
117 label = gtk.Label(self.pages[i]['name']) 117 label = gtk.Label(page['name'])
118 self.ins.append_page(tab, label) 118 self.ins.append_page(tab, label)
119 self.tables.append(tab) 119 self.tables.append(tab)
120 120
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
index db873b611a..6dd7c1e473 100755
--- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
@@ -127,16 +127,16 @@ class RecipeSelectionPage (HobPage):
127 self.ins = HobNotebook() 127 self.ins = HobNotebook()
128 self.tables = [] # we need modify table when the dialog is shown 128 self.tables = [] # we need modify table when the dialog is shown
129 # append the tabs in order 129 # append the tabs in order
130 for i in range(len(self.pages)): 130 for page in self.pages:
131 columns = self.pages[i]['columns'] 131 columns = page['columns']
132 tab = HobViewTable(columns) 132 tab = HobViewTable(columns)
133 filter = self.pages[i]['filter'] 133 filter = page['filter']
134 tab.set_model(self.recipe_model.tree_model(filter)) 134 tab.set_model(self.recipe_model.tree_model(filter))
135 tab.connect("toggled", self.table_toggled_cb) 135 tab.connect("toggled", self.table_toggled_cb)
136 if self.pages[i]['name'] == "Included": 136 if page['name'] == "Included":
137 tab.connect("row-activated", self.tree_row_activated_cb) 137 tab.connect("row-activated", self.tree_row_activated_cb)
138 138
139 label = gtk.Label(self.pages[i]['name']) 139 label = gtk.Label(page['name'])
140 self.ins.append_page(tab, label) 140 self.ins.append_page(tab, label)
141 self.tables.append(tab) 141 self.tables.append(tab)
142 142