r181 - branches/rewrite/src
Otavio Salvador
partial-mirror-devel@lists.alioth.debian.org
Thu, 22 Jul 2004 20:42:34 -0600
Author: otavio
Date: Thu Jul 22 20:42:34 2004
New Revision: 181
Modified:
branches/rewrite/src/PackageList.py
Log:
Port to new format and remove the exceptions to use the built-in.
Modified: branches/rewrite/src/PackageList.py
==============================================================================
--- branches/rewrite/src/PackageList.py (original)
+++ branches/rewrite/src/PackageList.py Thu Jul 22 20:42:34 2004
@@ -16,26 +16,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id$
-class PackageAlreadyIncluded(Exception):
- """
- Exception called when someone try to add a package but this was already included.
-
- Attributes:
- package -- The name of package.
- """
- def __init__(self, package):
- self.package = package
-
-class PackageDoesntExist(Exception):
- """
- Exception called when someone try to remove a package but this doesn't exist.
-
- Attributes:
- package -- The name of package.
- """
- def __init__(self, package):
- self.package = package
-
class PackageList:
"""
This class is use to store a list of packages and provide ways to
@@ -51,13 +31,13 @@
def add(self, package):
- if self._name.has_key(package.Name):
- raise PackageAlreadyIncluded(package.Name)
+ if self._name.has_key(package['Package']):
+ raise NameError, package['Package'] + 'already included.'
- if self._subsection[package.Section] is None:
- self._subsection[package.Section] = []
- if self._priority[package.Priority] is None:
- self._priority[package.Priority] = []
+ if self._subsection[package['Section']] is None:
+ self._subsection[package['Section']] = []
+ if self._priority[package['Priority']] is None:
+ self._priority[package['Priority']] = []
self._name[package.Name] = package
self._subsection[package.Section].append(package)
@@ -65,9 +45,9 @@
def remove(self, package):
- if not self._name.has_key(package.Name):
- raise PackageDoesntExist(package.Name)
+ if not self._name.has_key(package['Package']):
+ raise NameError, package['Package'] + 'do not exist.'
- del self._name[package.Name]
+ del self._name[package['Package']]
self._subsection[package.Section].remove(package)
self._priority[package.Priority].remove(package)