r415 - in branches/rewrite: . src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Thu, 16 Dec 2004 07:26:15 -0700


Author: otavio
Date: Thu Dec 16 07:26:13 2004
New Revision: 415

Modified:
   branches/rewrite/   (props changed)
   branches/rewrite/src/PackageList.py
Log:
 r1351@nurf:  otavio | 2004-12-16T14:26:17.724989Z
 - Fix documentation of filter method to explain the tasks are on
   debian-cd format;
 - Add InvalidFilter exception;
 - Change current filter method to raise InvalidFilter when it is
   invalid;


Modified: branches/rewrite/src/PackageList.py
==============================================================================
--- branches/rewrite/src/PackageList.py	(original)
+++ branches/rewrite/src/PackageList.py	Thu Dec 16 07:26:13 2004
@@ -45,12 +45,24 @@
     included.
 
     Attributes:
-        package -- The name of package.
+
+    - package: The name of package.
     """
     def __init__(self, package):
         Exception.__init__(self)
         self.package = package
 
+class InvalidFilter(Exception):
+    """
+    Exception called when someone try to use a invalid filter option.
+
+    Parameters:
+        *option* -- The filter option.
+    """
+    def __init__(self, option):
+        Exception.__init__(self)
+	self.option = option
+
 class PackageList:
     """
     This class is used to store a list of packages and provide ways to select
@@ -254,9 +266,9 @@
 
         The condition argument is a dictionary that can have the following keys:
 
-        - *include-from*: includes packages form the given tasksel task
+        - *include-from*: includes packages form the given debian-cd task
         
-        - *exclude-from*: excludes packages form the given tasksel task
+        - *exclude-from*: excludes packages form the given debian-cd task
         
         - *subsection*: includes packages that belong to a section that match
           the given regular expression
@@ -264,8 +276,11 @@
         - *priority*: includes packages that have a priority that match the
           given regular expression
 
-        - any other key: includes packages that have a name that match the given
+        - *name*: includes packages that have a name that match the given
           regular expression.
+          
+        If the condition was not on the above list a InvalidFilter exception is
+        raised.
         """
         packages = PackageList()
         
@@ -292,8 +307,10 @@
                 d = self._subsection
             elif item == "priority":
                 d = self._priority
-            else:
+            elif item == "name":
                 d = self._name
+            else:
+                raise InvalidFilter(item)
 
             regexp = re.compile(value)
             for k in d.keys():