summaryrefslogtreecommitdiffstats
path: root/cnucnu/package_list.py
diff options
context:
space:
mode:
Diffstat (limited to 'cnucnu/package_list.py')
-rwxr-xr-xcnucnu/package_list.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cnucnu/package_list.py b/cnucnu/package_list.py
index eb0c89f..939ef07 100755
--- a/cnucnu/package_list.py
+++ b/cnucnu/package_list.py
@@ -422,6 +422,7 @@ class PackageList:
self.append = self.packages.append
self.__len__ = self.packages.__len__
+
def __getitem__(self, key):
if isinstance(key, int):
return self.packages[key]
@@ -432,6 +433,13 @@ class PackageList:
raise KeyError("Package %s not found" % key)
+ def get(self, key, default=None):
+ try:
+ return self.__getitem__(key)
+ except KeyError:
+ return default
+
+
if __name__ == '__main__':
pl = PackageList()
p = pl.packages[0]