@@ -157,6 +157,16 @@ interfaces.
157
157
Return the TreeEntry object for the given *name *. Raise ``KeyError `` if
158
158
there is not a tree entry with that name.
159
159
160
+ .. method :: Tree.__truediv__(name)
161
+
162
+ Return the TreeEntry object for the given *name *. Raise ``KeyError `` if
163
+ there is not a tree entry with that name. This allows navigating the tree
164
+ similarly to Pathlib using the slash operator via:
165
+
166
+ Example::
167
+
168
+ >>> entry = tree / 'path' / 'deeper' / 'some.file'
169
+
160
170
.. method :: Tree.__contains__(name)
161
171
162
172
Return True if there is a tree entry with the given name, False otherwise.
@@ -181,6 +191,7 @@ Tree entries
181
191
.. autoattribute :: pygit2.TreeEntry.hex
182
192
.. autoattribute :: pygit2.TreeEntry.filemode
183
193
.. autoattribute :: pygit2.TreeEntry.type
194
+ .. autoattribute :: pygit2.TreeEntry.obj
184
195
185
196
.. method :: TreeEntry.__cmp__(TreeEntry)
186
197
@@ -202,12 +213,12 @@ Example::
202
213
85a67270a49ef16cdd3d328f06a3e4b459f09b27 blob setup.py
203
214
3d8985bbec338eb4d47c5b01b863ee89d044bd53 tree test
204
215
205
- >>> entry = tree[ 'pygit2.c'] # Get an entry by name
216
+ >>> entry = tree / 'pygit2.c' # Get an entry by name
206
217
>>> entry
207
218
<pygit2.TreeEntry object at 0xcc10f0>
208
219
209
- >>> blob = repo[ entry.id] # Get the object the entry points to
210
- >>> blob
220
+ >>> obj = entry.obj # Get the blob the entry points to
221
+ >>> obj
211
222
<pygit2.Blob object at 0xcc12d0>
212
223
213
224
Creating trees
0 commit comments