From 904630a31d9262895fb5cdbe70873bcf23b768e6 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 13 Feb 2014 21:42:06 +1100 Subject: [PATCH] Flask webapp with dirty horoscope support. --- Readme.md | 6 +- bin/horoscope | 11 + bullshit/__init__.py | 0 bullshit/common/__init__.py | 52 +++ bullshit/horoscope/__init__.py | 2 + bullshit/horoscope/dirtywords.py | 30 ++ bullshit/horoscope/horoscope.py | 232 ++++++++++++++ wordlist.py => bullshit/horoscope/wordlist.py | 33 +- bullshit/webapp/__init__.py | 0 .../webapp/static/horoscope_bg.jpg | Bin .../webapp/templates/horoscope.html | 4 +- bullshit/webapp/webapp.py | 17 + dirtywords.py | 35 -- horoscope.py | 300 ------------------ web/json.php | 6 - 15 files changed, 382 insertions(+), 346 deletions(-) create mode 100755 bin/horoscope create mode 100644 bullshit/__init__.py create mode 100644 bullshit/common/__init__.py create mode 100644 bullshit/horoscope/__init__.py create mode 100644 bullshit/horoscope/dirtywords.py create mode 100644 bullshit/horoscope/horoscope.py rename wordlist.py => bullshit/horoscope/wordlist.py (83%) create mode 100644 bullshit/webapp/__init__.py rename web/bg.jpg => bullshit/webapp/static/horoscope_bg.jpg (100%) rename web/index.php => bullshit/webapp/templates/horoscope.html (83%) create mode 100644 bullshit/webapp/webapp.py delete mode 100644 dirtywords.py delete mode 100755 horoscope.py delete mode 100644 web/json.php diff --git a/Readme.md b/Readme.md index a168985..e76c35a 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,8 @@ -Horoscope Generator -=================== +Bullshit: Horoscope Generator +============================= Generate random horoscopes! Adjust the silliness by adding words to the word list. + +Zen Koan generator coming soon. diff --git a/bin/horoscope b/bin/horoscope new file mode 100755 index 0000000..0c5a9e7 --- /dev/null +++ b/bin/horoscope @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import argparse + +from bullshit import horoscope + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--dirty", action='store_true', help="Enable offensive horoscopes.") + args = parser.parse_args() + print(horoscope.generate(dirty=args.dirty)) diff --git a/bullshit/__init__.py b/bullshit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bullshit/common/__init__.py b/bullshit/common/__init__.py new file mode 100644 index 0000000..b9a85ef --- /dev/null +++ b/bullshit/common/__init__.py @@ -0,0 +1,52 @@ +"""Bullshit Generator, by Michael Sproul.""" + +import random + +vowels = {"a", "e", "i", "o", "u"} + +def choose_uniq(exclude, *args): + """Choose a unique random item from a variable number of lists.""" + item = choose_from(*args) + while item in exclude: + item = choose_from(*args) + return item + + +def choose_from(*args): + """Choose a random item from a variable number of lists.""" + num_words = sum([len(x) for x in args]) + + # Take the ith item from the lists + i = random.randint(0, num_words - 1) + for (j, x) in enumerate(args): + if i < len(x): + return x[i] + i -= len(x) + + +def sentence_case(sentence, exciting=False): + """Capitalise the first letter of the sentence and add a full stop.""" + sentence = sentence[0].upper() + sentence[1:] + + if sentence[-1] in {'.', '!', '?'}: + return sentence + elif exciting: + return sentence + "!" + else: + return sentence + "." + + +def ing_to_ed(word): + """Convert `ing' endings to `ed' endings.""" + if word[-3:] == "ing": + return (word[:-3] + "ed") + else: + return word + + +def an(word): + """Prefix with 'a' or 'an', as appropriate.""" + if word[0] in vowels: + return "an %s" % word + else: + return "a %s" % word diff --git a/bullshit/horoscope/__init__.py b/bullshit/horoscope/__init__.py new file mode 100644 index 0000000..4b04990 --- /dev/null +++ b/bullshit/horoscope/__init__.py @@ -0,0 +1,2 @@ +from .horoscope import generate +__all__ = ["generate"] diff --git a/bullshit/horoscope/dirtywords.py b/bullshit/horoscope/dirtywords.py new file mode 100644 index 0000000..5a06f91 --- /dev/null +++ b/bullshit/horoscope/dirtywords.py @@ -0,0 +1,30 @@ +avoid_list = [ "poor people", + "mamallian flesh", + "white people", + "black people", + "foreigners", + "oral sex", + "bullshit artists", + "cats that look like Jesus", + "anarcho-syndicalists", + "athesists", + "Christians", + "Mormons", + "hard drugs", + "bogans" +] + +strange_people = [ "a talking dog", + "a tiny horse", + "Jesus", + "Muhammad (peace be upon him)", + "God", + "Allah", + "Daniel Radcliffe", + "Obama", + "Tony Abbott", + "a sexual tiger", + "a clone of yourself", + "Alan Jones", + "Richard Dawkins" +] diff --git a/bullshit/horoscope/horoscope.py b/bullshit/horoscope/horoscope.py new file mode 100644 index 0000000..c9842ec --- /dev/null +++ b/bullshit/horoscope/horoscope.py @@ -0,0 +1,232 @@ +"""Random Horoscope Generator, by Michael Sproul.""" + +import random + +from datetime import date, timedelta + +from ..common import choose_from, choose_uniq, sentence_case, ing_to_ed, an +from .wordlist import wordlist + +def generate(dirty=False): + """Generate a three to four sentence horoscope.""" + # Pick a mood (usually positive) + mood = "good" if random.random() <= 0.8 else "bad" + + discussion_s = choose_from([relationship_s, encounter_s]) + sentences = [feeling_statement_s, cosmic_implication_s, warning_s, discussion_s] + + # Select 2 or 3 sentences + k = random.randint(2, 3) + sentences = random.sample(sentences, k) + final_text = " ".join([sentence(mood, dirty) for sentence in sentences]) + + # Optionally add a date prediction + if random.random() <= 0.5 and k == 2: + final_text += " " + date_prediction_s(mood, dirty) + + return final_text + + +def relationship_s(mood, dirty): + """Generate a sentence about a relationship.""" + if mood == "good": + verb = "strengthened" + talk = "discussion" + else: + verb = "strained" + talk = "argument" + + # Wordlists + familiar_people = wordlist("familiar_people", dirty) + conversation_topics = wordlist("conversation_topics", dirty) + + person = choose_from(familiar_people) + topic = choose_from(conversation_topics) + s = "Your relationship with %s may be %s " % (person, verb) + s += "as the result of %s about %s" % (an(talk), topic) + + return sentence_case(s) + + +def encounter_s(mood, dirty): + """Generate a few sentences about a meeting with another person.""" + # Sentence 1: The meeting + familiar_people = wordlist("familiar_people", dirty) + strange_people = wordlist("strange_people", dirty) + locations = wordlist("locations", dirty) + + person = choose_from(familiar_people, strange_people) + location = choose_from(locations) + preposition = location[0] + location = location[1] + s1 = "You may meet %s %s %s." % (person, preposition, location) + + # Sentence 2: The discussion + discussions = wordlist("neutral_discussions", dirty) + discussions += wordlist("_discussions", dirty, prefix=mood) + feeling_nouns = wordlist("_feeling_nouns", dirty, prefix=mood) + emotive_nouns = wordlist("_emotive_nouns", dirty, prefix=mood) + conversation_topics = wordlist("conversation_topics", dirty) + + discussion = choose_from(discussions) + if random.random() <= 0.5: + feeling = choose_from(feeling_nouns) + feeling = "feelings of %s" % feeling + else: + feeling = choose_from(emotive_nouns) + topic = choose_from(conversation_topics) + + s2 = "%s about %s may lead to %s." % (an(discussion), topic, feeling) + s2 = sentence_case(s2) + return "%s %s" % (s1, s2) + + +def date_prediction_s(mood, dirty): + """Generate a random prediction sentence containing a date.""" + days_in_future = random.randint(2, 8) + significant_day = date.today() + timedelta(days=days_in_future) + month = significant_day.strftime("%B") + day = significant_day.strftime("%d").lstrip('0') + + r = random.random() + + if r <= 0.5: + s = "%s %s will be an important day for you" % (month, day) + elif r <= 0.8: + s = "Interesting things await you on %s %s" % (month, day) + else: + s = "The events of %s %s have the potential to change your life." % (month, day) + + return sentence_case(s) + + +def feeling_statement_s(mood, dirty): + """Generate a sentence that asserts a mood-based feeling.""" + adjectives = wordlist("_feeling_adjs", dirty, prefix=mood) + degrees = wordlist("neutral_degrees", dirty) + wordlist("_degrees", dirty, prefix=mood) + + adj = choose_from(adjectives) + adj = ing_to_ed(adj) + degree = choose_from(degrees) + ending = positive_intensifier if mood == "good" else consolation + exciting = (mood == "good" and random.random() <= 0.5) + are = random.choice([" are", "'re"]) + s = "You%s feeling %s %s" % (are, degree, adj) + s += ending(dirty) + return sentence_case(s, exciting) + + +def positive_intensifier(dirty): + """Extend a statement of positive feelings.""" + r = random.random() + + # Increase the probability of not giving a fuck as appropriate. + dirty_factor = 2 if dirty else 1 + + if r <= (0.5/dirty_factor): + verb = random.choice(["say", "do"]) + return ", and there's nothing anyone can %s to stop you" % verb + elif r <= (0.95/dirty_factor): + return ", and you don't care who knows it" + else: + return ", and you don't give a fuck" + + +def consolation(dirty): + """Provide a consolation for feeling bad.""" + r = random.random() + + if r <= 0.6: + when = random.choice(["shortly", "soon", "in due time"]) + return ", but don't worry, everything will improve %s" % when + elif r <= 0.9: + return ", perhaps you need a change in your life?" + else: + return "..." + + +def warning_s(mood, dirty): + r = random.random() + avoid_list = wordlist("avoid_list", dirty) + bad_thing = random.choice(avoid_list) + + if r <= 0.27: + s = "You would be well advised to avoid %s" % bad_thing + elif r <= 0.54: + s = "Avoid %s at all costs" % bad_thing + elif r <= 0.81: + s = "Steer clear of %s for a stress-free week" % bad_thing + else: + also_bad = choose_uniq({bad_thing}, avoid_list) + s = "For a peaceful week, avoid %s and %s" % (bad_thing, also_bad) + + return sentence_case(s) + + +def cosmic_implication_s(mood, dirty): + """Generate a sentence about the influence of a cosmic event.""" + c_event = cosmic_event(dirty) + prediction_verbs = wordlist("prediction_verbs", dirty) + verb = choose_from(prediction_verbs) + + # Bad mood = End of good, or start of bad + # Good mood = End of bad, or start of good + r = random.random() + beginnings = wordlist("beginnings", dirty) + endings = wordlist("endings", dirty) + if mood == 'bad' and r <= 0.5: + junction = choose_from(beginnings) + e_event = emotive_event('bad', dirty) + elif mood == 'bad': + junction = choose_from(endings) + e_event = emotive_event('good', dirty) + elif mood == 'good' and r <= 0.5: + junction = choose_from(beginnings) + e_event = emotive_event('good', dirty) + else: + junction = choose_from(endings) + e_event = emotive_event('bad', dirty) + + s = "%s %s the %s of %s" % (c_event, verb, junction, e_event) + return sentence_case(s) + + +def cosmic_event(dirty): + r = random.random() + + planets = wordlist("planets", dirty) + stars = wordlist("stars", dirty) + wanky_events = wordlist("wanky_events", dirty) + aspects = wordlist("aspects", dirty) + + if r <= 0.25: + return random.choice(planets) + " in retrograde" + elif r <= 0.5: + c_event = "the " + random.choice(["waxing", "waning"]) + c_event += " of " + choose_from(planets, ["the moon"], stars) + return c_event + elif r <= 0.6: + return "the " + random.choice(["New", "Full"]) + " Moon" + elif r <= 0.75: + return random.choice(wanky_events) + else: + first = choose_from(planets, stars, ["Moon"]) + second = choose_uniq({first}, planets, stars, ["Moon"]) + return "The %s/%s %s" % (first, second, choose_from(aspects)) + + +def emotive_event(mood, dirty): + """Generate a sentence about a prolonged emotion.""" + feeling_adjs = wordlist("_feeling_adjs", dirty, prefix=mood) + emotive_adjs = wordlist("_emotive_adjs", dirty, prefix=mood) + feeling_nouns = wordlist("_feeling_nouns", dirty, prefix=mood) + emotive_nouns = wordlist("_emotive_nouns", dirty, prefix=mood) + time_periods = wordlist("time_periods", dirty) + time_period = random.choice(time_periods) + + if random.random() <= 0.5: + adj = choose_from(feeling_adjs, emotive_adjs) + return "%s %s" % (adj, time_period) + else: + noun = choose_from(feeling_nouns, emotive_nouns) + return "%s of %s" % (time_period, noun) diff --git a/wordlist.py b/bullshit/horoscope/wordlist.py similarity index 83% rename from wordlist.py rename to bullshit/horoscope/wordlist.py index 8518b16..4e8e20c 100644 --- a/wordlist.py +++ b/bullshit/horoscope/wordlist.py @@ -1,3 +1,32 @@ +import sys + +from . import dirtywords + +this_module = sys.modules[__name__] + +def _setup(): + """Create lists in this module with both "clean" & dirty words.""" + for name in dir(dirtywords): + if name[:1] == "_": + continue + + named_object = getattr(dirtywords, name) + if isinstance(named_object, list): + clean_list = getattr(this_module, name) + dirty_list = clean_list + named_object + dirty_name = "dirty_" + name + setattr(this_module, dirty_name, dirty_list) + + +def wordlist(name, dirty=False, prefix=""): + """Get a word list by name, with optional filth.""" + name = prefix + name + dirty_name = "dirty_" + name + if dirty and hasattr(this_module, dirty_name): + return getattr(this_module, dirty_name) + return getattr(this_module, name) + + # Astrological words planets = ["Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"] @@ -46,7 +75,6 @@ bad_emotive_nouns = ["bad luck", "misfortune", "déjà vu"] # Misc -vowels = {'a', 'e', 'i', 'o', 'u'} prediction_verbs = ["heralds", "marks", "foreshadows", "signifies"] # You would be well advised to avoid... @@ -163,3 +191,6 @@ "your feelings", "their work" ] + +# Run the setup function once all names have been loaded +_setup() diff --git a/bullshit/webapp/__init__.py b/bullshit/webapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/bg.jpg b/bullshit/webapp/static/horoscope_bg.jpg similarity index 100% rename from web/bg.jpg rename to bullshit/webapp/static/horoscope_bg.jpg diff --git a/web/index.php b/bullshit/webapp/templates/horoscope.html similarity index 83% rename from web/index.php rename to bullshit/webapp/templates/horoscope.html index 1c2d7b4..e540cdd 100644 --- a/web/index.php +++ b/bullshit/webapp/templates/horoscope.html @@ -8,7 +8,7 @@ html { min-width: 100%; min-height: 100%; - background-image: url('bg.jpg'); + background-image: url({{ url_for("static", filename="horoscope_bg.jpg") }}); background-size: cover; background-position: center; background-repeat: no-repeat; @@ -28,6 +28,6 @@ -

+

{{ horoscope }}

diff --git a/bullshit/webapp/webapp.py b/bullshit/webapp/webapp.py new file mode 100644 index 0000000..882e9bc --- /dev/null +++ b/bullshit/webapp/webapp.py @@ -0,0 +1,17 @@ +from bullshit import horoscope +from flask import Flask, render_template + +app = Flask(__name__) + +@app.route("/horoscope/") +def get_horoscope(): + return render_template("horoscope.html", horoscope=horoscope.generate()) + +@app.route("/horoscope/dirty/") +def get_dirty_horoscope(): + return render_template("horoscope.html", horoscope=horoscope.generate(dirty=True)) + + +if __name__ == "__main__": + app.run(debug=True) + diff --git a/dirtywords.py b/dirtywords.py deleted file mode 100644 index 1f4c56a..0000000 --- a/dirtywords.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Filth up the horoscope generator with some stupid words.""" - -import wordlist - -wordlist.avoid_list.extend([ "poor people", - "mamallian flesh", - "white people", - "black people", - "foreigners", - "oral sex", - "bullshit artists", - "cats that look like Jesus", - "anarcho-syndicalists", - "athesists", - "Christians", - "Mormons", - "hard drugs", - "bogans" -]) - -wordlist.strange_people.extend([ "a talking dog", - "a tiny horse", - "Jesus", - "Muhammad (peace be upon him)", - "God", - "Allah", - "Daniel Radcliffe", - "Obama", - "Tony Abbott", - "a sexual tiger", - "a clone of yourself", - "Alan Jones", - "Richard Dawkins" - -]) diff --git a/horoscope.py b/horoscope.py deleted file mode 100755 index 1b2736c..0000000 --- a/horoscope.py +++ /dev/null @@ -1,300 +0,0 @@ -#!/usr/bin/env python - -"""Random Horoscope Generator, by Michael Sproul.""" - -import argparse -import random - -import wordlist - -from datetime import date, timedelta -from wordlist import * - -def horoscope(): - """Generate a three to four sentence horoscope.""" - # Pick a mood (usually positive) - mood = "good" if random.random() <= 0.8 else "bad" - - discussion_s = choose_from([relationship_s, encounter_s]) - sentences = [feeling_statement_s, cosmic_implication_s, warning_s, - discussion_s] - - # Select 2 or 3 sentences - random.shuffle(sentences) - final_text = sentences[0](mood) - n = choose_from([2, 3]) - for i in range(1, n): - final_text += " " + sentences[i](mood) - - # Optionally add a date prediction - if random.random() <= 0.5 and n == 2: - final_text += " " + date_prediction_s(mood) - - return final_text - - -def relationship_s(mood): - """Generate a sentence about a relationship.""" - if mood == "good": - verb = "strengthened" - talk = "discussion" - else: - verb = "strained" - talk = "argument" - - person = choose_from(familiar_people) - topic = choose_from(conversation_topics) - s = "Your relationship with %s may be %s " % (person, verb) - s += "as the result of %s about %s" % (an(talk), topic) - - return sentence_case(s) - - -def encounter_s(mood): - """Generate a few sentences about a meeting with another person.""" - person = choose_from(familiar_people, strange_people) - location = choose_from(locations) - prep = location[0] - location = location[1] - s1 = "You may meet %s %s %s." % (person, prep, location) - - if mood == "good": - discussion = choose_from(neutral_discussions, good_discussions) - if random.random() <= 0.5: - feeling = choose_from(good_feeling_nouns) - feeling = "feelings of %s" % feeling - else: - feeling = choose_from(good_emotive_nouns) - else: - discussion = choose_from(neutral_discussions, bad_discussions) - if random.random() <= 1: - feeling = choose_from(bad_feeling_nouns) - feeling = "feelings of %s" % feeling - else: - feeling = choose_from(bad_emotive_nouns) - topic = choose_from(conversation_topics) - - s2 = "%s about %s may lead to %s." % (an(discussion), topic, feeling) - s2 = sentence_case(s2) - return "%s %s" % (s1, s2) - - -def date_prediction_s(mood): - """Generate a random prediction sentence containing a date.""" - days_in_future = random.randint(2, 8) - significant_day = date.today() + timedelta(days=days_in_future) - month = significant_day.strftime("%B") - day = significant_day.strftime("%d").lstrip('0') - - r = random.random() - - if r <= 0.5: - s = "%s %s will be an important day for you" % (month, day) - elif r <= 0.8: - s = "Interesting things await you on %s %s" % (month, day) - else: - s = "The events of %s %s have the potential to" % (month, day) - s += " change your life" - - return sentence_case(s) - - -def feeling_statement_s(mood): - """Generate a sentence that asserts a mood-based feeling.""" - if mood == 'good': - adj = choose_from(good_feeling_adjs) - degree = choose_from(good_degrees, neutral_degrees) - ending = positive_intensifier - exciting = True if random.random() <= 0.5 else False - else: - adj = choose_from(bad_feeling_adjs) - degree = choose_from(bad_degrees, neutral_degrees) - ending = consolation - exciting = False - - adj = ing_to_ed(adj) - are = choose_from([" are", "'re"]) - s = "You%s feeling %s %s" % (are, degree, adj) - s += ending() - return sentence_case(s, exciting) - - -def positive_intensifier(): - """Extend a statement of positive feelings.""" - r = random.random() - - if r <= 0.5: - verb = choose_from(["say", "do"]) - return ", and there's nothing anyone can %s to stop you" % verb - elif r <= 0.95: - return ", and you don't care who knows it" - else: - return ", and you don't give a fuck" - - -def consolation(): - """Provide consolation for feeling bad.""" - r = random.random() - - if r <= 0.6: - when = choose_from(["shortly", "soon", "in due time"]) - return ", but don't worry, everything will improve %s" % when - elif r <= 0.9: - return ", perhaps you need a change in your life?" - else: - return "..." - - -def warning_s(mood): - r = random.random() - bad_thing = choose_from(avoid_list) - - if r <= 0.27: - s = "You would be well advised to avoid %s" % bad_thing - elif r <= 0.54: - s = "Avoid %s at all costs" % bad_thing - elif r <= 0.81: - s = "Steer clear of %s for a stress-free week" % bad_thing - else: - also_bad = choose_uniq({bad_thing}, avoid_list) - s = "For a peaceful week, avoid %s and %s" % (bad_thing, also_bad) - - return sentence_case(s) - - -def cosmic_implication_s(mood): - """Generate a sentence about the influence of a cosmic event.""" - c_event = cosmic_event() - verb = choose_from(prediction_verbs) - - # Bad mood = End of good, or start of bad - # Good mood = End of bad, or start of good - r = random.random() - if mood == 'bad' and r <= 0.5: - junction = choose_from(beginnings) - e_event = emotive_event('bad') - elif mood == 'bad': - junction = choose_from(endings) - e_event = emotive_event('good') - elif mood == 'good' and r <= 0.5: - junction = choose_from(beginnings) - e_event = emotive_event('good') - else: - junction = choose_from(endings) - e_event = emotive_event('bad') - - s = "%s %s the %s of %s" % (c_event, verb, junction, e_event) - return sentence_case(s) - - -def cosmic_event(): - r = random.random() - - if r <= 0.25: - return choose_from(planets) + " in retrograde" - elif r <= 0.5: - ce = "the " + choose_from(["waxing", "waning"]) - ce += " of " + choose_from(planets, ["the moon"], stars) - return ce - elif r <= 0.6: - return "the " + choose_from(["New", "Full"]) + " Moon" - elif r <= 0.75: - return choose_from(wanky_events) - else: - first = choose_from(planets, stars, ["Moon"]) - second = choose_uniq({first}, planets, stars, ["Moon"]) - return "The %s/%s %s" % (first, second, choose_from(aspects)) - - -def emotive_event(mood): - """Generate a sentence about a prolonged emotion.""" - if mood == 'good': - adjectives_1 = good_feeling_adjs - adjectives_2 = good_emotive_adjs - nouns_1 = good_feeling_nouns - nouns_2 = good_emotive_nouns - else: - adjectives_1 = bad_feeling_adjs - adjectives_2 = bad_emotive_adjs - nouns_1 = bad_feeling_nouns - nouns_2 = bad_emotive_nouns - - if random.random() <= 0.5: - adj = choose_from(adjectives_1, adjectives_2) - return "%s %s" % (adj, choose_from(time_periods)) - else: - noun = choose_from(nouns_1, nouns_2) - return "%s of %s" % (choose_from(time_periods), noun) - - -def choose_uniq(exclude, *args): - """Choose a unique random item from a variable number of lists.""" - item = choose_from(*args) - while item in exclude: - item = choose_from(*args) - return item - -def choose_from(*args): - """Choose a random item from a variable number of lists.""" - num_words = 0 - for list in args: - num_words += len(list) - - i = random.randint(0, num_words - 1) - j = 0 - while i >= len(args[j]): - i -= len(args[j]) - j += 1 - - return args[j][i] - - -def sentence_case(sentence, exciting=False): - """Capitalise the first letter of the sentence and add a full stop.""" - sentence = sentence[0].upper() + sentence[1:] - - if sentence[-1] in {'.', '!', '?'}: - return sentence - elif exciting: - return sentence + "!" - else: - return sentence + "." - - -def opposite_mood(mood): - return 'good' if (mood == 'bad') else 'bad' - - -def ing_to_ed(word): - """Convert `ing' endings to `ed' endings.""" - if word[-3:] == "ing": - return (word[:-3] + "ed") - else: - return word - -def an(word): - """Prefix with 'a' or 'an', as appropriate.""" - if word[0] in vowels: - return "an %s" % word - else: - return "a %s" % word - -def main(): - # Parse command-line arguments - parser = argparse.ArgumentParser(description=__doc__) - - parser.add_argument("--dirty", action='store_true', - help="Enable offensive horoscopes") - - parser.add_argument("--starsign", type=str, metavar="starsign", - help="Generate a starsign specific horoscope") - - arguments = vars(parser.parse_args()) - - if arguments["dirty"]: - import dirtywords - - print(horoscope()) - -if __name__ == "__main__": - main() diff --git a/web/json.php b/web/json.php deleted file mode 100644 index 9f76b27..0000000 --- a/web/json.php +++ /dev/null @@ -1,6 +0,0 @@ -