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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Oct 5 02:54:29 CEST 2010


Revision: 11150
          http://gar.svn.sourceforge.net/gar/?rev=11150&view=rev
Author:   wahwah
Date:     2010-10-05 00:54:29 +0000 (Tue, 05 Oct 2010)

Log Message:
-----------
mGAR v2: Added a check for e-mail addresses.

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-10-05 00:21:17 UTC (rev 11149)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-05 00:54:29 UTC (rev 11150)
@@ -50,6 +50,7 @@
     },
 }
 ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
+EMAIL_RE = re.compile(r"^.*@opencsw.org$")
 MAX_CATALOGNAME_LENGTH = 20
 MAX_PKGNAME_LENGTH = 20
 ARCH_LIST = opencsw.ARCHITECTURES
@@ -621,6 +622,16 @@
         "known architectures: %s" % ARCH_LIST)
 
 
+def CheckEmail(pkg_data, error_mgr, logger, messenger):
+  """Checks the e-mail address."""
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  pkginfo = pkg_data["pkginfo"]
+  if not re.match(EMAIL_RE, pkginfo["EMAIL"]):
+    error_mgr.ReportError("pkginfo-email-not-opencsw-org",
+                          "email=%s" % pkginfo["EMAIL"])
+
+
 def CheckPstamp(pkg_data, error_mgr, logger, messenger):
   pkginfo = pkg_data["pkginfo"]
   if "PSTAMP" in pkginfo:

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-10-05 00:21:17 UTC (rev 11149)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-10-05 00:54:29 UTC (rev 11150)
@@ -81,7 +81,19 @@
     self.error_mgr_mock.ReportError('pkginfo-description-not-starting-with-uppercase',
                                     'lowercase')
 
+class TestCheckEmailGood(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CheckEmail'
+  def CheckpkgTest(self):
+    self.pkg_data["pkginfo"]["EMAIL"] = 'somebody at opencsw.org'
 
+
+class TestCheckEmailBadDomain(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CheckEmail'
+  def CheckpkgTest(self):
+    self.pkg_data["pkginfo"]["EMAIL"] = 'somebody at opencsw.com'
+    self.error_mgr_mock.ReportError('pkginfo-email-not-opencsw-org', 'email=somebody at opencsw.com')
+
+
 class TestCheckCatalogname_1(CheckpkgUnitTestHelper, unittest.TestCase):
   FUNCTION_NAME = 'CheckCatalogname'
   def CheckpkgTest(self):


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