8000 Allow the octocat to speak! · dahlia/github3.py@f32750d · GitHub
[go: up one dir, main page]

Skip to content

Commit f32750d

Browse files
committed
Allow the octocat to speak!
Also, add a fun example to that effect.
1 parent fce7cea commit f32750d

File tree

5 files changed

+94
-6
lines changed

5 files changed

+94
-6
lines changed

HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ History/Changelog
2020
- API ``iter_`` methods now accept the ``etag`` argument as the
2121
``GitHub.iter_`` methods do.
2222

23+
- ``github3.octocat`` and ``github3.github.GitHub.octocat`` both support
24+
sending messages to make the Octocat say things. (Think cowsay)
25+
2326
- Remove vendored dependency of PySO8601.
2427

2528
0.5.3: 2013-03-19

docs/examples/octocat.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
A Conversation With Octocat
2+
===========================
3+
4+
.. include:: source/octocat_say.py
5+
:code: python
6+
7+
What you should see
8+
9+
::
10+
11+
12+
Hey Octocat!
13+
14+
MMM. .MMM
15+
MMMMMMMMMMMMMMMMMMM
16+
MMMMMMMMMMMMMMMMMMM __________
17+
MMMMMMMMMMMMMMMMMMMMM | |
18+
MMMMMMMMMMMMMMMMMMMMMMM | Hey Ian! |
19+
MMMMMMMMMMMMMMMMMMMMMMMM |_ ______|
20+
MMMM::- -:::::::- -::MMMM |/
21+
MM~:~ ~:::::~ ~:~MM
22+
.. MMMMM::. .:::+:::. .::MMMMM ..
23+
.MM::::: ._. :::::MM.
24+
MMMM;:::::;MMMM
25+
-MM MMMMMMM
26+
^ M+ MMMMMMMMM
27+
MMMMMMM MM MM MM
28+
MM MM MM MM
29+
MM MM MM MM
30+
.~~MM~MM~MM~MM~~.
31+
~~~~MM:~MM~~~MM~:MM~~~~
32+
~~~~~~==~==~~~==~==~~~~~~
33+
~~~~~~==~==~==~==~~~~~~
34+
:~==~==~==~==~~
35+
36+
What do you think about github3.py?
37+
38+
MMM. .MMM
39+
MMMMMMMMMMMMMMMMMMM
40+
MMMMMMMMMMMMMMMMMMM ___________________
41+
MMMMMMMMMMMMMMMMMMMMM | |
42+
MMMMMMMMMMMMMMMMMMMMMMM | github3.py rocks! |
43+
MMMMMMMMMMMMMMMMMMMMMMMM |_ _______________|
44+
MMMM::- -:::::::- -::MMMM |/
45+
MM~:~ ~:::::~ ~:~MM
46+
.. MMMMM::. .:::+:::. .::MMMMM ..
47+
.MM::::: ._. :::::MM.
48+
MMMM;:::::;MMMM
49+
-MM MMMMMMM
50+
^ M+ MMMMMMMMM
51+
MMMMMMM MM MM MM
52+
MM MM MM MM
53+
MM MM MM MM
54+
.~~MM~MM~MM~MM~~.
55+
~~~~MM:~MM~~~MM~:MM~~~~
56+
~~~~~~==~==~~~==~==~~~~~~
57+
~~~~~~==~==~==~==~~~~~~
58+
:~==~==~==~==~~
59+
60+
Thanks Octocat, that means a lot coming from you.
61+
FIN.
62+
Epilog:
63+
The preceding conversation was entirely fictional. If you didn't realize
64+
that, you need to get out more. And yes, I did just have a
65+
conversation with an API. Cool, no? (Sad too, I guess.)

docs/examples/source/octocat_say.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import github3
2+
3+
print("Hey Octocat!")
4+
< EDBE span class=pl-en>print(github3.octocat("Hey Ian!"))
5+
print("What do you think about github3.py?")
6+
print(github3.octocat("github3.py rocks!"))
7+
print("Thanks Octocat, that means a lot coming from you.")
8+
print("FIN.")
9+
print("""Epilog:
10+
The preceding conversation was entirely fictional. If you didn't realize
11+
that, you need to get out more.
12+
""")

github3/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,13 @@ def markdown(text, mode='', context='', raw=False):
290290
return gh.markdown(text, mode, context, raw)
291291

292292

293-
def octocat():
294-
"""Returns an easter egg from the API."""
295-
return gh.octocat()
293+
def octocat(say=None):
294+
"""Returns an easter egg from the API.
295+
296+
:params str say: (optional), pass in what you'd like Octocat to say
297+
:returns: ascii art of Octocat
298+
"""
299+
return gh.octocat(say)
296300

297301

298302
def organization(login):

github3/github.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,14 @@ def meta(self):
773773
url = self._build_url('meta')
774774
return self._json(self._get(url), 200)
775775

776-
def octocat(self):
777-
"""Returns an easter egg of the API."""
776+
def octocat(self, say=None):
777+
1E0A """Returns an easter egg of the API.
778+
779+
:params str say: (optional), pass in what you'd like Octocat to say
780+
:returns: ascii art of Octocat
781+
"""
778782
url = self._build_url('octocat')
779-
req = self._get(url)
783+
req = self._get(url, params={'s': say})
780784
return req.content if req.ok else ''
781785

782786
def organization(self, login):

0 commit comments

Comments
 (0)
0