[csw-devel] SF.net SVN: gar:[8729] csw/mgar/gar/v2/lib/python/package_checks.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Feb 22 11:53:10 CET 2010
Revision: 8729
http://gar.svn.sourceforge.net/gar/?rev=8729&view=rev
Author: wahwah
Date: 2010-02-22 10:53:10 +0000 (Mon, 22 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, some ideas for future APIs
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package_checks.py
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-22 09:16:13 UTC (rev 8728)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-22 10:53:10 UTC (rev 8729)
@@ -1,5 +1,58 @@
-# Defining the checking functions. They come in two flavors: individual
-# package checks and set checks.
+# $Id$
+#
+# Package checking functions. They come in two flavors:
+# - individual package checks
+# - set checks
+#
+# Some ideas for the future development of the checks. Here's what a check
+# could look like:
+#
+# class FooCheck(checkpkg.IndividualCheck):
+# """Simplest check for an individual package."""
+#
+# def CheckExampleOne(self):
+# """First idea, with an ReportError method."""
+# if self.catalogname != self.catalogname.lower():
+# self.ReportError("catalogname-not-lowercase")
+#
+# def CheckExampleTwo(self):
+# """Second idea, more similar to a unit test."""
+# self.checkEqual(self.catalogname,
+# self.catalogname.lower(),
+# "catalogname-not-lowercase")
+#
+# What would be needed to do that:
+#
+# - Have a class that looks for classes derived from checkpkg.IndividualCheck,
+# run SetUp on them (which sets things such as self.catalogname) and then
+# Check().
+# - Read all the data and set appropriate member names.
+#
+# Set checks would be slightly more complicated.
+#
+# class BarCheck(checkpkg.SetCheck):
+# """More complex check for multiple packages.
+#
+# We cannot have package data as class members any more, we have to use
+# a class member with a list of objects containing packages' data.
+#
+# In this class, checkEqual() methods needs one more parameter, denoting
+# the package to assign the error to.
+# """
+#
+# def Check(self):
+# for pkg in self.pkgs:
+# self.checkEqual(pkg.catalogname,
+# pkg.catalogname.lower(),
+# pkg,
+# "catalogname-not-lowercase")
+#
+# Alternately, a function-based approach is possible:
+#
+# def IndividualCheckCatalogname(pkg_data, checkpkg_mgr):
+# catalogdata = pkg_data["basic_stats"]["catalogname"]
+# if catalogdata != catalogdata.lower():
+# checkpkg_mgr.ReportError("catalogname-not-lowercase")
import checkpkg
import re
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