forked from erkin/ponysay
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
29 additions
and
30 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
ricksay/ponies/sprites/downloader.py → ricksay/ponies/sprites/downloader
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
import os, sys | ||
import argparse | ||
import click | ||
import os | ||
import random | ||
import sys | ||
|
||
import ricksay | ||
|
||
DIR = ricksay.__path__[0] | ||
|
||
if __name__ == "__main__": | ||
# parse options (for now only two) | ||
parser = argparse.ArgumentParser( | ||
description="Rick & Morty quotes of the day with ponies included!") | ||
parser.add_argument('-r', action="store_const", dest="character", | ||
const="Rick", help="Rick's quote (default)") | ||
parser.add_argument('-m', action="store_const", dest="character", | ||
const="Morty", help="Morty's quote") | ||
parser.set_defaults(character="Rick") | ||
parser.add_argument('-f', action="store", dest="ponyfile", | ||
required=False, help="Character ponyfile, default random") | ||
args = parser.parse_args() | ||
|
||
# if -f specified use given ponyfile, else get random | ||
ponies_dir = os.path.join(DIR, 'ponies', args.character) | ||
if args.ponyfile: | ||
ponyfile = os.path.join(ponies_dir, args.ponyfile) | ||
@click.command() | ||
@click.option('--char', '-c', default='Rick', help='Name of character (Rick, Morty, Beth, Jerry, Summer).') | ||
@click.option('--file', '-f', required=False, help='Ponyfile to use, file path.') | ||
def ricksay(char, file): | ||
# if -f specified use given file, else get random | ||
ponies_dir = os.path.join(DIR, "ponies", char) | ||
if file: | ||
file = os.path.join(ponies_dir, file) | ||
else: | ||
ponyfile = random.choice([os.path.join(ponies_dir,f) | ||
for f in os.listdir(ponies_dir)]) | ||
file = random.choice( | ||
[os.path.join(ponies_dir, f) for f in os.listdir(ponies_dir)] | ||
) | ||
|
||
# if it's piped text use it, else get random quote | ||
if not sys.stdin.isatty(): | ||
quote = sys.stdin.read() | ||
else: | ||
quotes_dir = os.path.join(DIR, 'quotes', args.character) | ||
random_quote_file = random.choice([os.path.join(quotes_dir, f) | ||
for f in os.listdir(quotes_dir)]) | ||
quotes_dir = os.path.join(DIR, "quotes", char) | ||
random_quote_file = random.choice( | ||
[os.path.join(quotes_dir, f) for f in os.listdir(quotes_dir)] | ||
) | ||
with open(random_quote_file) as f: | ||
quote = f.read() | ||
|
||
# run ponysay with faked args | ||
sys.argv = ['ricksay', '-f', ponyfile, '--', quote] | ||
from ricksay.main import main | ||
sys.argv = ["ricksay", "-f", file, "--", quote] | ||
from ricksay.main import main | ||
|
||
main() | ||
|
||
if __name__ == '__main__': | ||
ricksay() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,11 @@ | |
EMAIL = '[email protected]' | ||
AUTHOR = 'Roman Voropaev' | ||
REQUIRES_PYTHON = '>=3.0.0' | ||
VERSION = '0.1.0' | ||
VERSION = '0.2.0' | ||
|
||
# What packages are required for this module to be executed? | ||
REQUIRED = [ | ||
'click==6.7' | ||
] | ||
|
||
# What packages are optional? | ||
|
@@ -102,7 +103,7 @@ def run(self): | |
python_requires=REQUIRES_PYTHON, | ||
url=URL, | ||
packages=find_packages(exclude='png'), | ||
scripts=['scripts/ricksay', 'scripts/mortycry'], | ||
scripts=['scripts/ricksay'], | ||
|
||
install_requires=REQUIRED, | ||
extras_require=EXTRAS, | ||
|