Skip to content

Commit

Permalink
Total update, version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-guru committed May 6, 2020
1 parent 6d472e5 commit 56a64b3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
1 change: 1 addition & 0 deletions ricksay/ponies/sprites/downloader.py → ricksay/ponies/sprites/downloader
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
# This script parses sprites shared from Pocket Morties game
# Depends on Spriters Resource markup...

Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions scripts/mortycry

This file was deleted.

51 changes: 25 additions & 26 deletions scripts/ricksay
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()
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 56a64b3

Please sign in to comment.