Openembedded Bitbake Development
 help / color / mirror / Atom feed
From: Joshua Lock <josh@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH 04/12] Hob: change the code style to enumerate a list in a for-loop
Date: Mon, 19 Mar 2012 16:50:48 -0700	[thread overview]
Message-ID: <4F67C658.1040205@linux.intel.com> (raw)
In-Reply-To: <fecae981bde6d526f61722542f1c6265ac60e83e.1331910234.git.shane.wang@intel.com>



On 16/03/12 08:10, Shane Wang wrote:
> 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))
>
> Signed-off-by: Shane Wang<shane.wang@intel.com>

Thanks!

Signed-off-by: Joshua Lock <josh@linux.intel.com>

> ---
>   bitbake/lib/bb/ui/crumbs/hobwidget.py            |   30 +++++++++++-----------
>   bitbake/lib/bb/ui/crumbs/packageselectionpage.py |   10 +++---
>   bitbake/lib/bb/ui/crumbs/recipeselectionpage.py  |   10 +++---
>   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 2c3d831..247bbd1 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):
>           self.toggle_columns = []
>           self.table_tree.connect("row-activated", self.row_activated_cb)
>
> -        for i in range(len(columns)):
> -            col = gtk.TreeViewColumn(columns[i]['col_name'])
> +        for i, column in enumerate(columns):
> +            col = gtk.TreeViewColumn(column['col_name'])
>               col.set_clickable(True)
>               col.set_resizable(True)
> -            col.set_sort_column_id(columns[i]['col_id'])
> -            if 'col_min' in columns[i].keys():
> -                col.set_min_width(columns[i]['col_min'])
> -            if 'col_max' in columns[i].keys():
> -                col.set_max_width(columns[i]['col_max'])
> +            col.set_sort_column_id(column['col_id'])
> +            if 'col_min' in column.keys():
> +                col.set_min_width(column['col_min'])
> +            if 'col_max' in column.keys():
> +                col.set_max_width(column['col_max'])
>               self.table_tree.append_column(col)
>
> -            if (not 'col_style' in columns[i].keys()) or columns[i]['col_style'] == 'text':
> +            if (not 'col_style' in column.keys()) or column['col_style'] == 'text':
>                   cell = gtk.CellRendererText()
>                   col.pack_start(cell, True)
> -                col.set_attributes(cell, text=columns[i]['col_id'])
> -            elif columns[i]['col_style'] == 'check toggle':
> +                col.set_attributes(cell, text=column['col_id'])
> +            elif column['col_style'] == 'check toggle':
>                   cell = gtk.CellRendererToggle()
>                   cell.set_property('activatable', True)
>                   cell.connect("toggled", self.toggled_cb, i, self.table_tree)
>                   self.toggle_id = i
>                   col.pack_end(cell, True)
> -                col.set_attributes(cell, active=columns[i]['col_id'])
> -                self.toggle_columns.append(columns[i]['col_name'])
> -            elif columns[i]['col_style'] == 'radio toggle':
> +                col.set_attributes(cell, active=column['col_id'])
> +                self.toggle_columns.append(column['col_name'])
> +            elif column['col_style'] == 'radio toggle':
>                   cell = gtk.CellRendererToggle()
>                   cell.set_property('activatable', True)
>                   cell.set_radio(True)
>                   cell.connect("toggled", self.toggled_cb, i, self.table_tree)
>                   self.toggle_id = i
>                   col.pack_end(cell, True)
> -                col.set_attributes(cell, active=columns[i]['col_id'])
> -                self.toggle_columns.append(columns[i]['col_name'])
> +                col.set_attributes(cell, active=column['col_id'])
> +                self.toggle_columns.append(column['col_name'])
>
>           scroll = gtk.ScrolledWindow()
>           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 3cd1c5e..23e460c 100755
> --- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
> +++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
> @@ -105,16 +105,16 @@ class PackageSelectionPage (HobPage):
>           self.ins = HobNotebook()
>           self.tables = [] # we need to modify table when the dialog is shown
>           # append the tab
> -        for i in range(len(self.pages)):
> -            columns = self.pages[i]['columns']
> +        for page in self.pages:
> +            columns = page['columns']
>               tab = HobViewTable(columns)
> -            filter = self.pages[i]['filter']
> +            filter = page['filter']
>               tab.set_model(self.package_model.tree_model(filter))
>               tab.connect("toggled", self.table_toggled_cb)
> -            if self.pages[i]['name'] == "Included":
> +            if page['name'] == "Included":
>                   tab.connect("row-activated", self.tree_row_activated_cb)
>
> -            label = gtk.Label(self.pages[i]['name'])
> +            label = gtk.Label(page['name'])
>               self.ins.append_page(tab, label)
>               self.tables.append(tab)
>
> diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
> index db873b6..6dd7c1e 100755
> --- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
> +++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
> @@ -127,16 +127,16 @@ class RecipeSelectionPage (HobPage):
>           self.ins = HobNotebook()
>           self.tables = [] # we need modify table when the dialog is shown
>           # append the tabs in order
> -        for i in range(len(self.pages)):
> -            columns = self.pages[i]['columns']
> +        for page in self.pages:
> +            columns = page['columns']
>               tab = HobViewTable(columns)
> -            filter = self.pages[i]['filter']
> +            filter = page['filter']
>               tab.set_model(self.recipe_model.tree_model(filter))
>               tab.connect("toggled", self.table_toggled_cb)
> -            if self.pages[i]['name'] == "Included":
> +            if page['name'] == "Included":
>                   tab.connect("row-activated", self.tree_row_activated_cb)
>
> -            label = gtk.Label(self.pages[i]['name'])
> +            label = gtk.Label(page['name'])
>               self.ins.append_page(tab, label)
>               self.tables.append(tab)
>

-- 
Joshua '贾詡' Lock
         Yocto Project "Johannes factotum"
         Intel Open Source Technology Centre



  reply	other threads:[~2012-03-19 23:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 15:10 [PATCH 00/12] [V3]Hob Notebook Implementation and Others Shane Wang
2012-03-16 15:10 ` [PATCH 01/12] Hob: implement a self-defined notebook visual component for Hob Shane Wang
2012-03-19 23:49   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 02/12] Hob: use HobNotebook to implement a notebook in build details page Shane Wang
2012-03-19 23:49   ` Joshua Lock
2012-03-20 13:44     ` Wang, Shane
2012-03-20 14:17     ` Wang, Shane
2012-03-16 15:10 ` [PATCH 03/12] Hob: show indicators on the tabs of the Hob notebook Shane Wang
2012-03-19 23:49   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 04/12] Hob: change the code style to enumerate a list in a for-loop Shane Wang
2012-03-19 23:50   ` Joshua Lock [this message]
2012-03-16 15:10 ` [PATCH 05/12] Hob: fix '!= None' and '== None' in the code Shane Wang
2012-03-19 23:51   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 06/12] Hob: allow users to setup the proxies Shane Wang
2012-03-19 23:51   ` Joshua Lock
2012-03-20 13:27     ` Wang, Shane
2012-03-26 17:38       ` Barros Pena, Belen
2012-03-16 15:10 ` [PATCH 07/12] Hob: remove the invalid code in hobwidget.py Shane Wang
2012-03-19 23:51   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 08/12] Hob: change the range dance in hobwidget make it like a pythonista Shane Wang
2012-03-19 23:57   ` Joshua Lock
2012-03-20 12:16     ` An, LimingX L
2012-03-16 15:10 ` [PATCH 09/12] Hob: fix static variable "self.search" to parameter "search" in signal callback function Shane Wang
2012-03-19 23:52   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 10/12] Hob: add auto adjust background area function for long issue text Shane Wang
2012-03-19 23:52   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 11/12] Hob: change HobNoteBook tab edge color from green to gray Shane Wang
2012-03-19 23:53   ` Joshua Lock
2012-03-16 15:10 ` [PATCH 12/12] Hob: per UI design add refresh icon for building log Shane Wang
2012-03-19 23:53   ` Joshua Lock
2012-03-20 13:04     ` An, LimingX L
2012-03-20 18:29       ` Joshua Lock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F67C658.1040205@linux.intel.com \
    --to=josh@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox