[csw-devel] SF.net SVN: gar:[14048] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Apr 2 13:24:06 CEST 2011


Revision: 14048
          http://gar.svn.sourceforge.net/gar/?rev=14048&view=rev
Author:   wahwah
Date:     2011-04-02 11:24:06 +0000 (Sat, 02 Apr 2011)

Log Message:
-----------
package.py: Move inspective functions

Two functions that need access to unpackage package moved to
inspective_package.py.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/inspective_package.py
    csw/mgar/gar/v2/lib/python/package.py

Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py	2011-04-02 11:23:44 UTC (rev 14047)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py	2011-04-02 11:24:06 UTC (rev 14048)
@@ -284,7 +284,77 @@
                               % (repr(line), common_re))
     return response
 
+  def GetDependencies(self):
+    """Gets dependencies information.
 
+    Returns:
+      A tuple of (list, list) of depends and i_depends.
+    """
+    # The collection of dependencies needs to be a list (as opposed to
+    # a set) because there might be duplicates and it's necessary to
+    # carry that information.
+    depends = []
+    i_depends = []
+    depend_file_path = os.path.join(self.directory, "install", "depend")
+    if os.path.exists(depend_file_path):
+      with open(depend_file_path, "r") as fd:
+        for line in fd:
+          fields = re.split(c.WS_RE, line)
+          if len(fields) < 2:
+            logging.warning("Bad depends line: %s", repr(line))
+          if fields[0] == "P":
+            pkgname = fields[1]
+            pkg_desc = " ".join(fields[1:])
+            depends.append((pkgname, pkg_desc))
+          if fields[0] == "I":
+            pkgname = fields[1]
+            i_depends.append(pkgname)
+    return depends, i_depends
+
+  def GetObsoletedBy(self):
+    """Collects obsolescence information from the package if it exists
+
+    Documentation:
+    http://wiki.opencsw.org/obsoleting-packages
+
+    Returns:
+
+    A dictionary of "has_obsolete_info", "syntax_ok" and
+    "obsoleted_by" where obsoleted_by is a list of (pkgname,
+    catalogname) tuples and has_obsolete_info and syntax_ok are
+    booleans.
+
+    If the package has not been obsoleted or the package predates the
+    implementation of this mechanism, obsoleted_by is an empty list
+    and has_obsolete_info will be False.
+
+    If the package provides obsolescence information but the format of
+    the information is invalid, syntax_ok will be False and the list
+    may be empty.  It will always contain the valid entries.
+    """
+
+    has_obsolete_info = False
+    obsoleted_syntax_ok = True
+    obsoleted_by = []
+    obsoleted_by_path = os.path.join(self.directory, "install", "obsolete")
+
+    if os.path.exists(obsoleted_by_path):
+      has_obsolete_info = True
+      with open(obsoleted_by_path, "r") as fd:
+        for line in fd:
+          fields = re.split(c.WS_RE, line)
+          if len(fields) < 2:
+            obsoleted_syntax_ok = False
+            logging.warning("Bad line in obsolete file: %s", repr(line))
+            continue
+          pkgname, catalogname = fields[0:2]
+          obsoleted_by.append((pkgname, catalogname))
+
+    return { "syntax_ok": obsoleted_syntax_ok,
+             "obsoleted_by": obsoleted_by,
+             "has_obsolete_info": has_obsolete_info }
+
+
 class FileMagic(object):
   """Libmagic sometimes returns None, which I think is a bug.
   Trying to come up with a way to work around that.  It might not even be

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2011-04-02 11:23:44 UTC (rev 14047)
+++ csw/mgar/gar/v2/lib/python/package.py	2011-04-02 11:24:06 UTC (rev 14048)
@@ -341,76 +341,6 @@
     pkginfo_name = "%s - %s" % (catalog_name, description)
     self.SetPkginfoEntry("NAME", pkginfo_name)
 
-  def GetDependencies(self):
-    """Gets dependencies information.
-
-    Returns:
-      A tuple of (list, list) of depends and i_depends.
-    """
-    # The collection of dependencies needs to be a list (as opposed to
-    # a set) because there might be duplicates and it's necessary to
-    # carry that information.
-    depends = []
-    i_depends = []
-    depend_file_path = os.path.join(self.directory, "install", "depend")
-    if os.path.exists(depend_file_path):
-      with open(depend_file_path, "r") as fd:
-        for line in fd:
-          fields = re.split(c.WS_RE, line)
-          if len(fields) < 2:
-            logging.warning("Bad depends line: %s", repr(line))
-          if fields[0] == "P":
-            pkgname = fields[1]
-            pkg_desc = " ".join(fields[1:])
-            depends.append((pkgname, pkg_desc))
-          if fields[0] == "I":
-            pkgname = fields[1]
-            i_depends.append(pkgname)
-    return depends, i_depends
-
-  def GetObsoletedBy(self):
-    """Collects obsolescence information from the package if it exists
-
-    Documentation:
-    http://wiki.opencsw.org/obsoleting-packages
-
-    Returns:
-
-    A dictionary of "has_obsolete_info", "syntax_ok" and
-    "obsoleted_by" where obsoleted_by is a list of (pkgname,
-    catalogname) tuples and has_obsolete_info and syntax_ok are
-    booleans.
-
-    If the package has not been obsoleted or the package predates the
-    implementation of this mechanism, obsoleted_by is an empty list
-    and has_obsolete_info will be False.
-
-    If the package provides obsolescence information but the format of
-    the information is invalid, syntax_ok will be False and the list
-    may be empty.  It will always contain the valid entries.
-    """
-
-    has_obsolete_info = False
-    obsoleted_syntax_ok = True
-    obsoleted_by = []
-    obsoleted_by_path = os.path.join(self.directory, "install", "obsolete")
-
-    if os.path.exists(obsoleted_by_path):
-      has_obsolete_info = True
-      with open(obsoleted_by_path, "r") as fd:
-        for line in fd:
-          fields = re.split(c.WS_RE, line)
-          if len(fields) < 2:
-            obsoleted_syntax_ok = False
-            logging.warning("Bad line in obsolete file: %s", repr(line))
-            continue
-          pkgname, catalogname = fields[0:2]
-          obsoleted_by.append((pkgname, catalogname))
-
-    return { "syntax_ok": obsoleted_syntax_ok,
-             "obsoleted_by": obsoleted_by,
-             "has_obsolete_info": has_obsolete_info }
-
   def CheckPkgpathExists(self):
     if not os.path.isdir(self.directory):
       raise PackageError("%s does not exist or is not a directory"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list