Ver Fonte

Add simple lookup function to Tree.

Jelmer Vernooij há 16 anos atrás
pai
commit
5b199401b3
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      dulwich/objects.py

+ 6 - 0
dulwich/objects.py

@@ -344,6 +344,12 @@ class Tree(ShaFile):
         """Return a list of tuples describing the tree entries"""
         return self._entries
 
+    def __getitem__(self, name):
+        for mode, entry, hexsha in self.entries():
+            if entry == name:
+                return mode, hexsha
+        raise KeyError(name)
+
     def _parse_text(self):
         """Grab the entries in the tree"""
         count = 0