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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Apr 28 10:21:54 CEST 2010


Revision: 9787
          http://gar.svn.sourceforge.net/gar/?rev=9787&view=rev
Author:   wahwah
Date:     2010-04-28 08:21:54 +0000 (Wed, 28 Apr 2010)

Log Message:
-----------
mGAR v2: checkpkg, a new check for Python packages

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

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-04-28 02:45:39 UTC (rev 9786)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-04-28 08:21:54 UTC (rev 9787)
@@ -673,3 +673,29 @@
             "relocation bound to a symbol with STV_PROTECTED visibility"
             % (ldd_elem["symbol"], ldd_elem["path"]))
 
+def CheckPythonPackageName(pkg_data, error_mgr, logger, messenger):
+  """Checks for CSWpy-* and py_* package names."""
+  pyfile_re = re.compile(r"/opt/csw/lib/python.*/.*")
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  has_py_files = False
+  example_py_file = ""
+  for pkgmap_entry in pkg_data["pkgmap"]:
+    if not pkgmap_entry["path"]:
+      continue
+    if pyfile_re.match(pkgmap_entry["path"]):
+      has_py_files = True
+      example_py_file = pkgmap_entry["path"]
+      break
+  if has_py_files and not pkgname.startswith("CSWpy-"):
+    error_mgr.ReportError("pkgname-does-not-start-with-CSWpy-")
+    messenger.Message("The package "
+                      "installs files into /opt/csw/lib/python. For example, %s. "
+                      "However, the pkgname doesn't start with 'CSWpy-'."
+                      % repr(example_py_file))
+  if has_py_files and not pkg_data["basic_stats"]["catalogname"].startswith("py_"):
+    error_mgr.ReportError("catalogname-does-not-start-with-py_")
+    messenger.Message("The package installs files into /opt/csw/lib/python. "
+        "For example, %s. "
+        "However, the catalogname doesn't start with 'py_'."
+        % repr(example_py_file))
+

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-04-28 02:45:39 UTC (rev 9786)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-04-28 08:21:54 UTC (rev 9787)
@@ -462,5 +462,37 @@
     self.pkg_data["pkginfo"]["VENDOR"] = "https://www.example.com/"
 
 
+class TestCheckPythonPackageName(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = "CheckPythonPackageName"
+  def CheckpkgTest(self):
+    self.pkg_data["pkgmap"].append({
+      "class": "none",
+      "group": "bin",
+      "line": "",
+      "mode": '0755',
+      "path": "/opt/csw/lib/python/site-packages/hachoir_parser/video/mov.py",
+      "type": "f",
+      "user": "root"
+    })
+    self.error_mgr_mock.ReportError('pkgname-does-not-start-with-CSWpy-')
+    self.error_mgr_mock.ReportError('catalogname-does-not-start-with-py_')
+
+
+class TestCheckPythonPackageName_good(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = "CheckPythonPackageName"
+  def CheckpkgTest(self):
+    self.pkg_data["pkgmap"].append({
+      "class": "none",
+      "group": "bin",
+      "line": "",
+      "mode": '0755',
+      "path": "/opt/csw/lib/python/site-packages/hachoir_parser/video/mov.py",
+      "type": "f",
+      "user": "root"
+    })
+    self.pkg_data["basic_stats"]["catalogname"] = "py_foo"
+    self.pkg_data["basic_stats"]["pkgname"] = "CSWpy-foo"
+
+
 if __name__ == '__main__':
   unittest.main()


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