1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
%global _empty_manifest_terminate_build 0
Name: python-pypokedex
Version: 1.6.0
Release: 1
Summary: A minimal pokedex library
License: MIT
URL: https://github.com/arnavb/pypokedex#readme
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/80/34/63e08ff0c21fb2ab4ae5c2c305c01c163be9e6543e6125709298d2a6f2b2/pypokedex-1.6.0.tar.gz
BuildArch: noarch
Requires: python3-requests
%description
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/logo.png'/>
</p>
[](https://travis-ci.com/arnavb/pypokedex)
[](https://ci.appveyor.com/project/arnavb/pypokedex/branch/master)
[](https://codecov.io/gh/arnavb/pypokedex)
[](https://pypi.org/project/pypokedex/)

[](https://github.com/arnavb/pypokedex/blob/master/LICENSE)
PyPokedex is a minimal pokedex library for Python that uses [PokeAPI](https://pokeapi.co/) internally to get Pokemon data. A simple example:
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/example-usage.png'/>
</p>
## Requirements
- Python 3.6+
## Installing
Use:
```bash
$ pip install pypokedex
```
to get the latest stable release, or:
```bash
$ pip install git+https://github.com/arnavb/pypokedex.git@master
```
to get the latest commit on master.
## Documentation
This package (`pypokedex`) only provides one function through the
public API—`get`. It can be used as follows:
```python
import pypokedex
pokemon = pypokedex.get(dex=DEX) # DEX must be a valid _national_ pokedex
# number
pokemon2 = pypokedex.get(name=NAME) # NAME must be a valid name of a pokemon
```
In addition to the above function, the following classes are provided as part of the public API:
- `Pokemon` (returned by `get`),
- `BaseStats`,
- `Ability`,
- `Sprites`,
- and `Move`
Note that these classes shouldn't be initialized through client code; their purpose is mainly for type annotations.
### Possible Exceptions
- A `TypeError` will be raised if the wrong number of arguments or the wrong
type of arguments are passed.
- A `PyPokedexHTTPError` will be raised with an HTTP code of 404 if the Pokemon
requested is not found. **Note**: The `name` parameter to `get` is _case-insensitive_.
- A `PyPokedexHTTPError` will be raised with the proper HTTP code if another type
of HTTP error occurs.
- A `PyPokedexError` will be raised if a [requests exception](http://docs.python-requests.org/en/master/_modules/requests/exceptions/)
occurs (with the exception of `requests.exceptions.HTTPError`, handled in the
previous two bullet points).
- A `PyPokedexError` will be raised if data is missing when parsing the returned
JSON from PokeAPI (usually this indicates an API change).
Once a valid `pypokedex.pokemon.Pokemon` object is returned, the following
members are provided for its consumption:
### Member Variables
- `dex` (`int`): Contains the _national_ Pokedex number of the current Pokemon.
- `name` (`str`): Contains the name of the current Pokemon.
- `height` (`int`): Contains the height of the current Pokemon in decimeters (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `weight` (`int`): Contains the weight of the current Pokemon in hectograms (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `base_experience` (`intt`): Contains the base experience yield of the current Pokemon.
- `types` (`List[str]`): Contains a list of strings with the name of the current
Pokemon's types.
- `abilities` (`List[Ability]`): Contains a list of named tuples called `Ability`.
Each `Ability` has the following members:
- `name` (`str`): The name of the current ability.
- `is_hidden` (`bool`): Whether the current ability is a hidden ability or not.
- `base_stats` (`BaseStats`): Contains a named tuple with the current
Pokemon's base stats stored as follows (all `int`s):
- `hp`: The base HP of the current Pokemon.
- `attack`: The base attack of the current Pokemon.
- `defense`: The base defense of the current Pokemon.
- `sp_atk`: The base special attack of the current Pokemon.
- `sp_def`: The base special defense of the current Pokemon.
- `speed`: The base speed of the current Pokemon.
- `moves` (`DefaultDict[str, List[Move]]`): Contains a dictionary of game names
(according to PokeAPI) to a list of named tuples called `Move` representing the
moves the current Pokemon learns in the respective game. The `Move` named tuple
contains the following members:
- `name` (`str`): The name of the current move.
- `learn_method` (`str`): The method the current Pokemon uses to learn the
current move (according to PokeAPI).
- `level` (`int`): The level the current Pokemon learns the current move if
`learn_method` is `level-up`, `None` otherwise.
- `sprites` (`Sprites`): Contains two dictionaries, `front` and `back` representing the respective sprites of the current Pokemon. The keys in the dictionary are [Pokeapi sprite keys](https://pokeapi.co/docs/v2.html#pokemonsprites) without the direction prefix (e.g `back_default` is just `default` in the `back` dictionary).
- `other_sprites` (`Dict[str, Sprites]`): Contains a mapping of sprite groups to sprites (sprites are stored in the same way as the `sprites` instance variable.
- `version_sprites` (`Dict[str, Dict[str, Sprites]]`): Contains a mapping of generations to games to sprites. Note that like the API itself, keys are included for all generations and games, despite the fact that those Pokemon may not exist in said generation or game. e.g `pypokedex.get(name='garchomp')` would include keys for generation 1 through 3, even though it was introduced in generation 4.
### Member Functions
- `def exists_in(self, game: str) -> bool`: Method to check whether the current
Pokemon exists in a specific game.
- `def learns(self, move_name: str, game: str) -> bool`: Method to check
whether the current Pokemon learns a specific move in a specific game.
- `def get_descriptions(self, language="en") -> Dict[str, str]`: Method to returns all the descriptions of the current Pokemon for the specified language (en by default). **Note**: This function only returns the descriptions as a dictionary. It doesn't store them anywhere on the Pokemon object. This was done since the descriptions are fetched from a separate API endpoint.
- `def __str__(self) -> str`: Method to get a string represenation of the
current Pokemon. This string is of the form: `Pokemon(dex={self.dex}, name='{self.name}')`.
- `__eq__, __lt__, __gt__, __le__, __ge__`: Methods that implement various
comparison operators for Pokemon objects in terms of their Pokedex number.
#### Possible Exceptions
- `learns` will raise a `PyPokedexError` if the current Pokemon does not exist
in the game specified.
## License
This library is licensed under the [MIT License](https://github.com/arnavb/pypokedex/blob/master/LICENSE).
### Dependency Licenses
This library depends on [requests](https://github.com/requests/requests), which is licensed under the [Apache 2.0 License](https://github.com/requests/requests/blob/master/LICENSE).
%package -n python3-pypokedex
Summary: A minimal pokedex library
Provides: python-pypokedex
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-pypokedex
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/logo.png'/>
</p>
[](https://travis-ci.com/arnavb/pypokedex)
[](https://ci.appveyor.com/project/arnavb/pypokedex/branch/master)
[](https://codecov.io/gh/arnavb/pypokedex)
[](https://pypi.org/project/pypokedex/)

[](https://github.com/arnavb/pypokedex/blob/master/LICENSE)
PyPokedex is a minimal pokedex library for Python that uses [PokeAPI](https://pokeapi.co/) internally to get Pokemon data. A simple example:
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/example-usage.png'/>
</p>
## Requirements
- Python 3.6+
## Installing
Use:
```bash
$ pip install pypokedex
```
to get the latest stable release, or:
```bash
$ pip install git+https://github.com/arnavb/pypokedex.git@master
```
to get the latest commit on master.
## Documentation
This package (`pypokedex`) only provides one function through the
public API—`get`. It can be used as follows:
```python
import pypokedex
pokemon = pypokedex.get(dex=DEX) # DEX must be a valid _national_ pokedex
# number
pokemon2 = pypokedex.get(name=NAME) # NAME must be a valid name of a pokemon
```
In addition to the above function, the following classes are provided as part of the public API:
- `Pokemon` (returned by `get`),
- `BaseStats`,
- `Ability`,
- `Sprites`,
- and `Move`
Note that these classes shouldn't be initialized through client code; their purpose is mainly for type annotations.
### Possible Exceptions
- A `TypeError` will be raised if the wrong number of arguments or the wrong
type of arguments are passed.
- A `PyPokedexHTTPError` will be raised with an HTTP code of 404 if the Pokemon
requested is not found. **Note**: The `name` parameter to `get` is _case-insensitive_.
- A `PyPokedexHTTPError` will be raised with the proper HTTP code if another type
of HTTP error occurs.
- A `PyPokedexError` will be raised if a [requests exception](http://docs.python-requests.org/en/master/_modules/requests/exceptions/)
occurs (with the exception of `requests.exceptions.HTTPError`, handled in the
previous two bullet points).
- A `PyPokedexError` will be raised if data is missing when parsing the returned
JSON from PokeAPI (usually this indicates an API change).
Once a valid `pypokedex.pokemon.Pokemon` object is returned, the following
members are provided for its consumption:
### Member Variables
- `dex` (`int`): Contains the _national_ Pokedex number of the current Pokemon.
- `name` (`str`): Contains the name of the current Pokemon.
- `height` (`int`): Contains the height of the current Pokemon in decimeters (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `weight` (`int`): Contains the weight of the current Pokemon in hectograms (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `base_experience` (`intt`): Contains the base experience yield of the current Pokemon.
- `types` (`List[str]`): Contains a list of strings with the name of the current
Pokemon's types.
- `abilities` (`List[Ability]`): Contains a list of named tuples called `Ability`.
Each `Ability` has the following members:
- `name` (`str`): The name of the current ability.
- `is_hidden` (`bool`): Whether the current ability is a hidden ability or not.
- `base_stats` (`BaseStats`): Contains a named tuple with the current
Pokemon's base stats stored as follows (all `int`s):
- `hp`: The base HP of the current Pokemon.
- `attack`: The base attack of the current Pokemon.
- `defense`: The base defense of the current Pokemon.
- `sp_atk`: The base special attack of the current Pokemon.
- `sp_def`: The base special defense of the current Pokemon.
- `speed`: The base speed of the current Pokemon.
- `moves` (`DefaultDict[str, List[Move]]`): Contains a dictionary of game names
(according to PokeAPI) to a list of named tuples called `Move` representing the
moves the current Pokemon learns in the respective game. The `Move` named tuple
contains the following members:
- `name` (`str`): The name of the current move.
- `learn_method` (`str`): The method the current Pokemon uses to learn the
current move (according to PokeAPI).
- `level` (`int`): The level the current Pokemon learns the current move if
`learn_method` is `level-up`, `None` otherwise.
- `sprites` (`Sprites`): Contains two dictionaries, `front` and `back` representing the respective sprites of the current Pokemon. The keys in the dictionary are [Pokeapi sprite keys](https://pokeapi.co/docs/v2.html#pokemonsprites) without the direction prefix (e.g `back_default` is just `default` in the `back` dictionary).
- `other_sprites` (`Dict[str, Sprites]`): Contains a mapping of sprite groups to sprites (sprites are stored in the same way as the `sprites` instance variable.
- `version_sprites` (`Dict[str, Dict[str, Sprites]]`): Contains a mapping of generations to games to sprites. Note that like the API itself, keys are included for all generations and games, despite the fact that those Pokemon may not exist in said generation or game. e.g `pypokedex.get(name='garchomp')` would include keys for generation 1 through 3, even though it was introduced in generation 4.
### Member Functions
- `def exists_in(self, game: str) -> bool`: Method to check whether the current
Pokemon exists in a specific game.
- `def learns(self, move_name: str, game: str) -> bool`: Method to check
whether the current Pokemon learns a specific move in a specific game.
- `def get_descriptions(self, language="en") -> Dict[str, str]`: Method to returns all the descriptions of the current Pokemon for the specified language (en by default). **Note**: This function only returns the descriptions as a dictionary. It doesn't store them anywhere on the Pokemon object. This was done since the descriptions are fetched from a separate API endpoint.
- `def __str__(self) -> str`: Method to get a string represenation of the
current Pokemon. This string is of the form: `Pokemon(dex={self.dex}, name='{self.name}')`.
- `__eq__, __lt__, __gt__, __le__, __ge__`: Methods that implement various
comparison operators for Pokemon objects in terms of their Pokedex number.
#### Possible Exceptions
- `learns` will raise a `PyPokedexError` if the current Pokemon does not exist
in the game specified.
## License
This library is licensed under the [MIT License](https://github.com/arnavb/pypokedex/blob/master/LICENSE).
### Dependency Licenses
This library depends on [requests](https://github.com/requests/requests), which is licensed under the [Apache 2.0 License](https://github.com/requests/requests/blob/master/LICENSE).
%package help
Summary: Development documents and examples for pypokedex
Provides: python3-pypokedex-doc
%description help
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/logo.png'/>
</p>
[](https://travis-ci.com/arnavb/pypokedex)
[](https://ci.appveyor.com/project/arnavb/pypokedex/branch/master)
[](https://codecov.io/gh/arnavb/pypokedex)
[](https://pypi.org/project/pypokedex/)

[](https://github.com/arnavb/pypokedex/blob/master/LICENSE)
PyPokedex is a minimal pokedex library for Python that uses [PokeAPI](https://pokeapi.co/) internally to get Pokemon data. A simple example:
<p align='center'>
<img src='https://raw.githubusercontent.com/arnavb/pypokedex/master/assets/example-usage.png'/>
</p>
## Requirements
- Python 3.6+
## Installing
Use:
```bash
$ pip install pypokedex
```
to get the latest stable release, or:
```bash
$ pip install git+https://github.com/arnavb/pypokedex.git@master
```
to get the latest commit on master.
## Documentation
This package (`pypokedex`) only provides one function through the
public API—`get`. It can be used as follows:
```python
import pypokedex
pokemon = pypokedex.get(dex=DEX) # DEX must be a valid _national_ pokedex
# number
pokemon2 = pypokedex.get(name=NAME) # NAME must be a valid name of a pokemon
```
In addition to the above function, the following classes are provided as part of the public API:
- `Pokemon` (returned by `get`),
- `BaseStats`,
- `Ability`,
- `Sprites`,
- and `Move`
Note that these classes shouldn't be initialized through client code; their purpose is mainly for type annotations.
### Possible Exceptions
- A `TypeError` will be raised if the wrong number of arguments or the wrong
type of arguments are passed.
- A `PyPokedexHTTPError` will be raised with an HTTP code of 404 if the Pokemon
requested is not found. **Note**: The `name` parameter to `get` is _case-insensitive_.
- A `PyPokedexHTTPError` will be raised with the proper HTTP code if another type
of HTTP error occurs.
- A `PyPokedexError` will be raised if a [requests exception](http://docs.python-requests.org/en/master/_modules/requests/exceptions/)
occurs (with the exception of `requests.exceptions.HTTPError`, handled in the
previous two bullet points).
- A `PyPokedexError` will be raised if data is missing when parsing the returned
JSON from PokeAPI (usually this indicates an API change).
Once a valid `pypokedex.pokemon.Pokemon` object is returned, the following
members are provided for its consumption:
### Member Variables
- `dex` (`int`): Contains the _national_ Pokedex number of the current Pokemon.
- `name` (`str`): Contains the name of the current Pokemon.
- `height` (`int`): Contains the height of the current Pokemon in decimeters (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `weight` (`int`): Contains the weight of the current Pokemon in hectograms (see [veekun/pokedex#249](https://github.com/veekun/pokedex/issues/249)).
- `base_experience` (`intt`): Contains the base experience yield of the current Pokemon.
- `types` (`List[str]`): Contains a list of strings with the name of the current
Pokemon's types.
- `abilities` (`List[Ability]`): Contains a list of named tuples called `Ability`.
Each `Ability` has the following members:
- `name` (`str`): The name of the current ability.
- `is_hidden` (`bool`): Whether the current ability is a hidden ability or not.
- `base_stats` (`BaseStats`): Contains a named tuple with the current
Pokemon's base stats stored as follows (all `int`s):
- `hp`: The base HP of the current Pokemon.
- `attack`: The base attack of the current Pokemon.
- `defense`: The base defense of the current Pokemon.
- `sp_atk`: The base special attack of the current Pokemon.
- `sp_def`: The base special defense of the current Pokemon.
- `speed`: The base speed of the current Pokemon.
- `moves` (`DefaultDict[str, List[Move]]`): Contains a dictionary of game names
(according to PokeAPI) to a list of named tuples called `Move` representing the
moves the current Pokemon learns in the respective game. The `Move` named tuple
contains the following members:
- `name` (`str`): The name of the current move.
- `learn_method` (`str`): The method the current Pokemon uses to learn the
current move (according to PokeAPI).
- `level` (`int`): The level the current Pokemon learns the current move if
`learn_method` is `level-up`, `None` otherwise.
- `sprites` (`Sprites`): Contains two dictionaries, `front` and `back` representing the respective sprites of the current Pokemon. The keys in the dictionary are [Pokeapi sprite keys](https://pokeapi.co/docs/v2.html#pokemonsprites) without the direction prefix (e.g `back_default` is just `default` in the `back` dictionary).
- `other_sprites` (`Dict[str, Sprites]`): Contains a mapping of sprite groups to sprites (sprites are stored in the same way as the `sprites` instance variable.
- `version_sprites` (`Dict[str, Dict[str, Sprites]]`): Contains a mapping of generations to games to sprites. Note that like the API itself, keys are included for all generations and games, despite the fact that those Pokemon may not exist in said generation or game. e.g `pypokedex.get(name='garchomp')` would include keys for generation 1 through 3, even though it was introduced in generation 4.
### Member Functions
- `def exists_in(self, game: str) -> bool`: Method to check whether the current
Pokemon exists in a specific game.
- `def learns(self, move_name: str, game: str) -> bool`: Method to check
whether the current Pokemon learns a specific move in a specific game.
- `def get_descriptions(self, language="en") -> Dict[str, str]`: Method to returns all the descriptions of the current Pokemon for the specified language (en by default). **Note**: This function only returns the descriptions as a dictionary. It doesn't store them anywhere on the Pokemon object. This was done since the descriptions are fetched from a separate API endpoint.
- `def __str__(self) -> str`: Method to get a string represenation of the
current Pokemon. This string is of the form: `Pokemon(dex={self.dex}, name='{self.name}')`.
- `__eq__, __lt__, __gt__, __le__, __ge__`: Methods that implement various
comparison operators for Pokemon objects in terms of their Pokedex number.
#### Possible Exceptions
- `learns` will raise a `PyPokedexError` if the current Pokemon does not exist
in the game specified.
## License
This library is licensed under the [MIT License](https://github.com/arnavb/pypokedex/blob/master/LICENSE).
### Dependency Licenses
This library depends on [requests](https://github.com/requests/requests), which is licensed under the [Apache 2.0 License](https://github.com/requests/requests/blob/master/LICENSE).
%prep
%autosetup -n pypokedex-1.6.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-pypokedex -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.6.0-1
- Package Spec generated
|