[Ocfs2-tools-commits] manish commits r872 - trunk/ocfs2console/ocfs2interface

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Apr 29 22:12:26 CDT 2005


Author: manish
Date: 2005-04-29 22:12:24 -0500 (Fri, 29 Apr 2005)
New Revision: 872

Modified:
   trunk/ocfs2console/ocfs2interface/bosa.py
   trunk/ocfs2console/ocfs2interface/format.py
   trunk/ocfs2console/ocfs2interface/fswidgets.py
   trunk/ocfs2console/ocfs2interface/general.py
   trunk/ocfs2console/ocfs2interface/nodeconfig.py
Log:
Use enumerate where appropriate, to simplify the code


Modified: trunk/ocfs2console/ocfs2interface/bosa.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/bosa.py	2005-04-30 03:01:17 UTC (rev 871)
+++ trunk/ocfs2console/ocfs2interface/bosa.py	2005-04-30 03:12:24 UTC (rev 872)
@@ -162,9 +162,7 @@
 
         self.info_labels = []
 
-        column = 0
-
-        for field in fields:
+        for column, field in enumerate(fields):
             label = gtk.Label(field.label)
             set_props(label, xalign=0.0)
             table.attach(label, column, column + 1, 0, 1)
@@ -174,8 +172,6 @@
 
             self.info_labels.append(label)
 
-            column += 1
-
     def destroy_handler(self, obj):
         self.cleanup()
 

Modified: trunk/ocfs2console/ocfs2interface/format.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/format.py	2005-04-30 03:01:17 UTC (rev 871)
+++ trunk/ocfs2console/ocfs2interface/format.py	2005-04-30 03:12:24 UTC (rev 872)
@@ -74,9 +74,8 @@
                      parent=dialog.vbox)
 
     widgets = []
-    row = 0
 
-    for widget_type in entries:
+    for row, widget_type in enumerate(entries):
         widget = widget_type()
 
         label = gtk.Label()
@@ -101,8 +100,6 @@
 
         widgets.append(widget)
 
-        row = row + 1
-
     widgets[0].grab_focus()
 
     dialog.show_all()

Modified: trunk/ocfs2console/ocfs2interface/fswidgets.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/fswidgets.py	2005-04-30 03:01:17 UTC (rev 871)
+++ trunk/ocfs2console/ocfs2interface/fswidgets.py	2005-04-30 03:12:24 UTC (rev 872)
@@ -159,9 +159,7 @@
                      border_width=4,
                      parent=window)
 
-    row = 0
-
-    for widget_type in widgets:
+    for row, widget_type in enumerate(widgets):
         label = gtk.Label()
         label.set_text_with_mnemonic(widget_type.label + ':')
         set_props(label, xalign=1.0)
@@ -170,8 +168,6 @@
         widget = widget_type()
         table.attach(widget, 1, 2, row, row + 1)
 
-        row = row + 1
-
     window.show_all()
 
     gtk.main()

Modified: trunk/ocfs2console/ocfs2interface/general.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/general.py	2005-04-30 03:01:17 UTC (rev 871)
+++ trunk/ocfs2console/ocfs2interface/general.py	2005-04-30 03:12:24 UTC (rev 872)
@@ -113,9 +113,7 @@
             except ocfs2.error:
                 pass
 
-        row = 0
-
-        for field_type in fields:
+        for row, field_type in enumerate(fields):
             field = field_type(fs, super, dinode)
 
             label = gtk.Label(field.label + ':')
@@ -128,8 +126,6 @@
             self.attach(label, 1, 2, row, row + 1,
                         xoptions=gtk.FILL, yoptions=gtk.FILL)
 
-            row += 1
-
 def main():
     import sys
 

Modified: trunk/ocfs2console/ocfs2interface/nodeconfig.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/nodeconfig.py	2005-04-30 03:01:17 UTC (rev 871)
+++ trunk/ocfs2console/ocfs2interface/nodeconfig.py	2005-04-30 03:12:24 UTC (rev 872)
@@ -331,9 +331,8 @@
                          parent=dialog.vbox)
 
         widgets = []
-        row = 0
 
-        for field in fields:
+        for row, field in enumerate(fields):
             if field.widget_type is None:
                 widgets.append(None)
                 continue
@@ -359,8 +358,6 @@
 
             widgets.append(widget)
 
-            row = row + 1
-
         if defaults:
             for w, d in zip(widgets, defaults):
                 if w and d:



More information about the Ocfs2-tools-commits mailing list