catsay-py 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- catsay_py-0.1.0/LICENSE +21 -0
- catsay_py-0.1.0/PKG-INFO +291 -0
- catsay_py-0.1.0/README.md +273 -0
- catsay_py-0.1.0/catsay.py +91 -0
- catsay_py-0.1.0/catsay_py.egg-info/PKG-INFO +291 -0
- catsay_py-0.1.0/catsay_py.egg-info/SOURCES.txt +9 -0
- catsay_py-0.1.0/catsay_py.egg-info/dependency_links.txt +1 -0
- catsay_py-0.1.0/catsay_py.egg-info/top_level.txt +1 -0
- catsay_py-0.1.0/pyproject.toml +27 -0
- catsay_py-0.1.0/setup.cfg +4 -0
- catsay_py-0.1.0/tests/test_catsay.py +84 -0
catsay_py-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FelineFantasy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
catsay_py-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: catsay-py
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A cute cat that says things in the terminal
|
|
5
|
+
Author-email: FelineFantasy <mailsalavata5@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/FelineFantasy/catsay
|
|
8
|
+
Project-URL: Repository, https://github.com/FelineFantasy/catsay
|
|
9
|
+
Project-URL: Issues, https://github.com/FelineFantasy/catsay/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Terminals
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# catsay ๐ฑ [](https://www.python.org/) [](LICENSE)
|
|
20
|
+
|
|
21
|
+
A cute ASCII cat library that says, warns, thinks, and asks questions. Perfect for making your CLI output more fun and expressive!
|
|
22
|
+
|
|
23
|
+
## ๐ Description
|
|
24
|
+
|
|
25
|
+
**catsay** is a tiny Python library that renders an ASCII cat with messages. It provides several functions for different use cases:
|
|
26
|
+
|
|
27
|
+
- ๐ฃ๏ธ `say` โ The cat says text with a given mood
|
|
28
|
+
- โ ๏ธ `warn` โ The cat outputs a warning
|
|
29
|
+
- โ `error` โ The cat shows an error message
|
|
30
|
+
- ๐ญ `think` โ The cat thinks thoughtfully
|
|
31
|
+
- โ `ask` โ The cat asks a question and returns the user's answer
|
|
32
|
+
|
|
33
|
+
### Features:
|
|
34
|
+
|
|
35
|
+
- ๐ญ **4 moods** โ happy, sleepy, angry, love
|
|
36
|
+
- ๐ฆ **Zero dependencies** โ Pure Python, no extra packages
|
|
37
|
+
- ๐ **Simple API** โ 5 functions for all use cases
|
|
38
|
+
- ๐จ **ASCII art** โ No external images or assets needed
|
|
39
|
+
- ๐ฌ **Interactive** โ `ask()` reads user input
|
|
40
|
+
|
|
41
|
+
## โ๏ธ Installation
|
|
42
|
+
|
|
43
|
+
### Option 1: Install from PyPI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install catsay-py
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Option 2: Copy the file
|
|
50
|
+
|
|
51
|
+
Just copy `catsay.py` into your project:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Place catsay.py in your project directory
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Option 3: Install from Git
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone https://github.com/FelineFantasy/catsay
|
|
61
|
+
cd catsay
|
|
62
|
+
pip install .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## ๐ Usage
|
|
66
|
+
|
|
67
|
+
### Basic
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from catsay import say, warn, error, think, ask
|
|
71
|
+
|
|
72
|
+
say("Hello, World!")
|
|
73
|
+
warn("Don't forget to feed the cat!")
|
|
74
|
+
error("Something went wrong!")
|
|
75
|
+
think("Hmm, interesting...")
|
|
76
|
+
answer = ask("What's your name?")
|
|
77
|
+
print(f"User said: {answer}")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Moods
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
say("I'm happy!", mood="happy")
|
|
84
|
+
say("Zzz...", mood="sleepy")
|
|
85
|
+
say("I'm angry!", mood="angry")
|
|
86
|
+
say("I love you!", mood="love")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Without text
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
say() # Just a cute cat
|
|
93
|
+
think() # Thinking cat
|
|
94
|
+
warn() # Warning cat
|
|
95
|
+
error() # Error cat
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## ๐ API Reference
|
|
99
|
+
|
|
100
|
+
### `say(text: str = "", mood: str = "happy") -> None`
|
|
101
|
+
|
|
102
|
+
The cat says text with a given mood.
|
|
103
|
+
|
|
104
|
+
| Parameter | Type | Default | Description |
|
|
105
|
+
|-----------|------|---------|-------------|
|
|
106
|
+
| `text` | `str` | `""` | Text to display |
|
|
107
|
+
| `mood` | `str` | `"happy"` | Cat mood: `happy`, `sleepy`, `angry`, `love` |
|
|
108
|
+
|
|
109
|
+
**Raises:** `ValueError` if mood is not supported
|
|
110
|
+
|
|
111
|
+
**Example:**
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
say("Meow!")
|
|
115
|
+
# /\_/\
|
|
116
|
+
# ( o.o ) > Meow!
|
|
117
|
+
# > ^ <
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### `warn(text: str = "") -> None`
|
|
123
|
+
|
|
124
|
+
The cat outputs a warning.
|
|
125
|
+
|
|
126
|
+
| Parameter | Type | Default | Description |
|
|
127
|
+
|-----------|------|---------|-------------|
|
|
128
|
+
| `text` | `str` | `""` | Warning message |
|
|
129
|
+
|
|
130
|
+
**Example:**
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
warn("Low disk space!")
|
|
134
|
+
# /\_/\
|
|
135
|
+
# ( -.o ) ~ Low disk space! ~~~
|
|
136
|
+
# > ^ <
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### `error(text: str = "Error") -> None`
|
|
142
|
+
|
|
143
|
+
The cat outputs an error message (uses angry mood).
|
|
144
|
+
|
|
145
|
+
| Parameter | Type | Default | Description |
|
|
146
|
+
|-----------|------|---------|-------------|
|
|
147
|
+
| `text` | `str` | `"Error"` | Error message |
|
|
148
|
+
|
|
149
|
+
**Example:**
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
error("File not found!")
|
|
153
|
+
# /\_/\
|
|
154
|
+
# ( รฒ.รณ ) > !!! File not found! !!!
|
|
155
|
+
# > ^ <
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `think(text: str = "", mood: str = "happy") -> None`
|
|
161
|
+
|
|
162
|
+
The cat says text thoughtfully (with `<` bubble).
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Default | Description |
|
|
165
|
+
|-----------|------|---------|-------------|
|
|
166
|
+
| `text` | `str` | `""` | Text to think about |
|
|
167
|
+
| `mood` | `str` | `"happy"` | Cat mood |
|
|
168
|
+
|
|
169
|
+
**Raises:** `ValueError` if mood is not supported
|
|
170
|
+
|
|
171
|
+
**Example:**
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
think("Hmm, interesting...")
|
|
175
|
+
# /\_/\
|
|
176
|
+
# ( o.o ) < Hmm, interesting...
|
|
177
|
+
# > ^ <
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### `ask(question: str = "") -> str`
|
|
183
|
+
|
|
184
|
+
The cat asks a question and returns the user's answer.
|
|
185
|
+
|
|
186
|
+
| Parameter | Type | Default | Description |
|
|
187
|
+
|-----------|------|---------|-------------|
|
|
188
|
+
| `question` | `str` | `""` | Question to ask |
|
|
189
|
+
|
|
190
|
+
**Returns:** `str` โ User's input
|
|
191
|
+
|
|
192
|
+
**Example:**
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
name = ask("What's your name?")
|
|
196
|
+
print(f"Hello, {name}!")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## ๐ญ Moods
|
|
200
|
+
|
|
201
|
+
| Mood | Face | Description |
|
|
202
|
+
|------|------|-------------|
|
|
203
|
+
| `happy` | `o.o` | Default, friendly cat |
|
|
204
|
+
| `sleepy` | `-.-` | Tired, drowsy cat |
|
|
205
|
+
| `angry` | `รฒ.รณ` | Angry, frustrated cat |
|
|
206
|
+
| `love` | `^.^` | Loving, affectionate cat |
|
|
207
|
+
|
|
208
|
+
## ๐งช Full Example
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from catsay import say, warn, error, think, ask
|
|
212
|
+
|
|
213
|
+
print("=== say() ===\n")
|
|
214
|
+
say()
|
|
215
|
+
say("Meow!", mood="happy")
|
|
216
|
+
say("Zzz", mood="sleepy")
|
|
217
|
+
say("meow :(", mood="angry")
|
|
218
|
+
say("I love you!", mood="love")
|
|
219
|
+
|
|
220
|
+
print("\n=== warn() ===\n")
|
|
221
|
+
warn()
|
|
222
|
+
warn("Where's my food!")
|
|
223
|
+
|
|
224
|
+
print("\n=== error() ===\n")
|
|
225
|
+
error()
|
|
226
|
+
error("The cat has fallen!")
|
|
227
|
+
|
|
228
|
+
print("\n=== think() ===\n")
|
|
229
|
+
think()
|
|
230
|
+
think("Hmm", mood="happy")
|
|
231
|
+
think("Hmm", mood="sleepy")
|
|
232
|
+
think("Hmm", mood="angry")
|
|
233
|
+
think("Hmm", mood="love")
|
|
234
|
+
|
|
235
|
+
print("\n=== ask() ===\n")
|
|
236
|
+
ask()
|
|
237
|
+
ask("Where's my food?")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## ๐งช Testing
|
|
241
|
+
|
|
242
|
+
Run the test suite with the standard library `unittest`:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
python -m unittest discover -s tests -v
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Tests also run automatically on every push and pull request via GitHub Actions.
|
|
249
|
+
|
|
250
|
+
## ๐ Project Structure
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
catsay/
|
|
254
|
+
โโโ .github/
|
|
255
|
+
โ โโโ FUNDING.yml # Support link for DonationAlerts
|
|
256
|
+
โ โโโ workflows/
|
|
257
|
+
โ โโโ tests.yml # CI workflow for running tests
|
|
258
|
+
โโโ catsay.py # Main library
|
|
259
|
+
โโโ README.md # Documentation
|
|
260
|
+
โโโ LICENSE # MIT License
|
|
261
|
+
โโโ pyproject.toml # Package configuration
|
|
262
|
+
โโโ tests/
|
|
263
|
+
โ โโโ test_catsay.py # Unit tests
|
|
264
|
+
โโโ .gitignore # Git ignore rules
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## ๐ Technologies
|
|
268
|
+
|
|
269
|
+
- **Python 3.8+** โ Pure standard library, no external dependencies
|
|
270
|
+
|
|
271
|
+
## ๐ Requirements
|
|
272
|
+
|
|
273
|
+
- Python 3.8+
|
|
274
|
+
- No external dependencies
|
|
275
|
+
|
|
276
|
+
## ๐ Support the Project
|
|
277
|
+
|
|
278
|
+
If you enjoy **catsay** and want to help keep the project alive, you can support me here:
|
|
279
|
+
|
|
280
|
+
[](https://www.donationalerts.com/r/felinefantasy)
|
|
281
|
+
|
|
282
|
+
Your support helps me:
|
|
283
|
+
- ๐ฑ Keep developing cute tools
|
|
284
|
+
- ๐ ๏ธ Add more moods and features
|
|
285
|
+
- โ Stay awake while coding at 4 AM
|
|
286
|
+
|
|
287
|
+
Every little bit is appreciated! โค๏ธ
|
|
288
|
+
|
|
289
|
+
## ๐ค Author
|
|
290
|
+
- **FelineFantasy**
|
|
291
|
+
- **License**: MIT
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# catsay ๐ฑ [](https://www.python.org/) [](LICENSE)
|
|
2
|
+
|
|
3
|
+
A cute ASCII cat library that says, warns, thinks, and asks questions. Perfect for making your CLI output more fun and expressive!
|
|
4
|
+
|
|
5
|
+
## ๐ Description
|
|
6
|
+
|
|
7
|
+
**catsay** is a tiny Python library that renders an ASCII cat with messages. It provides several functions for different use cases:
|
|
8
|
+
|
|
9
|
+
- ๐ฃ๏ธ `say` โ The cat says text with a given mood
|
|
10
|
+
- โ ๏ธ `warn` โ The cat outputs a warning
|
|
11
|
+
- โ `error` โ The cat shows an error message
|
|
12
|
+
- ๐ญ `think` โ The cat thinks thoughtfully
|
|
13
|
+
- โ `ask` โ The cat asks a question and returns the user's answer
|
|
14
|
+
|
|
15
|
+
### Features:
|
|
16
|
+
|
|
17
|
+
- ๐ญ **4 moods** โ happy, sleepy, angry, love
|
|
18
|
+
- ๐ฆ **Zero dependencies** โ Pure Python, no extra packages
|
|
19
|
+
- ๐ **Simple API** โ 5 functions for all use cases
|
|
20
|
+
- ๐จ **ASCII art** โ No external images or assets needed
|
|
21
|
+
- ๐ฌ **Interactive** โ `ask()` reads user input
|
|
22
|
+
|
|
23
|
+
## โ๏ธ Installation
|
|
24
|
+
|
|
25
|
+
### Option 1: Install from PyPI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install catsay-py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Option 2: Copy the file
|
|
32
|
+
|
|
33
|
+
Just copy `catsay.py` into your project:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Place catsay.py in your project directory
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Option 3: Install from Git
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/FelineFantasy/catsay
|
|
43
|
+
cd catsay
|
|
44
|
+
pip install .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## ๐ Usage
|
|
48
|
+
|
|
49
|
+
### Basic
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from catsay import say, warn, error, think, ask
|
|
53
|
+
|
|
54
|
+
say("Hello, World!")
|
|
55
|
+
warn("Don't forget to feed the cat!")
|
|
56
|
+
error("Something went wrong!")
|
|
57
|
+
think("Hmm, interesting...")
|
|
58
|
+
answer = ask("What's your name?")
|
|
59
|
+
print(f"User said: {answer}")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Moods
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
say("I'm happy!", mood="happy")
|
|
66
|
+
say("Zzz...", mood="sleepy")
|
|
67
|
+
say("I'm angry!", mood="angry")
|
|
68
|
+
say("I love you!", mood="love")
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Without text
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
say() # Just a cute cat
|
|
75
|
+
think() # Thinking cat
|
|
76
|
+
warn() # Warning cat
|
|
77
|
+
error() # Error cat
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## ๐ API Reference
|
|
81
|
+
|
|
82
|
+
### `say(text: str = "", mood: str = "happy") -> None`
|
|
83
|
+
|
|
84
|
+
The cat says text with a given mood.
|
|
85
|
+
|
|
86
|
+
| Parameter | Type | Default | Description |
|
|
87
|
+
|-----------|------|---------|-------------|
|
|
88
|
+
| `text` | `str` | `""` | Text to display |
|
|
89
|
+
| `mood` | `str` | `"happy"` | Cat mood: `happy`, `sleepy`, `angry`, `love` |
|
|
90
|
+
|
|
91
|
+
**Raises:** `ValueError` if mood is not supported
|
|
92
|
+
|
|
93
|
+
**Example:**
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
say("Meow!")
|
|
97
|
+
# /\_/\
|
|
98
|
+
# ( o.o ) > Meow!
|
|
99
|
+
# > ^ <
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### `warn(text: str = "") -> None`
|
|
105
|
+
|
|
106
|
+
The cat outputs a warning.
|
|
107
|
+
|
|
108
|
+
| Parameter | Type | Default | Description |
|
|
109
|
+
|-----------|------|---------|-------------|
|
|
110
|
+
| `text` | `str` | `""` | Warning message |
|
|
111
|
+
|
|
112
|
+
**Example:**
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
warn("Low disk space!")
|
|
116
|
+
# /\_/\
|
|
117
|
+
# ( -.o ) ~ Low disk space! ~~~
|
|
118
|
+
# > ^ <
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### `error(text: str = "Error") -> None`
|
|
124
|
+
|
|
125
|
+
The cat outputs an error message (uses angry mood).
|
|
126
|
+
|
|
127
|
+
| Parameter | Type | Default | Description |
|
|
128
|
+
|-----------|------|---------|-------------|
|
|
129
|
+
| `text` | `str` | `"Error"` | Error message |
|
|
130
|
+
|
|
131
|
+
**Example:**
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
error("File not found!")
|
|
135
|
+
# /\_/\
|
|
136
|
+
# ( รฒ.รณ ) > !!! File not found! !!!
|
|
137
|
+
# > ^ <
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### `think(text: str = "", mood: str = "happy") -> None`
|
|
143
|
+
|
|
144
|
+
The cat says text thoughtfully (with `<` bubble).
|
|
145
|
+
|
|
146
|
+
| Parameter | Type | Default | Description |
|
|
147
|
+
|-----------|------|---------|-------------|
|
|
148
|
+
| `text` | `str` | `""` | Text to think about |
|
|
149
|
+
| `mood` | `str` | `"happy"` | Cat mood |
|
|
150
|
+
|
|
151
|
+
**Raises:** `ValueError` if mood is not supported
|
|
152
|
+
|
|
153
|
+
**Example:**
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
think("Hmm, interesting...")
|
|
157
|
+
# /\_/\
|
|
158
|
+
# ( o.o ) < Hmm, interesting...
|
|
159
|
+
# > ^ <
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### `ask(question: str = "") -> str`
|
|
165
|
+
|
|
166
|
+
The cat asks a question and returns the user's answer.
|
|
167
|
+
|
|
168
|
+
| Parameter | Type | Default | Description |
|
|
169
|
+
|-----------|------|---------|-------------|
|
|
170
|
+
| `question` | `str` | `""` | Question to ask |
|
|
171
|
+
|
|
172
|
+
**Returns:** `str` โ User's input
|
|
173
|
+
|
|
174
|
+
**Example:**
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
name = ask("What's your name?")
|
|
178
|
+
print(f"Hello, {name}!")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## ๐ญ Moods
|
|
182
|
+
|
|
183
|
+
| Mood | Face | Description |
|
|
184
|
+
|------|------|-------------|
|
|
185
|
+
| `happy` | `o.o` | Default, friendly cat |
|
|
186
|
+
| `sleepy` | `-.-` | Tired, drowsy cat |
|
|
187
|
+
| `angry` | `รฒ.รณ` | Angry, frustrated cat |
|
|
188
|
+
| `love` | `^.^` | Loving, affectionate cat |
|
|
189
|
+
|
|
190
|
+
## ๐งช Full Example
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from catsay import say, warn, error, think, ask
|
|
194
|
+
|
|
195
|
+
print("=== say() ===\n")
|
|
196
|
+
say()
|
|
197
|
+
say("Meow!", mood="happy")
|
|
198
|
+
say("Zzz", mood="sleepy")
|
|
199
|
+
say("meow :(", mood="angry")
|
|
200
|
+
say("I love you!", mood="love")
|
|
201
|
+
|
|
202
|
+
print("\n=== warn() ===\n")
|
|
203
|
+
warn()
|
|
204
|
+
warn("Where's my food!")
|
|
205
|
+
|
|
206
|
+
print("\n=== error() ===\n")
|
|
207
|
+
error()
|
|
208
|
+
error("The cat has fallen!")
|
|
209
|
+
|
|
210
|
+
print("\n=== think() ===\n")
|
|
211
|
+
think()
|
|
212
|
+
think("Hmm", mood="happy")
|
|
213
|
+
think("Hmm", mood="sleepy")
|
|
214
|
+
think("Hmm", mood="angry")
|
|
215
|
+
think("Hmm", mood="love")
|
|
216
|
+
|
|
217
|
+
print("\n=== ask() ===\n")
|
|
218
|
+
ask()
|
|
219
|
+
ask("Where's my food?")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## ๐งช Testing
|
|
223
|
+
|
|
224
|
+
Run the test suite with the standard library `unittest`:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
python -m unittest discover -s tests -v
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Tests also run automatically on every push and pull request via GitHub Actions.
|
|
231
|
+
|
|
232
|
+
## ๐ Project Structure
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
catsay/
|
|
236
|
+
โโโ .github/
|
|
237
|
+
โ โโโ FUNDING.yml # Support link for DonationAlerts
|
|
238
|
+
โ โโโ workflows/
|
|
239
|
+
โ โโโ tests.yml # CI workflow for running tests
|
|
240
|
+
โโโ catsay.py # Main library
|
|
241
|
+
โโโ README.md # Documentation
|
|
242
|
+
โโโ LICENSE # MIT License
|
|
243
|
+
โโโ pyproject.toml # Package configuration
|
|
244
|
+
โโโ tests/
|
|
245
|
+
โ โโโ test_catsay.py # Unit tests
|
|
246
|
+
โโโ .gitignore # Git ignore rules
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## ๐ Technologies
|
|
250
|
+
|
|
251
|
+
- **Python 3.8+** โ Pure standard library, no external dependencies
|
|
252
|
+
|
|
253
|
+
## ๐ Requirements
|
|
254
|
+
|
|
255
|
+
- Python 3.8+
|
|
256
|
+
- No external dependencies
|
|
257
|
+
|
|
258
|
+
## ๐ Support the Project
|
|
259
|
+
|
|
260
|
+
If you enjoy **catsay** and want to help keep the project alive, you can support me here:
|
|
261
|
+
|
|
262
|
+
[](https://www.donationalerts.com/r/felinefantasy)
|
|
263
|
+
|
|
264
|
+
Your support helps me:
|
|
265
|
+
- ๐ฑ Keep developing cute tools
|
|
266
|
+
- ๐ ๏ธ Add more moods and features
|
|
267
|
+
- โ Stay awake while coding at 4 AM
|
|
268
|
+
|
|
269
|
+
Every little bit is appreciated! โค๏ธ
|
|
270
|
+
|
|
271
|
+
## ๐ค Author
|
|
272
|
+
- **FelineFantasy**
|
|
273
|
+
- **License**: MIT
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Catsay - ASCII cat with customizable moods and messages
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# catsay.py
|
|
8
|
+
__all__ = ["say", "warn", "error", "think", "ask"]
|
|
9
|
+
|
|
10
|
+
FACES = {
|
|
11
|
+
"happy": "o.o",
|
|
12
|
+
"sleepy": "-.-",
|
|
13
|
+
"angry": "รฒ.รณ",
|
|
14
|
+
"love": "^.^",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_face(mood: str) -> str:
|
|
19
|
+
"""Return the face for a mood, raising ValueError if it is unknown."""
|
|
20
|
+
if mood not in FACES:
|
|
21
|
+
raise ValueError(f"Unsupported mood: {mood}. Available: {list(FACES.keys())}")
|
|
22
|
+
return FACES[mood]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def say(text: str = "", mood: str = "happy") -> None:
|
|
26
|
+
"""The cat says text with a given mood (happy/sleepy/angry/love)."""
|
|
27
|
+
face = _get_face(mood)
|
|
28
|
+
|
|
29
|
+
cat = rf""" /\_/\
|
|
30
|
+
( {face} ) > {text}
|
|
31
|
+
> ^ <""" if text else rf""" /\_/\
|
|
32
|
+
( {face} )
|
|
33
|
+
> ^ <"""
|
|
34
|
+
print(cat)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def warn(text: str = "") -> None:
|
|
38
|
+
"""The cat outputs a warning."""
|
|
39
|
+
cat = rf""" /\_/\
|
|
40
|
+
( -.o ) ~ {text} ~~~
|
|
41
|
+
> ^ <"""
|
|
42
|
+
print(cat)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def error(text: str = "Error") -> None:
|
|
46
|
+
"""The cat outputs an error message."""
|
|
47
|
+
say(f"!!! {text} !!!", mood="angry")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def think(text: str = "", mood: str = "happy") -> None:
|
|
51
|
+
"""The cat says text thoughtfully."""
|
|
52
|
+
face = _get_face(mood)
|
|
53
|
+
thought = f" < {text}..." if text else " <"
|
|
54
|
+
cat = rf""" /\_/\
|
|
55
|
+
( {face} ){thought}
|
|
56
|
+
> ^ <"""
|
|
57
|
+
print(cat)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def ask(question: str = "") -> str:
|
|
61
|
+
"""The cat asks a question and returns the user's answer."""
|
|
62
|
+
say(question, mood="love")
|
|
63
|
+
return input("> ")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if __name__ == "__main__":
|
|
67
|
+
print("=== say() ===\n")
|
|
68
|
+
say()
|
|
69
|
+
say("Meow!", mood="happy")
|
|
70
|
+
say("Zzz", mood="sleepy")
|
|
71
|
+
say("meow :(", mood="angry")
|
|
72
|
+
say("I love you!", mood="love")
|
|
73
|
+
|
|
74
|
+
print("\n=== warn() ===\n")
|
|
75
|
+
warn()
|
|
76
|
+
warn("Where's my food!")
|
|
77
|
+
|
|
78
|
+
print("\n=== error() ===\n")
|
|
79
|
+
error()
|
|
80
|
+
error("The cat has fallen!")
|
|
81
|
+
|
|
82
|
+
print("\n=== think() ===\n")
|
|
83
|
+
think()
|
|
84
|
+
think("Hmm", mood="happy")
|
|
85
|
+
think("Hmm", mood="sleepy")
|
|
86
|
+
think("Hmm", mood="angry")
|
|
87
|
+
think("Hmm", mood="love")
|
|
88
|
+
|
|
89
|
+
print("\n=== ask() ===\n")
|
|
90
|
+
ask()
|
|
91
|
+
ask("Where's my food?")
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: catsay-py
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A cute cat that says things in the terminal
|
|
5
|
+
Author-email: FelineFantasy <mailsalavata5@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/FelineFantasy/catsay
|
|
8
|
+
Project-URL: Repository, https://github.com/FelineFantasy/catsay
|
|
9
|
+
Project-URL: Issues, https://github.com/FelineFantasy/catsay/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Terminals
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# catsay ๐ฑ [](https://www.python.org/) [](LICENSE)
|
|
20
|
+
|
|
21
|
+
A cute ASCII cat library that says, warns, thinks, and asks questions. Perfect for making your CLI output more fun and expressive!
|
|
22
|
+
|
|
23
|
+
## ๐ Description
|
|
24
|
+
|
|
25
|
+
**catsay** is a tiny Python library that renders an ASCII cat with messages. It provides several functions for different use cases:
|
|
26
|
+
|
|
27
|
+
- ๐ฃ๏ธ `say` โ The cat says text with a given mood
|
|
28
|
+
- โ ๏ธ `warn` โ The cat outputs a warning
|
|
29
|
+
- โ `error` โ The cat shows an error message
|
|
30
|
+
- ๐ญ `think` โ The cat thinks thoughtfully
|
|
31
|
+
- โ `ask` โ The cat asks a question and returns the user's answer
|
|
32
|
+
|
|
33
|
+
### Features:
|
|
34
|
+
|
|
35
|
+
- ๐ญ **4 moods** โ happy, sleepy, angry, love
|
|
36
|
+
- ๐ฆ **Zero dependencies** โ Pure Python, no extra packages
|
|
37
|
+
- ๐ **Simple API** โ 5 functions for all use cases
|
|
38
|
+
- ๐จ **ASCII art** โ No external images or assets needed
|
|
39
|
+
- ๐ฌ **Interactive** โ `ask()` reads user input
|
|
40
|
+
|
|
41
|
+
## โ๏ธ Installation
|
|
42
|
+
|
|
43
|
+
### Option 1: Install from PyPI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install catsay-py
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Option 2: Copy the file
|
|
50
|
+
|
|
51
|
+
Just copy `catsay.py` into your project:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Place catsay.py in your project directory
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Option 3: Install from Git
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone https://github.com/FelineFantasy/catsay
|
|
61
|
+
cd catsay
|
|
62
|
+
pip install .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## ๐ Usage
|
|
66
|
+
|
|
67
|
+
### Basic
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from catsay import say, warn, error, think, ask
|
|
71
|
+
|
|
72
|
+
say("Hello, World!")
|
|
73
|
+
warn("Don't forget to feed the cat!")
|
|
74
|
+
error("Something went wrong!")
|
|
75
|
+
think("Hmm, interesting...")
|
|
76
|
+
answer = ask("What's your name?")
|
|
77
|
+
print(f"User said: {answer}")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Moods
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
say("I'm happy!", mood="happy")
|
|
84
|
+
say("Zzz...", mood="sleepy")
|
|
85
|
+
say("I'm angry!", mood="angry")
|
|
86
|
+
say("I love you!", mood="love")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Without text
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
say() # Just a cute cat
|
|
93
|
+
think() # Thinking cat
|
|
94
|
+
warn() # Warning cat
|
|
95
|
+
error() # Error cat
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## ๐ API Reference
|
|
99
|
+
|
|
100
|
+
### `say(text: str = "", mood: str = "happy") -> None`
|
|
101
|
+
|
|
102
|
+
The cat says text with a given mood.
|
|
103
|
+
|
|
104
|
+
| Parameter | Type | Default | Description |
|
|
105
|
+
|-----------|------|---------|-------------|
|
|
106
|
+
| `text` | `str` | `""` | Text to display |
|
|
107
|
+
| `mood` | `str` | `"happy"` | Cat mood: `happy`, `sleepy`, `angry`, `love` |
|
|
108
|
+
|
|
109
|
+
**Raises:** `ValueError` if mood is not supported
|
|
110
|
+
|
|
111
|
+
**Example:**
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
say("Meow!")
|
|
115
|
+
# /\_/\
|
|
116
|
+
# ( o.o ) > Meow!
|
|
117
|
+
# > ^ <
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### `warn(text: str = "") -> None`
|
|
123
|
+
|
|
124
|
+
The cat outputs a warning.
|
|
125
|
+
|
|
126
|
+
| Parameter | Type | Default | Description |
|
|
127
|
+
|-----------|------|---------|-------------|
|
|
128
|
+
| `text` | `str` | `""` | Warning message |
|
|
129
|
+
|
|
130
|
+
**Example:**
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
warn("Low disk space!")
|
|
134
|
+
# /\_/\
|
|
135
|
+
# ( -.o ) ~ Low disk space! ~~~
|
|
136
|
+
# > ^ <
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### `error(text: str = "Error") -> None`
|
|
142
|
+
|
|
143
|
+
The cat outputs an error message (uses angry mood).
|
|
144
|
+
|
|
145
|
+
| Parameter | Type | Default | Description |
|
|
146
|
+
|-----------|------|---------|-------------|
|
|
147
|
+
| `text` | `str` | `"Error"` | Error message |
|
|
148
|
+
|
|
149
|
+
**Example:**
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
error("File not found!")
|
|
153
|
+
# /\_/\
|
|
154
|
+
# ( รฒ.รณ ) > !!! File not found! !!!
|
|
155
|
+
# > ^ <
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `think(text: str = "", mood: str = "happy") -> None`
|
|
161
|
+
|
|
162
|
+
The cat says text thoughtfully (with `<` bubble).
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Default | Description |
|
|
165
|
+
|-----------|------|---------|-------------|
|
|
166
|
+
| `text` | `str` | `""` | Text to think about |
|
|
167
|
+
| `mood` | `str` | `"happy"` | Cat mood |
|
|
168
|
+
|
|
169
|
+
**Raises:** `ValueError` if mood is not supported
|
|
170
|
+
|
|
171
|
+
**Example:**
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
think("Hmm, interesting...")
|
|
175
|
+
# /\_/\
|
|
176
|
+
# ( o.o ) < Hmm, interesting...
|
|
177
|
+
# > ^ <
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### `ask(question: str = "") -> str`
|
|
183
|
+
|
|
184
|
+
The cat asks a question and returns the user's answer.
|
|
185
|
+
|
|
186
|
+
| Parameter | Type | Default | Description |
|
|
187
|
+
|-----------|------|---------|-------------|
|
|
188
|
+
| `question` | `str` | `""` | Question to ask |
|
|
189
|
+
|
|
190
|
+
**Returns:** `str` โ User's input
|
|
191
|
+
|
|
192
|
+
**Example:**
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
name = ask("What's your name?")
|
|
196
|
+
print(f"Hello, {name}!")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## ๐ญ Moods
|
|
200
|
+
|
|
201
|
+
| Mood | Face | Description |
|
|
202
|
+
|------|------|-------------|
|
|
203
|
+
| `happy` | `o.o` | Default, friendly cat |
|
|
204
|
+
| `sleepy` | `-.-` | Tired, drowsy cat |
|
|
205
|
+
| `angry` | `รฒ.รณ` | Angry, frustrated cat |
|
|
206
|
+
| `love` | `^.^` | Loving, affectionate cat |
|
|
207
|
+
|
|
208
|
+
## ๐งช Full Example
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from catsay import say, warn, error, think, ask
|
|
212
|
+
|
|
213
|
+
print("=== say() ===\n")
|
|
214
|
+
say()
|
|
215
|
+
say("Meow!", mood="happy")
|
|
216
|
+
say("Zzz", mood="sleepy")
|
|
217
|
+
say("meow :(", mood="angry")
|
|
218
|
+
say("I love you!", mood="love")
|
|
219
|
+
|
|
220
|
+
print("\n=== warn() ===\n")
|
|
221
|
+
warn()
|
|
222
|
+
warn("Where's my food!")
|
|
223
|
+
|
|
224
|
+
print("\n=== error() ===\n")
|
|
225
|
+
error()
|
|
226
|
+
error("The cat has fallen!")
|
|
227
|
+
|
|
228
|
+
print("\n=== think() ===\n")
|
|
229
|
+
think()
|
|
230
|
+
think("Hmm", mood="happy")
|
|
231
|
+
think("Hmm", mood="sleepy")
|
|
232
|
+
think("Hmm", mood="angry")
|
|
233
|
+
think("Hmm", mood="love")
|
|
234
|
+
|
|
235
|
+
print("\n=== ask() ===\n")
|
|
236
|
+
ask()
|
|
237
|
+
ask("Where's my food?")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## ๐งช Testing
|
|
241
|
+
|
|
242
|
+
Run the test suite with the standard library `unittest`:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
python -m unittest discover -s tests -v
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Tests also run automatically on every push and pull request via GitHub Actions.
|
|
249
|
+
|
|
250
|
+
## ๐ Project Structure
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
catsay/
|
|
254
|
+
โโโ .github/
|
|
255
|
+
โ โโโ FUNDING.yml # Support link for DonationAlerts
|
|
256
|
+
โ โโโ workflows/
|
|
257
|
+
โ โโโ tests.yml # CI workflow for running tests
|
|
258
|
+
โโโ catsay.py # Main library
|
|
259
|
+
โโโ README.md # Documentation
|
|
260
|
+
โโโ LICENSE # MIT License
|
|
261
|
+
โโโ pyproject.toml # Package configuration
|
|
262
|
+
โโโ tests/
|
|
263
|
+
โ โโโ test_catsay.py # Unit tests
|
|
264
|
+
โโโ .gitignore # Git ignore rules
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## ๐ Technologies
|
|
268
|
+
|
|
269
|
+
- **Python 3.8+** โ Pure standard library, no external dependencies
|
|
270
|
+
|
|
271
|
+
## ๐ Requirements
|
|
272
|
+
|
|
273
|
+
- Python 3.8+
|
|
274
|
+
- No external dependencies
|
|
275
|
+
|
|
276
|
+
## ๐ Support the Project
|
|
277
|
+
|
|
278
|
+
If you enjoy **catsay** and want to help keep the project alive, you can support me here:
|
|
279
|
+
|
|
280
|
+
[](https://www.donationalerts.com/r/felinefantasy)
|
|
281
|
+
|
|
282
|
+
Your support helps me:
|
|
283
|
+
- ๐ฑ Keep developing cute tools
|
|
284
|
+
- ๐ ๏ธ Add more moods and features
|
|
285
|
+
- โ Stay awake while coding at 4 AM
|
|
286
|
+
|
|
287
|
+
Every little bit is appreciated! โค๏ธ
|
|
288
|
+
|
|
289
|
+
## ๐ค Author
|
|
290
|
+
- **FelineFantasy**
|
|
291
|
+
- **License**: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
catsay
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "catsay-py"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A cute cat that says things in the terminal"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [{name = "FelineFantasy", email = "mailsalavata5@gmail.com"}]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Topic :: Terminals",
|
|
17
|
+
]
|
|
18
|
+
requires-python = ">=3.8"
|
|
19
|
+
dependencies = []
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/FelineFantasy/catsay"
|
|
23
|
+
Repository = "https://github.com/FelineFantasy/catsay"
|
|
24
|
+
Issues = "https://github.com/FelineFantasy/catsay/issues"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
py-modules = ["catsay"]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import unittest
|
|
3
|
+
from contextlib import redirect_stdout
|
|
4
|
+
from unittest.mock import patch
|
|
5
|
+
|
|
6
|
+
import catsay
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def capture(func, *args, **kwargs):
|
|
10
|
+
output = io.StringIO()
|
|
11
|
+
with redirect_stdout(output):
|
|
12
|
+
func(*args, **kwargs)
|
|
13
|
+
return output.getvalue()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CatSayTests(unittest.TestCase):
|
|
17
|
+
def test_default_cat(self):
|
|
18
|
+
self.assertEqual(capture(catsay.say), " /\\_/\\\n ( o.o )\n > ^ <\n")
|
|
19
|
+
|
|
20
|
+
def test_text_and_mood(self):
|
|
21
|
+
self.assertEqual(
|
|
22
|
+
capture(catsay.say, "Meow!", mood="sleepy"),
|
|
23
|
+
" /\\_/\\\n ( -.- ) > Meow!\n > ^ <\n",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
def test_all_moods_render_their_face(self):
|
|
27
|
+
for mood, face in catsay.FACES.items():
|
|
28
|
+
self.assertIn(f"( {face} )", capture(catsay.say, "hi", mood=mood))
|
|
29
|
+
|
|
30
|
+
def test_unknown_mood_raises(self):
|
|
31
|
+
with self.assertRaises(ValueError):
|
|
32
|
+
capture(catsay.say, "hi", mood="grumpy")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class CatWarnTests(unittest.TestCase):
|
|
36
|
+
def test_empty_warning(self):
|
|
37
|
+
self.assertEqual(capture(catsay.warn), " /\\_/\\\n ( -.o ) ~ ~~~\n > ^ <\n")
|
|
38
|
+
|
|
39
|
+
def test_warning_with_text(self):
|
|
40
|
+
self.assertEqual(
|
|
41
|
+
capture(catsay.warn, "Low disk space!"),
|
|
42
|
+
" /\\_/\\\n ( -.o ) ~ Low disk space! ~~~\n > ^ <\n",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CatErrorTests(unittest.TestCase):
|
|
47
|
+
def test_default_error(self):
|
|
48
|
+
self.assertEqual(
|
|
49
|
+
capture(catsay.error),
|
|
50
|
+
" /\\_/\\\n ( รฒ.รณ ) > !!! Error !!!\n > ^ <\n",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def test_custom_error(self):
|
|
54
|
+
self.assertIn("!!! File not found! !!!", capture(catsay.error, "File not found!"))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class CatThinkTests(unittest.TestCase):
|
|
58
|
+
def test_empty_thought_has_no_ellipsis(self):
|
|
59
|
+
self.assertEqual(capture(catsay.think), " /\\_/\\\n ( o.o ) <\n > ^ <\n")
|
|
60
|
+
|
|
61
|
+
def test_thought_with_text(self):
|
|
62
|
+
self.assertEqual(
|
|
63
|
+
capture(catsay.think, "Hmm", mood="love"),
|
|
64
|
+
" /\\_/\\\n ( ^.^ ) < Hmm...\n > ^ <\n",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def test_unknown_mood_raises(self):
|
|
68
|
+
with self.assertRaises(ValueError):
|
|
69
|
+
capture(catsay.think, "Hmm", mood="grumpy")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class CatAskTests(unittest.TestCase):
|
|
73
|
+
def test_returns_user_answer(self):
|
|
74
|
+
output = io.StringIO()
|
|
75
|
+
with patch("builtins.input", return_value="fish") as mock_input:
|
|
76
|
+
with redirect_stdout(output):
|
|
77
|
+
answer = catsay.ask("What's for dinner?")
|
|
78
|
+
self.assertEqual(answer, "fish")
|
|
79
|
+
self.assertIn("What's for dinner?", output.getvalue())
|
|
80
|
+
mock_input.assert_called_once_with("> ")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
unittest.main()
|