[csw-devel] [PATCH 1/2] checkpkg: Change GetDependencies to 'with'

maciej at opencsw.org maciej at opencsw.org
Sun Mar 27 10:54:05 CEST 2011


From: Maciej Bliziński <maciej at opencsw.org>

---
 gar/v2/lib/python/package.py |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/gar/v2/lib/python/package.py b/gar/v2/lib/python/package.py
index 21b8b1a..1d06467 100644
--- a/gar/v2/lib/python/package.py
+++ b/gar/v2/lib/python/package.py
@@ -346,16 +346,15 @@ class DirectoryFormatPackage(shell.ShellMixin, object):
     depend_file_path = os.path.join(self.directory, "install", "depend")
     if not os.path.exists(depend_file_path):
       return depends
-    fd = open(os.path.join(self.directory, "install", "depend"), "r")
-    # It needs to be a list because there might be duplicates and it's
-    # necessary to carry that information.
-    for line in fd:
-      fields = re.split(c.WS_RE, line)
-      if fields[0] == "P":
-        pkgname = fields[1]
-        pkg_desc = " ".join(fields[1:])
-        depends.append((pkgname, pkg_desc))
-    fd.close()
+    with open(depend_file_path, "r") as fd:
+      # It needs to be a list because there might be duplicates and it's
+      # necessary to carry that information.
+      for line in fd:
+        fields = re.split(c.WS_RE, line)
+        if fields[0] == "P":
+          pkgname = fields[1]
+          pkg_desc = " ".join(fields[1:])
+          depends.append((pkgname, pkg_desc))
     return depends
 
   def CheckPkgpathExists(self):
-- 
1.7.1



More information about the devel mailing list