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

bdwalton at users.sourceforge.net bdwalton at users.sourceforge.net
Sun Mar 27 18:52:04 CEST 2011


Revision: 13947
          http://gar.svn.sourceforge.net/gar/?rev=13947&view=rev
Author:   bdwalton
Date:     2011-03-27 16:52:03 +0000 (Sun, 27 Mar 2011)

Log Message:
-----------
checkpkg/package.py: add GetObsoletedBy to class DirectoryFormatPackage

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

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2011-03-27 15:42:18 UTC (rev 13946)
+++ csw/mgar/gar/v2/lib/python/package.py	2011-03-27 16:52:03 UTC (rev 13947)
@@ -358,6 +358,42 @@
     fd.close()
     return depends
 
+  def GetObsoletedBy(self):
+    """Collects obsolescence information from the package if it exists
+
+    Documentation:
+    http://wiki.opencsw.org/obsoleting-packages
+
+    Returns:
+    A dictionary of "syntax_ok" and "obsoleted_by" where obsoleted_by
+    is a list of (pkgname, catalogname) tuples and syntax_ok is a
+    boolean.
+
+    If the package has not been obsoleted or the package predates the
+    implementation of this mechanism, obsoleted_by is an empty list.
+    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.
+    """
+
+    obsoleted_syntax_ok = True
+    obsoleted_by = []
+    obsoleted_by_path = os.path.join(self.directory, "install", "obsolete")
+
+    if not os.path.exists(obsoleted_by_path):
+      return obsoleted_by
+
+    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 }
+
   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