[csw-devel] SF.net SVN: gar:[8197] csw/mgar/gar/v2/bin/checkpkg.d/ checkpkg-you-can-write-your-own.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Jan 27 14:21:54 CET 2010


Revision: 8197
          http://gar.svn.sourceforge.net/gar/?rev=8197&view=rev
Author:   wahwah
Date:     2010-01-27 13:21:51 +0000 (Wed, 27 Jan 2010)

Log Message:
-----------
mGAR v2: checkpkg, more help with writing own checkpkg modules

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py

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-27 10:27:59 UTC (rev 8196)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py	2010-01-27 13:21:51 UTC (rev 8197)
@@ -1,12 +1,11 @@
 #!/opt/csw/bin/python2.6
 # $Id$
 
-"""This is a dummy check. You can use it as a boilerplate for your own checks.
+"""This is a dummy module. You can use it as a boilerplate for your own modules.
 
 Copy it and modify.
 """
 
-import logging
 import os.path
 import sys
 
@@ -19,7 +18,7 @@
 
 # Defining checking functions.
 
-def CheckIndividualPackage(pkg):
+def MyCheckForAsinglePackage(pkg):
   """Checks an individual package.
   
   Gets a DirctoryFormatPackage as an argument, and returns a list of errors.
@@ -29,17 +28,24 @@
   errors.append(checkpkg.PackageError("There's something wrong."))
   """
   errors = []
-  # Checking code for an individual package goes here.
+  # Checking code for an individual package goes here.  See the
+  # DirectoryFormatPackage class in lib/python/opencsw.py for the available
+  # APIs.
+
+  # Here's how to report an error:
+  something_is_wrong = False
+  if something_is_wrong:
+    errors.append(checkpkg.PackageError("There's something wrong."))
   return errors
 
 
-def CheckAsetOfPackages(pkgs):
+def MyCheckForAsetOfPackages(pkgs):
   """Checks a set of packages.
 
   Sometimes individual checks aren't enough. If you need to write code which
   needs to examine multiple packages at the same time, use this function.
 
-  Gets a list of packages.
+  Gets a list of packages, returns a list of errors.
   """
   errors = []
   # Checking code goes here.
@@ -55,9 +61,9 @@
                                            options.extractdir,
                                            pkgnames,
                                            options.debug)
-  # Registering previously defined checks.
-  check_manager.RegisterIndividualCheck(CheckIndividualPackage)
-  check_manager.RegisterSetCheck(CheckAsetOfPackages)
+  # Registering functions defined above.
+  check_manager.RegisterIndividualCheck(MyCheckForAsinglePackage)
+  check_manager.RegisterSetCheck(MyCheckForAsetOfPackages)
   # Running the checks, reporting and exiting.
   exit_code, report = check_manager.Run()
   print report.strip()


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