83fe4c7e8702

simplify exact prefix match
[view raw] [browse files]
author Neal Fultz <nfultz@gmail.com>
date Tue, 25 Jun 2019 07:21:47 +0000
parents b183c1d51530
children d34ec597c1f6
branches/tags (none)
files t.py

Changes

--- a/t.py	Mon Jan 01 10:37:56 2018 +1100
+++ b/t.py	Tue Jun 25 07:21:47 2019 +0000
@@ -165,12 +165,10 @@
             return self.tasks[matched[0]]
         elif len(matched) == 0:
             raise UnknownPrefix(prefix)
+        elif prefix in matched:
+            return self.tasks[prefix]
         else:
-            matched = [tid for tid in self.tasks.keys() if tid == prefix]
-            if len(matched) == 1:
-                return self.tasks[matched[0]]
-            else:
-                raise AmbiguousPrefix(prefix)
+            raise AmbiguousPrefix(prefix)
 
     def add_task(self, text):
         """Add a new, unfinished task with the given summary text."""