pokemon-images 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl
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.
Potentially problematic release.
This version of pokemon-images might be problematic. Click here for more details.
- pokemon_images/__init__.py +11 -9
- pokemon_images/__main__.py +7 -0
- pokemon_images/tests.py +42 -0
- pokemon_images-1.1.0.dist-info/METADATA +38 -0
- pokemon_images-1.1.0.dist-info/RECORD +6 -0
- pokemon_images-1.0.0.dist-info/METADATA +0 -15
- pokemon_images-1.0.0.dist-info/RECORD +0 -4
- {pokemon_images-1.0.0.dist-info → pokemon_images-1.1.0.dist-info}/WHEEL +0 -0
pokemon_images/__init__.py
CHANGED
|
@@ -6,16 +6,18 @@ def get_url_from_number(image_number: int):
|
|
|
6
6
|
"""Gets a Pokemon image URL from an image number."""
|
|
7
7
|
padded: str
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
padded =
|
|
13
|
-
elif len(
|
|
14
|
-
padded =
|
|
15
|
-
elif len(
|
|
16
|
-
padded =
|
|
9
|
+
image_number = str(image_number)
|
|
10
|
+
|
|
11
|
+
if len(image_number) == 1:
|
|
12
|
+
padded = "00" + image_number
|
|
13
|
+
elif len(image_number) == 2:
|
|
14
|
+
padded = "0" + image_number
|
|
15
|
+
elif len(image_number) == 3:
|
|
16
|
+
padded = image_number
|
|
17
|
+
elif len(image_number) == 4:
|
|
18
|
+
padded = image_number
|
|
17
19
|
else:
|
|
18
|
-
|
|
20
|
+
raise ValueError
|
|
19
21
|
|
|
20
22
|
return f"https://assets.pokemon.com/assets/cms2/img/pokedex/full/{padded}.png"
|
|
21
23
|
|
pokemon_images/tests.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
import requests # Needed for testing that generated URLs return valid contents
|
|
4
|
+
import __init__ as pokemon_images
|
|
5
|
+
|
|
6
|
+
class URLsTestCase(unittest.TestCase):
|
|
7
|
+
"""Tests for `pokemon_images.get_url_from_number`."""
|
|
8
|
+
|
|
9
|
+
def test_generates_good_url(self):
|
|
10
|
+
self.assertTrue(pokemon_images.get_url_from_number(1).startswith("https://") or
|
|
11
|
+
pokemon_images.get_url_from_number(1).startswith("http://"))
|
|
12
|
+
|
|
13
|
+
def test_generates_good_status(self):
|
|
14
|
+
"""Ensure that the URLs generated as intended."""
|
|
15
|
+
r = requests.get(pokemon_images.get_url_from_number(1))
|
|
16
|
+
self.assertEqual(r.status_code, 200)
|
|
17
|
+
|
|
18
|
+
def test_generates_good_content_type(self):
|
|
19
|
+
"""Ensure that the URLs generated as intended."""
|
|
20
|
+
r = requests.get(pokemon_images.get_url_from_number(1))
|
|
21
|
+
self.assertEqual(r.headers["content-type"], "image/png")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class RandomURLsTestCase(unittest.TestCase):
|
|
25
|
+
"""Tests for `pokemon_images.get_random_url`."""
|
|
26
|
+
|
|
27
|
+
def test_generates_good_url(self):
|
|
28
|
+
self.assertTrue(pokemon_images.get_random_url().startswith("https://") or
|
|
29
|
+
pokemon_images.get_random_url().startswith("http://"))
|
|
30
|
+
|
|
31
|
+
def test_generates_good_status(self):
|
|
32
|
+
"""Ensure that the URLs generated as intended."""
|
|
33
|
+
r = requests.get(pokemon_images.get_random_url())
|
|
34
|
+
self.assertEqual(r.status_code, 200)
|
|
35
|
+
|
|
36
|
+
def test_generates_good_content_type(self):
|
|
37
|
+
"""Ensure that the URLs generated as intended."""
|
|
38
|
+
r = requests.get(pokemon_images.get_random_url())
|
|
39
|
+
self.assertEqual(r.headers["content-type"], "image/png")
|
|
40
|
+
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
unittest.main()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pokemon-images
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Randomly get images of Pokémon from the official Pokémon website
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Tomodachi94
|
|
7
|
+
Requires-Python: >=3.5,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Multimedia
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Project-URL: Bug Tracker, https://github.com/tomodachi94/pokemon-images.py/issues
|
|
21
|
+
Project-URL: Homepage, https://github.com/tomodachi94/pokemon-images.py
|
|
22
|
+
Project-URL: Source, https://github.com/tomodachi94/pokemon-images.py
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# `pokemon_images.py`
|
|
26
|
+
|
|
27
|
+
A small library with no dependencies to get a random image of a Pokémon.
|
|
28
|
+
|
|
29
|
+
Usage is simple: `import pokemon_images`, then `pokemon_images.get_random_url`.
|
|
30
|
+
|
|
31
|
+
## Some notes
|
|
32
|
+
|
|
33
|
+
There are no accented `é`s in this library to aid typing on keyboards that do not have this key. In all cases, `é` should be replaced by `e` except in documentation.
|
|
34
|
+
|
|
35
|
+
This library is fully typed and fully documented with Python docstrings.
|
|
36
|
+
|
|
37
|
+
Contributions are welcome, but this library is considered feature-complete.
|
|
38
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pokemon_images/__init__.py,sha256=OlPt_2VKmzvidZhA1icdpc6Oeh6920KQk-2pTrGsvEw,813
|
|
2
|
+
pokemon_images/__main__.py,sha256=7MNpvS8VtQoOQ6lt3WVzAcnnGc8YG7ILix8pxnVMcPk,129
|
|
3
|
+
pokemon_images/tests.py,sha256=cWmY9w9YhhJxMC-ysscykzyuPhgyv0-0V0EzwcAwQJc,1670
|
|
4
|
+
pokemon_images-1.1.0.dist-info/WHEEL,sha256=DA86_h4QwwzGeRoz62o1svYt5kGEXpoUTuTtwzoTb30,83
|
|
5
|
+
pokemon_images-1.1.0.dist-info/METADATA,sha256=-irhU7bHu7MT8rKXsQIE5HPhjJjXVQLYyFWGcZL5H0M,1507
|
|
6
|
+
pokemon_images-1.1.0.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pokemon-images
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Randomly get images of Pokémon from the official Pokémon website
|
|
5
|
-
License: MIT
|
|
6
|
-
Author: Tomodachi94
|
|
7
|
-
Requires-Python: >=3.5,<4.0
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.5
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
pokemon_images/__init__.py,sha256=f3mU7FW2GDcbzdgc2ERloKV-j-FDVTMYPtTRVweUndk,805
|
|
2
|
-
pokemon_images-1.0.0.dist-info/WHEEL,sha256=DA86_h4QwwzGeRoz62o1svYt5kGEXpoUTuTtwzoTb30,83
|
|
3
|
-
pokemon_images-1.0.0.dist-info/METADATA,sha256=yFn9kBmq2CjcpskkK1w9IRphGpRp5ZMLjeCT9YfE45U,595
|
|
4
|
-
pokemon_images-1.0.0.dist-info/RECORD,,
|
|
File without changes
|