Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f23379

Browse files
committed
Corrections to the tutorial to account for the change of Tree to a dictionary protocol.
1 parente4582f8 commit5f23379

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

‎doc/tutorial.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,31 @@ the root tree of the latest commit on the master branch.
114114

115115
Once you have a tree, you can get the contents.
116116

117-
>>> contents = tree.contents
117+
>>> contents = tree.values()
118118
[<git.Blob "6a91a439ea968bf2f5ce8bb1cd8ddf5bf2cad6c7">,
119119
<git.Blob "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391">,
120120
<git.Tree "eaa0090ec96b054e425603480519e7cf587adfc3">,
121121
<git.Blob "980e72ae16b5378009ba5dfd6772b59fe7ccd2df">]
122122

123-
This tree contains three ``Blob`` objects and one ``Tree`` object. The trees
124-
are subdirectories and the blobs are files. Trees below the root have
123+
The tree is implements a dictionary protocol so it can be used and acts just
124+
like a dictionary with some additional properties.
125+
126+
>>> tree.items()
127+
[('lib', <git.Tree "310ebc9a0904531438bdde831fd6a27c6b6be58e">),
128+
('LICENSE', <git.Blob "6797c1421052efe2ded9efdbb498b37aeae16415">),
129+
('doc', <git.Tree "a58386dd101f6eb7f33499317e5508726dfd5e4f">),
130+
('MANIFEST.in', <git.Blob "7da4e346bb0a682e99312c48a1f452796d3fb988">),
131+
('.gitignore', <git.Blob "6870991011cc8d9853a7a8a6f02061512c6a8190">),
132+
('test', <git.Tree "c6f6ee37d328987bc6fb47a33fed16c7886df857">),
133+
('VERSION', <git.Blob "9faa1b7a7339db85692f91ad4b922554624a3ef7">),
134+
('AUTHORS', <git.Blob "9f649ef5448f9666d78356a2f66ba07c5fb27229">),
135+
('README', <git.Blob "9643dcf549f34fbd09503d4c941a5d04157570fe">),
136+
('ez_setup.py', <git.Blob "3031ad0d119bd5010648cf8c038e2bbe21969ecb">),
137+
('setup.py', <git.Blob "271074302aee04eb0394a4706c74f0c2eb504746">),
138+
('CHANGES', <git.Blob "0d236f3d9f20d5e5db86daefe1e3ba1ce68e3a97">)]
139+
140+
This tree contains three ``Blob`` objects and one ``Tree`` object. The trees
141+
are subdirectories and the blobs are files. Trees below the root have
125142
additional attributes.
126143

127144
>>> contents = tree["lib"]
@@ -153,7 +170,7 @@ The Blob object
153170

154171
A blob represents a file. Trees often contain blobs.
155172

156-
>>> blob = tree.contents[-1]
173+
>>> blob = tree['urls.py']
157174
<git.Blob "b19574431a073333ea09346eafd64e7b1908ef49">
158175

159176
A blob has certain attributes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp