项目作者: vsoch

项目描述 :
ascii database of pokemon... in python!
高级语言: Python
项目地址: git://github.com/vsoch/pokemon.git
创建时间: 2016-07-24T10:50:57Z
项目社区:https://github.com/vsoch/pokemon

开源协议:MIT License

下载


pokemon

Watch the pokemon ascii being born!

img/generation.gif

This is a module for generating ascii art for any of the 890 pokemon, across 8 generations, in the Pokedex. The package includes functions for generating “gravatars” (pokemon associated with an identifier like an email address), and functions for searching and exploring the database. The library includes a version of the database generated with pokemon/make_db.py that can be updated by re-running the script. The choice of ascii art is to produce pokemon images or avatars that are suited for command line tools.

  1. $ pokemon
  2. usage: pokemon [-h] [--avatar AVATAR] [--pokemon POKEMON] [--message MESSAGE]
  3. [--catch] [--list]
  4. generate pokemon ascii art and avatars
  5. optional arguments:
  6. -h, --help show this help message and exit
  7. --avatar AVATAR generate a pokemon avatar for some unique id.
  8. --pokemon POKEMON generate ascii for a particular pokemon (by name)
  9. --message MESSAGE add a custom message to your ascii!
  10. --catch catch a random pokemon!
  11. --list list pokemon available

Installation

You can install directly from pip:

  1. $ pip install pokemon

or for the development version, clone the repo and install manually:

  1. git clone https://github.com/vsoch/pokemon
  2. cd pokemon
  3. pip install .

Produce an avatar

An “avatar” is an image that is consistently associated with some unique ID. In our case, this is an ascii avatar. For example,

img/avatar.png

To do this, I take the hash of a string, and then use modulus to get the remainder of that hash divided by the number of pokemon in the database. This means that, given that the database doesn’t change, and given that the pokemon have unique IDs in the range of 1 to 721, you should always get the same image for some unique id (like an email).

Note the database was updated between version 0.34 and version 0.35, so you will
get different avatars depending on the version you are using. There are Docker tags
and pip installs available for each, and version 0.35 is suggested to use with Python 3.

  1. $ pokemon --avatar vsoch
  2. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  3. @@@@@@@@@?:::::::::::::::+.+.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  4. @@@@@@@*?%:::::::::*::****#SSSSS%.**S+@@@@@@@@@@@@@@@@@@@@@@
  5. @@@@@@@*???:::::::*********#...+****++++S:@@@@@@@@@@@@@@@@@@
  6. @@@@@@@::SSS............S+.*....*****?%S+#@@@@@@@@@@@@@@@@@@
  7. @@@@@@@@@@@@@@.?SS.S.....S?%%%%%%%%..**+....?@@@@@@@@@@@@@@@
  8. @@@@@@@@@@@@@@@@..%???????#%%%%%%%....**++.....?@@@@@@@@@@@@
  9. @@@@@@@@@@@@@@..+++%????????????%%%%%%*.......%++%@@@@@@@@@@
  10. @@@@@@@@@@@@S.+++++S%+++SS%..????%%%?..............@@@@@@@@@
  11. @@@@@@@@@@@%++++S+S++++.......?@%%%%%......SSSSSS:@@@@@@@@@@
  12. @@@@@@@@@?.++.+++++%**.#.....?.%%%%%,@@@@@@@@@@@#.%@@@@@@@@@
  13. @@@@@@@?.*.....+.**.*.....%.....+++%@@#+++S.%?+++.%@@@@@@@@@
  14. @@@@@#***......%:.**++%........++++#.#+++++.++++.S@@@@@@@@@@
  15. @@@@,+%.......?+++++......#....#.**+++#@@%++++.SS@@@@@@@@@@@
  16. @@@:+?+...?..S.......S%%%...S+++::.+++@%++++.?.#@@@@@@@@@@@@
  17. @@@@@@@,?...S%%*@@.?%++SS.S++.+S...?#.+++S++..@@@@@@@@@@@@@@
  18. @@@@@@@@@@@@@@*...?.@SS+.SS....?....#++%:+..S@@@@@@@@@@@@@@@
  19. @@@@@@@@@@?+S.%?#+@@@@@S...#???%%%S@+:::...@@@@@@@@@@@@@@@@@
  20. @@@@@@@++S....#@@@@@@@@@@@@@@@S.%...:::+#...@@@@@@@@@@@@@@@@
  21. @@@@#++.....S@@@@@@@@@@@@@.S..++..%?:...+?...@@@@@@@@@@@@@@@
  22. @@@.......?@@@@@@@@@@@@+.....+++......#.++....*@@@@@@@@@@@@@
  23. @@.*+...@@@@@@@@@@@@S.....?.S+..S....++...S....@@@@@@@@@@@@@
  24. @+*++@@@@@@@@@@@@,?........@:%.*SS?+++++..+.....%@@@@@@@@@@@
  25. @:+%@@@@@@@@@@@:?........?@@@#:::.+++++#...+.....#@@@@@@@@@@
  26. @S@@@@@@@@@@@@+.........#@@@@@@+..++++....+......S.,@@@@@@@@
  27. @@@@@@@@@@@@@S%##.....S@@@@@@@@@*.??.......#@%...??.#@@@@@@@
  28. @@@@@@@@@@@@@S%@....?S@@@@@@@@@@@@@%.?...?.@@@.S+.....@@@@@@
  29. @@@@@@@@@@@@@@@@S.....?@@@@@@@@@@@@@@@.%S.?@@@@+++S....@@@@@
  30. @@@@@@@@@@@@@@@@+......@@@@@@@@@@@@@@@@@@@@@@@@.+++S....@@@@
  31. @@@@@@@@@@@@@@@.%......@@@@@@@@@@@@@@@@@@@@@@@@@++++......@@
  32. @@@@@@@@@@@@@@.%......S@@@@@@@@@@@@@@@@@@@@@@@@@++++......@@
  33. @@@@@@@@@@@@@S.#.....++@@@@@@@@@@@@@@@@@@@@@@@@@..+..+....S@
  34. @@@@@@@@@@@.::++S.@@?+?@@@@@@@@@@@@@@@@@@@@@@@@@+...#S+?..SS
  35. @@@@@@@@@@@@,@,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+..*++,@
  36. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.::+@@
  37. vsoch

You can also use the functions on command line:

  1. from pokemon.skills import get_avatar
  2. # Just get the string!
  3. avatar = get_avatar("vsoch", print_screen=False)
  4. print(avatar)
  5. # Remove the name at the bottom, print to screen (default)
  6. avatar = get_avatar("vsoch", include_name=False)

List Pokemon

Want a complete listing of your Pokemon choices in the database?

  1. pokemon --list
  2. Slugma
  3. Machop
  4. Druddigon
  5. Magby
  6. Clawitzer
  7. Growlithe
  8. Empoleon
  9. Dusknoir
  10. Rhydon
  11. Krookodile
  12. Hoppip
  13. Swellow
  14. Oddish
  15. Scrafty
  16. Boldore
  17. Pancham
  18. Beheeyem
  19. Honedge
  20. ...
  21. Jumpluff
  22. Rotom
  23. Frillish
  24. Lapras
  25. Clamperl
  26. Wingull
  27. Vespiquen
  28. Keldeo
  29. Mareep
  30. Phantump
  31. Medicham
  32. Shuckle
  33. Lickitung
  34. Chingling

You could use this to parse through a function. Here we show a simple loop to print the name of the Pokemon, but you would be more creative!

  1. for gotcha in $(pokemon --list)
  2. do
  3. echo $gotcha
  4. done

Randomly select a Pokemon

You might want to just randomly get a pokemon! Do this with the --catch command line argument!

  1. pokemon --catch
  2. @%,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  3. .????.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  4. .???????S@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  5. :?????????#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  6. *?????????????*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  7. @???????#?????###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,*.??#
  8. @?????,##,S???#####@@@@@@@@@@@@@@@@@@@@@@@@@@S##????????????
  9. @?????*,,,,,,########@@@@@@@@@@@@@@@@@:###????????????????#@
  10. @##????,,,,,,,,,#####@@@@@@@@@@@@@.######?????#?:#????????@@
  11. @####?#,,,,,,,,,,,##@@@@@@@@@@@@@@#######*,,,,,*##+?????+@@@
  12. @######,,,,,,,,,,,S@@@@@@@@@@@@@@#.,,,,,,,,,,,,,,:?####@@@@@
  13. @######,,,,,,,,,,%@@,S.S.,@@@@@@@,,,,,,,,,,,,,,,######@@@@@@
  14. @@#####,,,,,,,,.,,,,,,,,,,,,,,,*#,,,,,,,,,,,,,.#####:@@@@@@@
  15. @@@@@@@@@@.#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,######@@@@@@@@@
  16. @@@@@@@@@,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,+######@@@@@@@@@@
  17. @@@@@@@@%,,,,,++:,,,,,,,,,,,,,,,,,,,,,@@:.######:@@@@@@@@@@@
  18. @@@@@@@:,,,:##@@@#,,,,,,,,,,,,?@S#,,,,,,@@@@@@@@@@@@@@@@@@@@
  19. @@@@@@@?,,,#######,,,,,,,,,,,#.@:##,,,:?@@@@@@@@@@@@@@@@@@@@
  20. @@@@@@@.,,S,??%?*,,,,,,,,,,,,####?%+,::%@@@@@@@@@@@@@@@@@@@@
  21. @@@@@@@@?..*+,,,,,,*,,,,,,,,,,,+#S,::::*@@@@@@@@@@@@@@@@@@@@
  22. @@@@@@@@@%..*,,,,,,,,,,,,,,,,,,,:.*...%@@@@@@@@@@@@@@@@@@@@@
  23. @@@@@@@@@@.**::*::::::,,:::::::+.....@@@@@@@@@@@@@@@@@@@@@@@
  24. @@@@@@@@.@@@@?:**:::*::::::::::*...@@@@@@@@@@@@@@@@@@@@@@@@@
  25. @@@@@?,,,,,,,,,:,##S::::**:::S#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  26. @@@@@@@.,,,,,,:S#?##?########:#****#,@@@@@@@@@@@@@@@@@@@@@@@
  27. @@@@@@@@@@,%:*%,??#,,,,:*S##**:..****:,.*@@@@@@@@@@@@@@@@@@@
  28. @@@@@@@@@@@@@+,,,,,,,,,,,,,,,,,,*...*:,.,@@@@@@@@@@@@@@@@@@@
  29. @@@@@@@@@@@@@+,,,,,,,,,,,,,,,,,,?@@@@@*#?@@@@@@@@@@@@@@@@@@@
  30. @@@@@@@@@@@@@*,,,,,,,,,,,,,,,,,,.@#########?@@@@@@@@@@@@@@@@
  31. @@@@@@@@@@@@@.*:,,,,,,,,,,,,,,:.##%,?#####????:@@@@@@@@@@@@@
  32. @@@@@@@@@@@@@@?.....*******....S@@@@@@:##?????@@@@@@@@@@@@@@
  33. @@@@@@@@@@@@@@S.+..********...#%@@@@@@@@@##,@@@@@@@@@@@@@@@@
  34. @@@@@@@@@@@#*,,,,*.#@@@@@@@..*:,,*S@@@@@@@@@@@@@@@@@@@@@@@@@
  35. @@@@@@@@@@+@,%,,,#@@@@@@@@@@,S,,,%,,:@@@@@@@@@@@@@@@@@@@@@@@
  36. Pichu

You can equivalently use the --message argument to add a custom message to your catch!

  1. pokemon --catch --message "You got me!"
  2. @@@@@@@@@*.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  3. @@@@@@@@...+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  4. @@@@@@@@++++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  5. :..+,@@+.+++%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  6. @..++++S++++++.?...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  7. @@@:S.S+SSS.S%++.+++@@@@@@@@@@+.%.@@@@@@@@@@@@@@@@@@@@@@@@@@
  8. @@@@:SSSSSSSSSS,@@@@@@@,:,:.SS+.....+.@@@@@@@@@@@@@@@@@@@@@@
  9. @@@@,:%SS++SS.,.%,:,S,,,,+..%.........S.@@@@@@@@@@@@@@@@@@@@
  10. @@@@@,:*...:,,+,.,,,,,,,*%%%++++..+++SSS+@@@@@@@@@@@@@@@@@@@
  11. @@@@@@,,.....%:,,,:.:.,:.%%.SSSS++SS+%+S%,+@@@@@@@@@@@@@@@@@
  12. @@@@@@@*.....S...***+,,,%..%++,?SSS.%.%%%:,.,@@@@@@@@@@@@@@@
  13. @@@@@@@@,+**........,,,,....++S@,+%..#..%,,S..@@@@@@@@@@@@@@
  14. @@@@@@@@@@@@@@@@*..:,,,,,%..%++S%%.%%.S%%,,*+.+@@@@@@@@@@@@@
  15. @@@@@@@@@@@@@@@@S,,,,,,,,,%%%..SS..%?%%%,,,S+...@@@@@@@@@@@@
  16. @@@@@@@@@@@@@@@@S.:::::::::%.%%S...%%%%:::*.....**@@@@@@@@@@
  17. @@@@@@@@@@@@@@@@.%%..:::::::S%%.?%%%%%:::....**,S,,:@@@@@@@@
  18. @@@@@@@@@@@@@@:::*%%%%?..*:::,.%%%%.,:*.%@@.*:,,,:,,S@....@@
  19. @@@@@@@@@@@@@:,:,::*.?%%%%%%?+*%%?.?%%%%%+@@,,,,,,,.++%++@@@
  20. @@@@@@@@@@@@@@*,,,,,**...*%%%%%%%%%%?++++++.@,,,,,SS+SS++@@@
  21. @@@@@@@@@@@@@,,.,S,,,,:....***%%?%++++++++++.@.,,+SSSSS.S+@@
  22. @@@@@@@@@@@@,,SSSS..:.%,:*..?%%??%%++++++.+S+@@@.S..%S.%.S++
  23. @@@@@@@@@@@,,S.....S::*.@@@%%%%@?%%#+++++%%%?S@@@@@.%.,@@...
  24. @@@@@@@@@@@:,,?.%%%::::@@@...%.@?.%.++++.+%%%%.@@@@..++@@@@@
  25. @@@@@@@@@@S,.%%.:,,,,,S@@@@@.?@@+SS,S..........@@@@@,@@@@@@@
  26. @@@@@@@@@@@+S...++.,,:@@@@@@@@@@@@@@@%....SSS+SS@@@@@@@@@@@@
  27. You got me!

You can also catch pokemon in your python applications. If you are going to be generating many, it is recommended to load the database once and provide it to the function, otherwise it will be loaded each time.

  1. from pokemon.master import catch_em_all, get_pokemon
  2. pokemons = catch_em_all()
  3. catch = get_pokemon(pokemons=pokemons)

The catch is a dictionary, with keys as the pokemon ID, and the value being another dictionary with various meta data (height, weight, japanese, link, ascii, etc).

Updating the database

The database was generated by running the script make_db.py, and you can update it by running it yourself, if at some point in the future new pokemon are added to the index.

  1. git clone https://github.com/vsoch/pokemon
  2. cd pokemon
  3. cd scripts
  4. pip install -r requirements.txt
  5. python make_db.py

Then move your old database (and you can do this to keep it in case you don’t want changes to persist):

  1. mv pokemon/database dbbackup
  2. mv ./database pokemon/database

The file pokemons.json will be saved under pokemon/databases. Next, install as usual.

  1. python setup.py install

Docker

You can also use the Docker image,
which provides the various functions and Scientific Filesystem apps.
The 0.35 tag was developed with Python 2, and the 0.35 tag is Python 3 and later
(with an updated database).

What can I do?

  1. docker run vanessa/pokemon apps
  2. list
  3. catch
  4. avatar

Give me my avatar!

  1. docker run vanessa/pokemon run avatar vsoch

Catch a random Pokemon

  1. docker run vanessa/pokemon run catch

What Pokemon can I catch?

  1. docker run vanessa/pokemon run list

Catch me Venusaur!

  1. docker run vanessa/pokemon run catch Venusaur

You can also build the image locally:

  1. docker build -t vanessa/pokemon .

Singularity

We can do the same with Singularity containers!

  1. sudo singularity build pokemons Singularity

What can I do?

  1. ./pokemons apps
  2. avatar
  3. catch
  4. list

Give me my avatar!

  1. ./pokemons run avatar vsoch

Catch a random Pokemon

  1. ./pokemons run catch

What Pokemons can I catch?

  1. ./pokemons list
  2. ...
  3. Phantump
  4. Trevenant
  5. Pumpkaboo
  6. Gourgeist
  7. Bergmite
  8. Avalugg
  9. Noibat
  10. Noivern
  11. Xerneas
  12. Yveltal
  13. Zygarde
  14. Diancie
  15. Hoopa
  16. Volcanion

Catch a specific Pokemon

  1. ./pokemons run catch Pikachu
  2. [catch] executing /bin/bash /scif/apps/catch/scif/runscript Pikachu
  3. @@@@@@@@@@@@@.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  4. @@@@@@@@@@@,??@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  5. @@@@@@@@@@.###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  6. @@@@@@@@@,##:,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*?@@
  7. @@@@@@@@@#::::@@@@@@@@@@@@@@@@@@@@@@@@@,*.???%@@@@@@@@*,,,@@
  8. @@@@@@@@::,,::@@@@@@@@@@@@@@@@@@%:,,:#####??,@@@@@@*,,,,,,:@
  9. @@@@@@@@%:,,:.@@@@@@@@@@@@@@.:::::::.#####@@@@@@@.::,,,,,::@
  10. @@@@@@@@%::::.,,,,:,:%@@:,:::::::::S###@@@@@@@@%,:::::,::,:%
  11. @@@@@@@@.S,,,,,,,,::::::::::::::::?@@@@@@@@@@?::::::::::::::
  12. @@@@@@@:,,,,,,,:,#.#?::::::+.,@@@@@@@@@@@@@.::::::::::::::::
  13. @@@@@,#:S,,:,::::*#.,:::::::*@@@@@@@@@@@@,::::::::::::::::+@
  14. @@@@@:%S::::::*,,:::...+.::::S@@@@@@@@@@:::::::::::::::%@@@@
  15. @@@@*.::::,SSSS%::::+++++:::::%@@@@@@@@:::::::::::::%@@@@@@@
  16. @@@@@.+:,,::S%+S::::.+++:::::::,@@@@@@@@@:::*::::S@@@@@@@@@@
  17. @@@@@@.S:::::.*.::::::::::::::::@@@@@@@@@,****%@@@@@@@@@@@@@
  18. @@@@@@@@.:::::::::::::::*:,**::::,@@@@@@@@,***@@@@@@@@@@@@@@
  19. @@@@,%,::::::::::::::::*.****::,:S%@@@@@@......@@@@@@@@@@@@@
  20. ,**::::,,,,,,:::::::::::+:**:::::,::@@?.....S@@@@@@@@@@@@@@@
  21. %:*:,:::,,,,,,,,,,,::::::%::::::,,,::,@S..+@@@@@@@@@@@@@@@@@
  22. @@@@@,S%+::*,:,,::,:,,,,::::::::::::::?@@%SS?@@@@@@@@@@@@@@@
  23. @@@@@@@@@@@@.:,,,,:,,,,,,,:::::::::::::+SSSSS.@@@@@@@@@@@@@@
  24. @@@@@@@@@@@@@:,,,:::::,::::,:::::::::::*?.@@@@@@@@@@@@@@@@@@
  25. @@@@@@@@@@@@@+,:,:,::::::::::,,::,::::**.SS@@@@@@@@@@@@@@@@@
  26. @@@@@@@@@@@@@S,,:,,,,::::::::::::::::****@@@@@@@@@@@@@@@@@@@
  27. @@@@@@@@@@@@@@:::::::::****::::::*******S@@@@@@@@@@@@@@@@@@@
  28. @@@@@@@@@@@@@@@**********.%..***********@@@@@@@@@@@@@@@@@@@@
  29. @@@@@@@@@@@@@@@@@,?+S%@@@@@@@@@@@@......@@@@@@@@@@@@@@@@@@@@
  30. @@@@@@@@@@@@@@@@@@@+..*@@@@@@@@@@@@@:+**@@@@@@@@@@@@@@@@@@@@

Issues and updates

Would you like different or updated functionality?
Please ping me by adding an issue!
I did this for fun, might sneak it into a few command line applications,
and it’s pretty simple so far! I hope you have fun with it! :D