├── MANIFEST.in ├── .gitignore ├── docs ├── images │ ├── pyjokes.png │ └── society.jpg ├── society.md ├── install.md ├── index.md └── api.md ├── pyjokes ├── __init__.py ├── jokes_de.py ├── pyjokes.py ├── jokes_gl.py ├── jokes_es.py └── jokes_en.py ├── scripts ├── pyjokes └── pyjoke ├── .travis.yml ├── mkdocs.yml ├── tests ├── test_joke_length.py ├── test_cli_error.py ├── test_joke_encoding.py └── test_get_joke.py ├── CONTRIBUTING.md ├── LICENCE.txt ├── setup.py └── README.rst /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.egg-info/ 3 | build/ 4 | dist/ 5 | website 6 | .idea/ 7 | .cache/ 8 | -------------------------------------------------------------------------------- /docs/images/pyjokes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/pyjokes/master/docs/images/pyjokes.png -------------------------------------------------------------------------------- /docs/images/society.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/pyjokes/master/docs/images/society.jpg -------------------------------------------------------------------------------- /pyjokes/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from .pyjokes import get_joke, get_jokes 3 | 4 | 5 | __version__ = '0.5.0' 6 | -------------------------------------------------------------------------------- /pyjokes/jokes_de.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | neutral = [ 4 | 'No jokes found.', 5 | ] 6 | 7 | jokes_de = { 8 | 'neutral': neutral, 9 | 'all': neutral, 10 | } 11 | -------------------------------------------------------------------------------- /scripts/pyjokes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | 6 | def main(): 7 | print('Did you mean pyjoke?') 8 | return 1 9 | 10 | if __name__ == '__main__': 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - "2.7" 5 | - "3.4" 6 | 7 | env: 8 | - PIP_USE_MIRRORS=true 9 | 10 | install: 11 | - python setup.py install 12 | - pip install coveralls 13 | 14 | script: 15 | - python setup.py test 16 | - coverage run --source=pyjokes setup.py test 17 | 18 | after_success: 19 | - coveralls 20 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: pyjokes 2 | theme: mkdocs 3 | site_url: http://pyjok.es/ 4 | repo_url: https://github.com/pyjokes/pyjokes 5 | site_description: One-line programmer jokes (jokes-as-a-service) 6 | site_author: Pyjokes Society 7 | site_dir: website 8 | google_analytics: ['UA-65996819-1', 'pyjok.es'] 9 | pages: 10 | - 'Home': 'index.md' 11 | - 'Install': 'install.md' 12 | - 'API Reference': 'api.md' 13 | - 'Pyjokes Society': 'society.md' 14 | -------------------------------------------------------------------------------- /docs/society.md: -------------------------------------------------------------------------------- 1 | # Pyjokes Society 2 | 3 | Founders: 4 | 5 | - [Ben Nuttall](https://twitter.com/ben_nuttall) - Chairperson 6 | - [Alex Savio](https://twitter.com/alex_savio) - Vice-chairperson 7 | - [Borja Ayerdi](https://twitter.com/bayerdi) - Treasurer 8 | - [Oier Etxaniz](https://twitter.com/oiertwo) - Spokesperson 9 | 10 | ![Pyjokes Society](images/society.jpg) 11 | 12 | See members on the [wiki](https://github.com/pyjokes/pyjokes/wiki). 13 | -------------------------------------------------------------------------------- /tests/test_joke_length.py: -------------------------------------------------------------------------------- 1 | from pyjokes.jokes_en import jokes_en 2 | from pyjokes.jokes_de import jokes_de 3 | from pyjokes.jokes_es import jokes_es 4 | from pyjokes.jokes_gl import jokes_gl 5 | 6 | 7 | def _test_joke_length(joke): 8 | assert len(joke) <= 140 9 | 10 | 11 | def _test_joke_group(jokes): 12 | for joke in jokes: 13 | _test_joke_length(joke) 14 | 15 | 16 | def test_jokes_lengths(): 17 | jokes_sets = [jokes_en, jokes_es, jokes_de, jokes_gl] 18 | for jokes in jokes_sets: 19 | _test_joke_group(jokes['all']) 20 | -------------------------------------------------------------------------------- /tests/test_cli_error.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import subprocess 3 | from subprocess import PIPE 4 | 5 | 6 | def test_pyjokes_call_exception(): 7 | pytest.raises( 8 | subprocess.CalledProcessError, "subprocess.check_call('pyjokes')" 9 | ) 10 | 11 | 12 | def test_pyjokes_call_output(): 13 | try: 14 | p = subprocess.Popen('pyjokes', stdin=PIPE, stdout=PIPE, stderr=PIPE) 15 | except: 16 | out, err = p.communicate() 17 | assert out == b'Did you mean pyjoke?' 18 | assert p.returncode == 1 19 | pass 20 | -------------------------------------------------------------------------------- /tests/test_joke_encoding.py: -------------------------------------------------------------------------------- 1 | from pyjokes.jokes_en import jokes_en 2 | from pyjokes.jokes_de import jokes_de 3 | from pyjokes.jokes_es import jokes_es 4 | from pyjokes.jokes_gl import jokes_gl 5 | 6 | 7 | #test if joke is windows compatible 8 | def _test_joke_win(joke): 9 | assert len(joke) <= len(joke.encode('ascii', 'ignore')) 10 | 11 | def _test_default_locale(joke): 12 | import locale 13 | encod = locale.getdefaultlocale()[1] 14 | assert len(joke) <= len(joke.encode(encod, 'ignore')) 15 | 16 | #unix is full compatible - no need of tests 17 | def test_jokes_lengths(): 18 | jokes_sets = [jokes_en, jokes_es, jokes_de, jokes_gl] 19 | for jokes in jokes_sets: 20 | for j in jokes['all']: 21 | _test_default_locale(j) 22 | _test_joke_win(j) 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Jokes 4 | 5 | New jokes should be proposed in the [proposal issue](https://github.com/pyjokes/pyjokes/issues/10) or via pull request. 6 | 7 | New languages are welcome and should follow the existing format. 8 | 9 | New categories should be proposed in a [GitHub issue](https://github.com/pyjokes/pyjokes/issues). 10 | 11 | ### Joke policy 12 | 13 | - Maximum joke length: 140 characters 14 | - Gender neutrality (mix of he/she/they) 15 | - No assumption of gender or sexuality 16 | - No racism 17 | 18 | ## Technical Issues 19 | 20 | Please report bugs and other issues as [GitHub issues](https://github.com/pyjokes/pyjokes/issues) ensuring to give as much detail about your problem as possible. 21 | 22 | ## Complaints 23 | 24 | If you have a problem with the content of the jokes, please raise a [GitHub issue](https://github.com/pyjokes/pyjokes/issues) for us to discuss. 25 | 26 | ## Development Policy 27 | 28 | - Python 2/3 compatibility 29 | - PEP8-compliance (with exceptions) 30 | - Tests should be passing 31 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # Install pyjokes 2 | 3 | ## Pip or virtualenv 4 | 5 | If you have `pip` installed, or you're using a virtualenv, just install `pyjokes`: 6 | 7 | ```bash 8 | pip3 install pyjokes 9 | ``` 10 | 11 | or 12 | 13 | ```bash 14 | pip install pyjokes 15 | ``` 16 | 17 | ## Linux (Ubuntu) 18 | 19 | First install `pip`, Python's package manager using Ubuntu's package manager: 20 | 21 | ```bash 22 | sudo apt-get install python3-pip 23 | ``` 24 | 25 | then install `pyjokes` using `pip`: 26 | 27 | ```bash 28 | sudo pip3 install pyjokes 29 | ``` 30 | 31 | The instructions for Python 2 are similar: 32 | 33 | ```bash 34 | sudo apt-get install python-pip 35 | sudo pip install pyjokes 36 | ``` 37 | 38 | ## Raspberry Pi (Raspbian) 39 | 40 | First install `pip`, Python's package manager using your Raspbian's package manager: 41 | 42 | ```bash 43 | sudo apt-get install python3-pip 44 | ``` 45 | 46 | then install `pyjokes` using `pip`: 47 | 48 | ```bash 49 | sudo pip-3.2 install pyjokes 50 | ``` 51 | 52 | The instructions for Python 2 are similar: 53 | 54 | ```bash 55 | sudo apt-get install python-pip 56 | sudo pip install pyjokes 57 | ``` 58 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # pyjokes 2 | 3 | One line jokes for programmers (jokes as a service) 4 | 5 | ![pyjokes](images/pyjokes.png) 6 | 7 | ## Install 8 | 9 | Install with pip: 10 | 11 | ```bash 12 | sudo pip install pyjokes 13 | ``` 14 | 15 | See the [install](install.md) page for information on installing on different platforms. 16 | 17 | ## Usage 18 | 19 | ### Command line 20 | 21 | Run `pyjoke` at the command line to get a random joke: 22 | 23 | ``` 24 | $ pyjoke 25 | Why did the programmer quit his job? Because he didn't get arrays. 26 | ``` 27 | 28 | ### Python 29 | 30 | Import the `pyjokes` module in a Python file and use the `get_joke` function to easily drop a random joke into your application: 31 | 32 | ```python 33 | import pyjokes 34 | 35 | print(pyjokes.get_joke()) 36 | ``` 37 | 38 | See the [API reference](api.md) for full documentation. 39 | 40 | ## Proposal of new jokes 41 | 42 | New jokes should be proposed in the [proposal issue](https://github.com/pyjokes/pyjokes/issues/10) or via pull request. 43 | 44 | ## Reference 45 | 46 | - [GitHub](https://github.com/pyjokes/pyjokes) 47 | - [Wiki](https://github.com/pyjokes/pyjokes/wiki) 48 | - [PyPi](https://pypi.python.org/pypi/pyjokes) 49 | - [Twitter](https://twitter.com/pyjokes_bot) 50 | -------------------------------------------------------------------------------- /docs/api.md: -------------------------------------------------------------------------------- 1 | # API Reference 2 | 3 | Import the pyjokes module to access `pyjokes` in any Python application: 4 | 5 | ```python 6 | import pyjokes 7 | ``` 8 | 9 | ## pyjokes.get_joke() 10 | 11 | Returns a random joke from the given category in the given language. 12 | 13 | | Parameters | Types | Values | Default | 14 | | ---------- | ----- | ------ | ------- | 15 | | language | str | 'en', 'de', 'es', 'gl' | 'en' | 16 | | category | str | 'neutral', 'adult', 'chuck', 'all' | 'neutral' | 17 | 18 | Return type: str 19 | 20 | If the `language` value provided is not available, a `LanguageNotFoundError` exception is raised. 21 | 22 | If the `category` value provided is not available, a `CategoryNotFoundError` exception is raised. 23 | 24 | ## pyjokes.get_jokes() 25 | 26 | Returns a list of jokes from the given category in the given language. 27 | 28 | | Parameters | Types | Values | Default | 29 | | ---------- | ----- | ------ | ------- | 30 | | language | str | 'en', 'de', 'es', 'gl' | 'en' | 31 | | category | str | 'neutral', 'adult', 'chuck', 'all' | 'neutral' | 32 | 33 | Return type: list 34 | 35 | If the `language` value provided is not available, a `LanguageNotFoundError` exception is raised. 36 | 37 | If the `category` value provided is not available, a `CategoryNotFoundError` exception is raised. 38 | -------------------------------------------------------------------------------- /tests/test_get_joke.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from pyjokes import get_joke, get_jokes 3 | from pyjokes.pyjokes import LanguageNotFoundError, CategoryNotFoundError 4 | 5 | 6 | languages = ['en', 'de', 'es', 'gl'] 7 | categories = ['neutral', 'adult', 'all'] 8 | test_data = ['', 'abc', '123'] 9 | 10 | 11 | def test_get_joke(): 12 | assert get_joke() 13 | 14 | for language in languages: 15 | assert get_joke(language=language) 16 | 17 | for category in categories: 18 | assert get_joke(category=category) 19 | 20 | 21 | def test_get_joke_with_language_raises(): 22 | for language in test_data: 23 | assert pytest.raises( 24 | LanguageNotFoundError, get_joke, language=language 25 | ) 26 | 27 | 28 | def test_get_joke_with_category_raises(): 29 | for category in test_data: 30 | assert pytest.raises( 31 | CategoryNotFoundError, get_joke, category=category 32 | ) 33 | 34 | 35 | def test_get_joke_in_language_with_category_raises(): 36 | for category in test_data: 37 | assert pytest.raises( 38 | CategoryNotFoundError, get_joke, 39 | language='en', category=category 40 | ) 41 | 42 | def test_all_jokes_are_funny(): 43 | for language in languages: 44 | jokes = get_jokes(language=language, category='all') 45 | for joke in jokes: 46 | assert True 47 | -------------------------------------------------------------------------------- /scripts/pyjoke: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import argparse 5 | from pyjokes import pyjokes 6 | 7 | 8 | def create_argparser(): 9 | parser = argparse.ArgumentParser( 10 | description='One line jokes for programmers (jokes as a service)' 11 | ) 12 | 13 | parser.add_argument( 14 | '-c', '--category', 15 | dest='category', 16 | choices=['neutral', 'adult', 'chuck', 'all'], 17 | default='neutral', 18 | help='Joke category.' 19 | ) 20 | 21 | parser.add_argument( 22 | '-l', '--language', 23 | dest='language', 24 | choices=['en', 'de', 'es', 'gl'], 25 | default='en', 26 | help='Joke language.' 27 | ) 28 | 29 | return parser 30 | 31 | 32 | def main(): 33 | parser = create_argparser() 34 | 35 | try: 36 | args = parser.parse_args() 37 | except argparse.ArgumentError as exc: 38 | print('Error parsing arguments.') 39 | parser.error(str(exc.message)) 40 | exit(-1) 41 | 42 | try: 43 | joke = pyjokes.get_joke(language=args.language, category=args.category) 44 | except pyjokes.LanguageNotFoundError: 45 | print('No such language %s' % args.language) 46 | exit(-1) 47 | except pyjokes.CategoryNotFoundError: 48 | print('No such category %s' % args.category) 49 | exit(-1) 50 | 51 | print(joke) 52 | 53 | if __name__ == '__main__': 54 | main() 55 | -------------------------------------------------------------------------------- /pyjokes/pyjokes.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | import random 3 | 4 | from .jokes_en import jokes_en 5 | from .jokes_de import jokes_de 6 | from .jokes_es import jokes_es 7 | from .jokes_gl import jokes_gl 8 | 9 | 10 | all_jokes = { 11 | 'en': jokes_en, 12 | 'de': jokes_de, 13 | 'es': jokes_es, 14 | 'gl': jokes_gl, 15 | } 16 | 17 | 18 | class LanguageNotFoundError(Exception): 19 | pass 20 | 21 | 22 | class CategoryNotFoundError(Exception): 23 | pass 24 | 25 | 26 | def get_jokes(language='en', category='neutral'): 27 | """ 28 | Parameters 29 | ---------- 30 | category: str 31 | Choices: 'neutral', 'adult', 'chuck', 'all' 32 | lang: str 33 | Choices: 'en', 'de', 'es', 'gl' 34 | 35 | Returns 36 | ------- 37 | jokes: list 38 | """ 39 | 40 | if language not in all_jokes: 41 | raise LanguageNotFoundError('No such language %s' % language) 42 | 43 | jokes = all_jokes[language] 44 | 45 | if category not in jokes: 46 | raise CategoryNotFoundError('No such category %s in language %s' % (category, language)) 47 | 48 | return jokes[category] 49 | 50 | 51 | def get_joke(language='en', category='neutral'): 52 | """ 53 | Parameters 54 | ---------- 55 | category: str 56 | Choices: 'neutral', 'adult', 'chuck', 'all' 57 | lang: str 58 | Choices: 'en', 'de', 'es', 'gl' 59 | 60 | Returns 61 | ------- 62 | joke: str 63 | """ 64 | 65 | jokes = get_jokes(language, category) 66 | return random.choice(jokes) 67 | -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014- Pyjokes Society 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from setuptools import setup, find_packages 4 | from setuptools.command.test import test as TestCommand 5 | 6 | 7 | def read(fname): 8 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 9 | 10 | 11 | class PyTest(TestCommand): 12 | user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] 13 | 14 | def initialize_options(self): 15 | TestCommand.initialize_options(self) 16 | self.pytest_args = [] 17 | 18 | def finalize_options(self): 19 | TestCommand.finalize_options(self) 20 | self.test_args = [] 21 | self.test_suite = True 22 | 23 | def run_tests(self): 24 | #import here, cause outside the eggs aren't loaded 25 | import pytest 26 | errno = pytest.main(self.pytest_args) 27 | sys.exit(errno) 28 | 29 | 30 | setup( 31 | name="pyjokes", 32 | version="0.5.0", 33 | author="Pyjokes Society", 34 | description="One line jokes for programmers (jokes as a service)", 35 | license="BSD", 36 | keywords=[ 37 | "pyjokes", 38 | "jokes", 39 | ], 40 | url="https://github.com/pyjokes/pyjokes", 41 | packages=find_packages(), 42 | long_description=read('README.rst'), 43 | scripts=['scripts/pyjoke', 44 | 'scripts/pyjokes'], 45 | classifiers=[ 46 | "Development Status :: 4 - Beta", 47 | "Topic :: Utilities", 48 | "License :: OSI Approved :: BSD License", 49 | "Programming Language :: Python :: 2", 50 | "Programming Language :: Python :: 3", 51 | ], 52 | #test requirements and class specification: 53 | tests_require=['pytest'], 54 | cmdclass={ 'test' : PyTest }, 55 | ) 56 | -------------------------------------------------------------------------------- /pyjokes/jokes_gl.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | neutral = [ 4 | 'Abrese o elevador e hai un programador dentro. Preguntanlle: Sube ou baixa? O programador respondelle: - Si', 5 | 'Que lle di un bit a outro? Vemonos no bus.', 6 | 'Atracador: Os cartos ou a vida! Programador: Sintoo, son programador. Atracador: E? Programador: Non posuo nin cartos nin vida.', 7 | 'Que e un terapeuta? - 1024 gigapeutas', 8 | 'Cantos programadores fan falta para cambiar unha lampada? - Ningun, e un problema de hardware.', 9 | 'Abrese o pano, aparece un informatico e di: Que tocachedes que o pano non se cerra!', 10 | 'Falece unha persoa mentres estudaba na biblioteca. - Que estaba a estudar? - A API de Windows', 11 | 'Que lle di un GIF a un PNG? - Animate, home...', 12 | 'Que berra un informatico que se esta a afogar na praia? F1, F1!', 13 | 'So hay 10 tipos de persoas no mundo, aquelas que entenden binario e as que non', 14 | 'So hay 10 tipos de persoas no mundo, as que entenden trinario, as que non, e as que o confunden co binario.', 15 | 'Unha muller dixo o seu home: - Ve a tenda e trae unha barra de pan, e, se hai ovos, doce. Volveu con doce barras de pan.', 16 | 'Podese saber quen demonios e o General Failure? Esta tratando de ler o meu disco duro.', 17 | 'En que se diferencian Windows e un virus? En que o virus funciona, e e gratis.' 18 | ] 19 | 20 | adult = [ 21 | 'Que e unha muller obxecto? Unha instancia dunha muller con clase', 22 | '- Cantos dalmatas habia na peli? - 101. - Polo cu cha finco!', 23 | 'Atopan programador morto na ducha cun bote de champu: "enxaboar, aclarar e repetir"', 24 | 'Isto e un mainframe que lle di a un PC: "Tan pequeno e xa "computas"?"' 25 | ] 26 | 27 | jokes_gl = { 28 | 'neutral': neutral, 29 | 'adult': adult, 30 | 'all': neutral + adult, 31 | } 32 | -------------------------------------------------------------------------------- /pyjokes/jokes_es.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | neutral = [ 4 | #'Se abre el ascensor y hay un programador dentro, le preguntan: - Sube o baja? A lo que el programador responde: - Si.', 5 | 'Se abre el ascensor y hay un programador dentro, le preguntan: - Sube o baja? A lo que el programador responde: - Si.', 6 | #'Que le dice un bit al otro? Nos vemos en el bus.', 7 | 'Que le dice un bit al otro? Nos vemos en el bus.', 8 | 'Atracador: El dinero o la vida! Programador: Lo siento, soy programador. Atracador: Y? Programador: No tengo dinero ni vida.', 9 | 'Que es un terapeuta? - 1024 Gigapeutas', 10 | 'Cuantos programadores hacen falta para cambiar una bombilla? - Ninguno, porque es un problema de hardware.', 11 | 'Se abre el telon, aparece un informatico y dice: que habeis tocado que no se cierra el telon!', 12 | '- ...fallece una persona mientras estudiaba en la biblioteca - Que estaba estudiando? - La API de Windows.', 13 | 'Que le dice un GIF a un JPG? -Animate hombre...', 14 | 'Que dice un informatico que se esta ahogando en la playa?: F1, F1!', 15 | 'Solo hay 10 tipos de personas en el mundo, las que entienden binario y las que no.', 16 | 'Solo hay 10 tipos de personas en el mundo: las que entienden trinario, las que no, y las que lo confunden con binario.', 17 | 'Una mujer dice a su marido informatico: - Ve al supermercado y trae una barra de pan, y si hay huevos, doce. Trajo doce barras de pan.', 18 | 'Quien demonios es el general Failure, y que hace intentando leer de mi disco duro?', 19 | 'En que se diferencian Windows y un virus? En que el virus funciona, y es gratis.' 20 | ] 21 | 22 | adult = [ 23 | #'Que es una mujer objeto? Un instancia de una mujer con clase', 24 | #'- Cuantos dalmatas habia en la peli? - 101. - Por el culo te la hinco!', 25 | #'Encuentran programador muerto en la ducha con un bote de champu: "enjabonar, aclarar y vuelta a empezar"', 26 | #'Esto es un mainframe que le dice a un PC: "tan pequeno y ya "computas"?' 27 | 'Que es una mujer objeto? Un instancia de una mujer con clase', 28 | '- Cuantos dalmatas habia en la peli? - 101. - Por el culo te la hinco!', 29 | 'Encuentran programador muerto en la ducha con un bote de champu: "enjabonar, aclarar y vuelta a empezar"', 30 | 'Esto es un mainframe que le dice a un PC: "tan pequeno y ya "computas"?' 31 | ] 32 | 33 | jokes_es = { 34 | 'neutral': neutral, 35 | 'adult': adult, 36 | 'all': neutral + adult, 37 | } 38 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: https://travis-ci.org/pyjokes/pyjokes.svg 2 | :target: https://travis-ci.org/pyjokes/pyjokes 3 | .. image:: https://coveralls.io/repos/pyjokes/pyjokes/badge.svg?branch=master&service=github 4 | :target: https://coveralls.io/github/pyjokes/pyjokes?branch=master 5 | 6 | ======= 7 | pyjokes 8 | ======= 9 | 10 | One line jokes for programmers (jokes as a service) 11 | 12 | Installation 13 | ============ 14 | 15 | Install the `pyjokes` module with pip. 16 | 17 | See the `documentation`_ for installation instructions. 18 | 19 | Usage 20 | ===== 21 | 22 | Once installed, simply call `pyjoke` from the command line or add it to your .bashrc file to see a joke everytime you start a terminal session. 23 | 24 | Use the `-c` flag to get jokes from a specific category. Options:: 25 | 26 | -c neutral [default] (neutral geek jokes) 27 | -c adult (adult geek jokes) 28 | -c chuck (Chuck Norris geek jokes) 29 | -c all (all jokes) 30 | 31 | You can also access the jokes in your own project by importing `pyjokes` and using the functions `get_joke` and `get_jokes` 32 | 33 | Comprehensive documentation is available at http://pyjok.es 34 | 35 | Contributors 36 | ============ 37 | 38 | Development: 39 | 40 | * `Ben Nuttall`_ 41 | * `Alex Savio`_ 42 | * `Borja Ayerdi`_ 43 | * `Oier Etxaniz`_ 44 | 45 | Jokes: 46 | 47 | * `Luke Wren`_ 48 | * `Sarah Bird`_ 49 | * `Yash Mehrotra`_ 50 | * `Marc Kirkwood`_ 51 | * `Gregory Parker`_ 52 | * `Martin O'Hanlon`_ 53 | * `Graham Markall`_ 54 | 55 | Contributing 56 | ============ 57 | 58 | * The code is licensed under the `BSD Licence`_ 59 | * The project source code is hosted on `GitHub`_ 60 | * Please use `GitHub issues`_ to submit bugs and report issues 61 | * Feel free to `contribute`_ to the code 62 | * Feel free to contribute jokes (via pull request or `proposal issue`_) 63 | * See the `contributing policy`_ on GitHub 64 | 65 | Tests 66 | ===== 67 | 68 | Install requirements (pytest) 69 | 70 | Run tests:: 71 | 72 | python setup.py test 73 | 74 | Pyjokes Society 75 | =============== 76 | 77 | This project was founded at `PySS 2014`_ and is directed by the `Pyjokes Society`_. 78 | 79 | 80 | .. _documentation: http://pyjok.es/install/ 81 | .. _http://pyjok.es: http://pyjok.es/ 82 | .. _Ben Nuttall: https://github.com/bennuttall 83 | .. _Alex Savio: https://github.com/alexsavio 84 | .. _Borja Ayerdi: https://github.com/borjaayerdi 85 | .. _Oier Etxaniz: https://github.com/oiertwo 86 | .. _Luke Wren: https://github.com/wren6991 87 | .. _Sarah Bird: https://github.com/birdsarah 88 | .. _Yash Mehrotra: https://github.com/yashmehrotra 89 | .. _Marc Kirkwood: https://github.com/trojjer 90 | .. _Gregory Parker: https://github.com/ElectronicsGeek 91 | .. _Martin O'Hanlon: https://github.com/martinohanlon 92 | .. _Graham Markall: https://github.com/gmarkall 93 | .. _BSD Licence: http://opensource.org/licenses/BSD-3-Clause 94 | .. _GitHub: https://github.com/pyjokes/pyjokes 95 | .. _GitHub Issues: https://github.com/pyjokes/pyjokes/issues 96 | .. _contribute: https://github.com/pyjokes/pyjokes/tree/master/CONTRIBUTING.md 97 | .. _proposal issue: https://github.com/pyjokes/pyjokes/issues/10 98 | .. _contributing policy: https://github.com/pyjokes/pyjokes/tree/master/CONTRIBUTING.md 99 | .. _PySS 2014: http://www.pyss.org/ 100 | .. _Pyjokes Society: http://pyjok.es/society/ 101 | -------------------------------------------------------------------------------- /pyjokes/jokes_en.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Jokes from stackoverflow - provided under CC BY-SA 3.0 5 | http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke?page=4&tab=votes#tab-top 6 | """ 7 | 8 | neutral = [ 9 | "Complaining about the lack of smoking shelters, the nicotine addicted Python programmers said there ought to be 'spaces for tabs'.", 10 | "Ubuntu users are apt to get this joke.", 11 | "Obfuscated Reality Mappers (ORMs) can be useful database tools.", 12 | "I wonder if the MPs voting on the Digital Economy Bill think that Creative Commons is a Parliamentary initiative.", 13 | "Asked to explain Unicode during an interview, Geoff went into detail about his final year university project. He was not hired.", 14 | "Triumphantly, Beth removed Python 2.7 from her server in 2020. 'Finally!' she said with glee, only to see the announcement for Python 4.4.", 15 | "An SQL query goes into a bar, walks up to two tables and asks, 'Can I join you?'", 16 | "When your hammer is C++, everything begins to look like a thumb.", 17 | "If you put a million monkeys at a million keyboards, one of them will eventually write a Java program. The rest of them will write Perl.", 18 | "To understand recursion you must first understand recursion.", 19 | "Friends don't let friends use Python 2.7", 20 | "I suggested holding a 'Python Object Oriented Programming Seminar', but the acronym was unpopular.", 21 | "'Knock, knock.' 'Who's there?' ... very long pause ... 'Java.'", 22 | "How many programmers does it take to change a light bulb? None, that's a hardware problem.", 23 | "What's the object-oriented way to become wealthy? Inheritance", 24 | "Why don't jokes work in octal? Because 7 10 11.", 25 | "How many programmers does it take to change a light bulb? None, they just make darkness a standard.", 26 | "Two bytes meet. The first byte asks, 'Are you ill?' The second byte replies, 'No, just feeling a bit off.'", 27 | "Two threads walk into a bar. The barkeeper looks up and yells, 'Hey, I want don't any conditions race like time last!'", 28 | "Old C programmers don't die, they're just cast into void.", 29 | "Eight bytes walk into a bar. The bartender asks, 'Can I get you anything?' 'Yeah,' reply the bytes. 'Make us a double.'", 30 | "Why did the programmer quit his job? Because they didn't get arrays.", 31 | "Why do Java programmers have to wear glasses? Because they don't see sharp.", 32 | "Software developers like to solve problems. If there are no problems handily available, they will create their own problems.", 33 | ".NET was named .NET so that it wouldn't show up in a Unix directory listing.", 34 | "Hardware: The part of a computer that you can kick.", 35 | "A programmer was found dead in the shower. Next to their body was a bottle of shampoo with the instructions 'Lather, Rinse and Repeat'.", 36 | "Optimist: The glass is half full. Pessimist: The glass is half empty. Programmer: The glass is twice as large as necessary.", 37 | "In C we had to code our own bugs. In C++ we can inherit them.", 38 | "How come there is not obfuscated Perl contest? Because everyone would win.", 39 | "If you play a Windows CD backwards, you'll hear satanic chanting ... worse still, if you play it forwards, it installs Windows.", 40 | "How many programmers does it take to kill a cockroach? Two: one holds, the other installs Windows on it.", 41 | "What do you call a programmer from Finland? Nerdic.", 42 | "What did the Java code say to the C code? A: You've got no class.", 43 | "Why did Microsoft name their search engine BING? Because It's Not Google.", 44 | "Pirates go 'arg!', computer pirates go 'argv!'", 45 | "Software salesmen and used-car salesmen differ in that the latter know when they are lying.", 46 | "Child: Dad, why does the sun rise in the east and set in the west? Dad: Son, it's working, don't touch", 47 | "Why do programmers confuse Halloween with Christmas? Because OCT 31 == DEC 25", 48 | "How many Prolog programmers does it take to change a lightbulb? false.", 49 | "Real programmers can write assembly code in any language", 50 | "Waiter: Would you like coffee or tea? Programmer: Yes.", 51 | "What do you get when you cross a cat and a dog? Cat dog sin theta.", 52 | "If loving you is ROM I don't wanna read write.", 53 | "A programmer walks into a foo...", 54 | "A programmer walks into a bar and orders 1.38 root beers. The bartender informs her it's a root beer float. She says 'Make it a double!'", 55 | "What is Benoit B. Mandelbrot's middle name? Benoit B. Mandelbrot.", 56 | "Why are you always smiling? That's just my... regular expression.", 57 | "ASCII stupid question, get a stupid ANSI.", 58 | "A programmer had a problem. He thought to himself, 'I know, I'll solve it with threads!'. has Now problems. two he", 59 | "Why do sin and tan work? Just cos.", 60 | "Java: Write once, run away.", 61 | "I would tell you a joke about UDP, but you would never get it.", 62 | "A QA engineer walks into a bar. Runs into a bar. Crawls into a bar. Dances into a bar. Tiptoes into a bar. Rams a bar. Jumps into a bar.", 63 | "My friend's in a band called '1023 Megabytes'... They haven't got a gig yet!", 64 | "I had a problem so I thought I'd use Java. Now I have a ProblemFactory.", 65 | "QA Engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 999999999 beers. Orders a lizard. Orders -1 beers. Orders a sfdeljknesv.", 66 | "A product manager walks into a bar, asks for drink. Bartender says no, but will consider adding later.", 67 | "How do you generate a random string? Put a first year Computer Science student in Vim and ask them to save and exit.", 68 | "I've been using Vim for a long time now, mainly because I can't figure out how to exit.", 69 | "How do you know whether a person is a Vim user? Don't worry, they'll tell you.", 70 | "Waiter: He's choking! Is anyone a doctor? Programmer: I'm a Vim user.", 71 | "3 Database Admins walked into a NoSQL bar. A little while later they walked out because they couldn't find a table.", 72 | "How to explain the movie Inception to a programmer? When you run a VM inside another VM, inside another VM ... everything runs real slow!", 73 | "What do you call a parrot that says \"Squawk! Pieces of nine! Pieces of nine!\"? A parrot-ey error.", 74 | "There are only two hard problems in Computer Science: cache invalidation, naming things and off-by-one-errors.", 75 | "There are 10 types of people: those who understand binary and those who don't", 76 | "There are 2 types of people: those who can extrapolate from incomplete data sets...", 77 | "There are II types of people: Those who understand Roman Numerals and those who don't.", 78 | "There are 10 types of people: those who understand hexadecimal and 15 others", 79 | "There are 10 types of people: those who understand binary, those who don't, and those who were expecting this joke to be in trinary.", 80 | "There are 10 types of people: those who understand trinary, those who don't, and those who have never heard of it.", 81 | "What do you call eight hobbits? A hobbyte.", 82 | "The best thing about a Boolean is even if you are wrong, you are only off by a bit.", 83 | "A good programmer is someone who always looks both ways before crossing a one-way street.", 84 | "There are two ways to write error-free programs; only the third one works.", 85 | "QAs consist of 55% water, 30% blood and 15% Jira tickets.", 86 | "Sympathy for the Devil is really just about being nice to QAs.", 87 | "How many QAs does it take to change a light bulb? They noticed that the room was dark. They don't fix problems, they find them.", 88 | "A programmer crashes a car at the bottom of a hill, a bystander asks what happened, he says \"No idea. Let's push it back up and try again\".", 89 | "What do you mean 911 is only for emergencies, I've got a merge conflict and it doesn't look good.", 90 | "Writing PHP is like peeing in the swimming pool, everyone did it, but we don't need to bring it up in public.", 91 | "Why did the QA cross the road? To ruin everyone's day.", 92 | "Number of days since I have encountered an array index error: -1", 93 | "Speed dating is useless. 5 minutes is not enough to properly explain the benefits of the Unix philosophy.", 94 | "Microsoft hold a bi-monthly internal \"productive week\" where they use Google instead of Bing.", 95 | "Schrodinger's Cat in Web Development: If I don't look at in in Internet Explorer then there's a chance it looks fine.", 96 | "Finding a good PHP developer is like looking for a needle in a haystack. Or is it a hackstack in a needle?", 97 | "Unix is user friendly. It's just very particular about who its friends are.", 98 | "A COBOL programmer makes millions with Y2K remediation and decides to get cryogenically frozen. \"The year is 9999. You know COBOL, right?\"", 99 | "The C language combines all the power of assembly language with all the ease-of-use of assembly language.", 100 | "An SEO expert walks into a bar, bars, pub, public house, Irish pub, tavern, bartender, beer, liquor, wine, alcohol, spirits...", 101 | "What does 'Emacs' stand for? 'Exclusively used by middle aged computer scientists.'", 102 | ] 103 | 104 | adult = [ 105 | "Programming is like sex: One mistake and you have to support it for the rest of your life.", 106 | "Software is like sex: It's better when it's free.", 107 | "Software is like sex: It's never REALLY free.", 108 | "There are 10 types of people: those who understand binary, and those who get laid.", 109 | "Why programmers like UNIX: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep", 110 | "If your mom was a collection class, her insert method would be public.", 111 | "Your momma's so fat that not even Dijkstra is able to find a shortest path around her.", 112 | "C++ - where your friends have access to your private members.", 113 | "The only intuitive user interface is the nipple. After that, it's all learned.", 114 | "What's the difference between software development and sex? In sex, you don't get a bonus for releasing early.", 115 | "Your momma's so fat, the recursive function calculating her mass causes a stack overflow.", 116 | ] 117 | 118 | """ 119 | Jokes from The Internet Chuck Norris DB (ICNDB) (http://www.icndb.com/) - provided under CC BY-SA 3.0 120 | http://api.icndb.com/jokes/ 121 | """ 122 | 123 | chuck = [ 124 | "When Chuck Norris throws exceptions, it's across the room.", 125 | "All arrays Chuck Norris declares are of infinite size, because Chuck Norris knows no bounds.", 126 | "Chuck Norris doesn't have disk latency because the hard drive knows to hurry the hell up, or else.", 127 | "Chuck Norris writes code that optimises itself.", 128 | "Chuck Norris can't test for equality because he has no equal.", 129 | "Chuck Norris doesn't need garbage collection because he doesn't call .Dispose(), he calls .DropKick().", 130 | "Chuck Norris's first program was kill -9.", 131 | "Chuck Norris burst the dot com bubble.", 132 | "All browsers support the hex definitions #chuck and #norris for the colours black and blue.", 133 | "MySpace isn't really your space, it's Chuck's (he just lets you use it).", 134 | "Chuck Norris can write infinitely recursive functions and have them return.", 135 | "Chuck Norris can solve the Towers of Hanoi in one move.", 136 | "The only design pattern Chuck Norris knows is the God Object Pattern.", 137 | "Chuck Norris finished World of Warcraft.", 138 | "Project managers never ask Chuck Norris for estimations.", 139 | "Chuck Norris doesn't use web standards as the web will conform to him.", 140 | "'It works on my machine' always holds true for Chuck Norris.", 141 | "Chuck Norris doesn't do Burn Down charts, he does Smack Down charts.", 142 | "Chuck Norris can delete the Recycling Bin.", 143 | "Chuck Norris's beard can type 140 words per minute.", 144 | "Chuck Norris can unit test entire applications with a single assertion, 'it works'.", 145 | "Chuck Norris doesn't bug hunt as that signifies a probability of failure, he goes bug killing.", 146 | "Chuck Norris's keyboard doesn't have a Ctrl key because nothing controls Chuck Norris.", 147 | "Chuck Norris can overflow your stack just by looking at it.", 148 | "To Chuck Norris, everything contains a vulnerability.", 149 | "Chuck Norris doesn't sudo, the shell just knows it's him and does what it's told.", 150 | "Chuck Norris doesn't need a debugger, he just stares at the code until it confesses.", 151 | "Chuck Norris can access private methods.", 152 | "Chuck Norris can instantiate an abstract class.", 153 | "Chuck Norris does not need to know about Class Factory Pattern. He can instantiate interfaces.", 154 | "The class object inherits from Chuck Norris", 155 | "For Chuck Norris, NP-Hard = O(1).", 156 | "Chuck Norris knows the last digit of Pi.", 157 | "Chuck Norris's Internet connection is faster upstream than downstream because even data has more incentive to run from him than to him.", 158 | "Chuck Norris solved the Travelling Salesman problem in O(1) time: break salesman into N pieces; kick each piece to a different city.", 159 | "No statement can catch the ChuckNorrisException.", 160 | "Chuck Norris doesn't pair program.", 161 | "Chuck Norris can write multi-threaded applications with a single thread.", 162 | "Chuck Norris doesn't need to use AJAX because pages are too afraid to postback anyways.", 163 | "Chuck Norris doesn't use reflection, reflection asks politely for his help.", 164 | "There is no Esc key on Chuck Norris' keyboard, because no one escapes Chuck Norris.", 165 | "Chuck Norris can binary search unsorted data.", 166 | "Chuck Norris doesn't needs try-catch, exceptions are too afraid to raise.", 167 | "Chuck Norris went out of an infinite loop.", 168 | "If Chuck Norris writes code with bugs, the bugs fix themselves.", 169 | "Chuck Norris hosting is 101% uptime guaranteed.", 170 | "Chuck Norris's keyboard has the Any key.", 171 | "Chuck Norris can access the database from the UI.", 172 | "Chuck Norris's programs never exit, they are terminated.", 173 | "Chuck Norris insists on strongly-typed programming languages.", 174 | "The Chuck Norris protocol design method has no status, requests or responses, only commands.", 175 | "Chuck Norris's programs occupy 150% of CPU, even when they are not running.", 176 | "Chuck Norris can spawn threads that complete before they are started.", 177 | "Chuck Norris's programs do not accept input.", 178 | "Chuck Norris can install iTunes without installing Quicktime.", 179 | "Chuck Norris doesn't need an OS.", 180 | "Chuck Norris's OSI network model has only one layer - Physical.", 181 | "Chuck Norris can compile syntax errors.", 182 | "Every SQL statement that Chuck Norris codes has an implicit 'COMMIT' in its end.", 183 | "Chuck Norris does not need to type-cast. The Chuck-Norris Compiler (CNC) sees through things. All the way down. Always.", 184 | "Chuck Norris does not code in cycles, he codes in strikes.", 185 | "Chuck Norris compresses his files by doing a flying round house kick to the hard drive.", 186 | "Chick Norris solved the halting problem.", 187 | "With Chuck Norris P = NP. There's no nondeterminism with Chuck Norris decisions.", 188 | "Chuck Norris can retrieve anything from /dev/null.", 189 | "No one has ever pair-programmed with Chuck Norris and lived to tell the tale.", 190 | "No one has ever spoken during review of Chuck Norris' code and lived to tell the tale.", 191 | "Chuck Norris doesn't use a GUI, he prefers COMMAND line.", 192 | "Chuck Norris doesn't use Oracle, he is the Oracle.", 193 | "Chuck Norris can dereference NULL.", 194 | "A diff between your code and Chuck Norris's is infinite.", 195 | "The Chuck Norris Eclipse plugin made alien contact.", 196 | "Chuck Norris is the ultimate mutex, all threads fear him.", 197 | "Don't worry about tests, Chuck Norris's test cases cover your code too.", 198 | "Each hair in Chuck Norris's beard contributes to make the world's largest DDOS.", 199 | "Chuck Norris's log statements are always at the FATAL level.", 200 | "Chuck Norris's database has only one table, 'Kick', which he drops frequently.", 201 | "Chuck Norris completed World of Warcraft.", 202 | "When Chuck Norris breaks the build, you can't fix it, because there is not a single line of code left.", 203 | "Chuck Norris types with one finger. He points it at the keyboard and the keyboard does the rest.", 204 | "Chuck Norris's programs can pass the Turing Test by staring at the interrogator.", 205 | "If you try to kill -9 Chuck Norris's programs, it backfires.", 206 | "Chuck Norris performs infinite loops in under 4 seconds.", 207 | "Chuck Norris can overwrite a locked variable.", 208 | "Chuck Norris knows the value of NULL, and he can sort by it too.", 209 | "Chuck Norris can install a 64-bit operating system on 32-bit machines.", 210 | "Chuck Norris can write to an output stream.", 211 | "Chuck Norris can read from an input stream.", 212 | "Chuck Norris never has to build his program to machine code. Machines have learnt to interpret Chuck Norris's code.", 213 | "Chuck Norris's unit tests don't run. They die.", 214 | "Chuck Norris causes the Blue Screen of Death.", 215 | "Chuck Norris can make a class that is both abstract and final.", 216 | "Chuck Norris could use anything in java.util.* to kill you, including the javadocs.", 217 | "Code runs faster when Chuck Norris watches it.", 218 | "Chuck Norris doesn't use REST, he waits.", 219 | "Everyone likes Chuck Norris on Facebook, whether they choose to or not", 220 | "You can't follow Chuck Norris on Twitter, because he follows you", 221 | "Chuck Norris's calculator has only 3 keys: 0, 1, and NAND.", 222 | "Chuck Norris only uses global variables. He has nothing to hide.", 223 | "Chuck Norris once implemented an HTTP server in a single printf call. It is now the heart of Apache webserver.", 224 | "Chuck Norris writes directly in binary. He then writes the source code as documentation for other programmers.", 225 | "Chuck Norris once shifted a bit so hard, it ended up on a different computer.", 226 | "Q: What is Chuck Norris's favorite javascript framework? A: Knockout.js", 227 | ] 228 | 229 | from random import choice 230 | 231 | p1 = ["why did the", "would a", "can you make a", "ever seen a"] 232 | p2 = ["pope", "german", "java programmer", "chicken", "pyjoke", "bear", "$ANIMAL", "country", "american", "englishman", "irishman", "scotsman", "welshman", "$NATIONALITY", "barman", "code monkey", "python programmer"] 233 | p3 = ["eat cheese?", "cross the road?", "tell a bad joke?", "say sorry?", "go to a bar?", "EOL?", "get muddy?", "tell a good joke?", "get really clean?", "code the road?", "learn assembly?", "play pong?"] 234 | p4 = ["to get to the other side", "sex", "german sex", "yes", "PARSE ERROR", "germans.", "for the interview", "no"] 235 | 236 | def autojoke(): 237 | return "%s %s %s %s" % (choice(p1), choice(p2), choice(p3), choice(p4)) 238 | 239 | def auto_joke_list(count=1): 240 | return [autojoke() for x in range(count)] 241 | 242 | auto = auto_joke_list(100) 243 | 244 | 245 | jokes_en = { 246 | 'neutral': neutral, 247 | 'adult': adult, 248 | 'chuck': chuck, 249 | 'auto': auto, 250 | 'all': neutral + adult + chuck + auto, 251 | } 252 | --------------------------------------------------------------------------------