[Grml-devel] [PATCH 1/2] Rename variables in update_grml_versions to be less confusing

Christian Hofstaedtler ch at zeha.at
Thu Jul 1 20:58:03 CEST 2010


New names should be very clear in what they refer to.
---
 grml2usb |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/grml2usb b/grml2usb
index 13c8249..dbf1ba9 100755
--- a/grml2usb
+++ b/grml2usb
@@ -1116,26 +1116,26 @@ def update_grml_versions(iso_mount, target):
     @target: path of the target mount point
     """
     grml_target = target + '/grml/'
-    new_grml_version = search_file('grml-version', grml_target)
-    if new_grml_version:
-        orig_grml_version = search_file('grml-version', iso_mount)
-        if not orig_grml_version:
-            logging.warn("Warning: %s could not be found - can not install it", orig_grml_version)
+    target_grml_version_file = search_file('grml-version', grml_target)
+    if target_grml_version_file:
+        iso_grml_version_file = search_file('grml-version', iso_mount)
+        if not iso_grml_version_file:
+            logging.warn("Warning: %s could not be found - can not install it", iso_grml_version_file)
             return False
         try:
-            new_file = open(new_grml_version, 'a+')
-            new_flavours = [ get_flavour(l) for l in new_file.readlines() ]
-
-            old_file = open(orig_grml_version, 'r')
-            old_lines = old_file.readlines()
-            for line in old_lines:
-                if not get_flavour(line) in new_flavours:
-                    new_file.write(line)
+            target_file = open(target_grml_version_file, 'a+')
+            target_flavours = [ get_flavour(l) for l in target_file.readlines() ]
+
+            iso_file = open(iso_grml_version_file, 'r')
+            iso_lines = iso_file.readlines()
+            for line in iso_lines:
+                if not get_flavour(line) in target_flavours:
+                    target_file.write(line)
         except IOError:
             logging.warn("Warning: Could not write file")
         finally:
-            new_file.close()
-            old_file.close()
+            target_file.close()
+            iso_file.close()
         return True
     else:
         return False
-- 
1.7.1



More information about the Grml-devel mailing list