[csw-devel] SF.net SVN: gar:[8188] csw/mgar/gar/v2

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Jan 26 18:01:33 CET 2010


Revision: 8188
          http://gar.svn.sourceforge.net/gar/?rev=8188&view=rev
Author:   wahwah
Date:     2010-01-26 17:01:27 +0000 (Tue, 26 Jan 2010)

Log Message:
-----------
mGAR v2: checkpkg, more elegant way to find the current file (__file__).

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py
    csw/mgar/gar/v2/lib/python/opencsw_test.py

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py	2010-01-26 16:46:41 UTC (rev 8187)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py	2010-01-26 17:01:27 UTC (rev 8188)
@@ -19,8 +19,7 @@
 
 # The following bit of code sets the correct path to Python libraries
 # distributed with GAR.
-path_list = [os.getcwd(),
-             os.path.split(sys.argv[0])[0],
+path_list = [os.path.dirname(__file__),
              "..", "..", "lib", "python"]
 sys.path.append(os.path.join(*path_list))
 import checkpkg

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py	2010-01-26 16:46:41 UTC (rev 8187)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py	2010-01-26 17:01:27 UTC (rev 8188)
@@ -10,8 +10,7 @@
 
 # The following bit of code sets the correct path to Python libraries
 # distributed with GAR.
-path_list = [os.getcwd(),
-             os.path.split(sys.argv[0])[0],
+path_list = [os.path.dirname(__file__),
              "..", "..", "lib", "python"]
 sys.path.append(os.path.join(*path_list))
 import checkpkg

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py	2010-01-26 16:46:41 UTC (rev 8187)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py	2010-01-26 17:01:27 UTC (rev 8188)
@@ -12,8 +12,7 @@
 
 # The following bit of code sets the correct path to Python libraries
 # distributed with GAR.
-path_list = [os.getcwd(),
-             os.path.split(sys.argv[0])[0],
+path_list = [os.path.dirname(__file__),
              "..", "..", "lib", "python"]
 sys.path.append(os.path.join(*path_list))
 import checkpkg

Modified: csw/mgar/gar/v2/lib/python/opencsw_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw_test.py	2010-01-26 16:46:41 UTC (rev 8187)
+++ csw/mgar/gar/v2/lib/python/opencsw_test.py	2010-01-26 17:01:27 UTC (rev 8188)
@@ -2,8 +2,9 @@
 # $Id$
 
 import opencsw
-import unittest
+import os.path
 import re
+import unittest
 
 CATALOG_DATA_1 = """amavisd_new 2.6.3,REV=2009.04.23 CSWamavisdnew amavisd_new-2.6.3,REV=2009.04.23-SunOS5.8-all-CSW.pkg.gz 831f063d1ba20eb8bea0e0e60ceef3cb 813802 CSWperl|CSWcswclassutils|CSWpmunixsyslog|CSWpmiostringy|CSWpmnetserver|CSWpmmailtools|CSWpmmimetools|CSWpmcompresszlib|CSWpmarchivetar|CSWpmarchivezip|CSWspamassassin|CSWpmberkeleydb|CSWpmconverttnef|CSWpmconvertuulib|CSWpmmaildkim|CSWcommon none
 amsn 0.94 CSWamsn amsn-0.94-SunOS5.8-all-CSW.pkg.gz 99afd828dd38fb39a37cb8ffd448b098 2420919 CSWtcl|CSWtk|CSWtcltls none
@@ -46,9 +47,7 @@
 class ParsePackageFileNameTest(unittest.TestCase):
 
   def testParsePackageFileName1(self):
-    # FIXME: it doesn't find the file if the pwd is not the same as the
-    # location of this file.
-    test_data = open("testdata/example-catalog.txt")
+    test_data = open(os.path.join(os.path.split(__file__)[0], "testdata/example-catalog.txt"))
     split_re = re.compile(r"\s+")
     for line in test_data:
       fields = re.split(split_re, line)


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