class Deity(ListGenerated): template = "{title} {name}, {long_title}" providers = { 'title': ListProvider(deity.titles), 'name': ListProvider(deity.names), 'long': ListProvider(deity.long), } def __init__(self, name, title="", long=""): super().__init__(name) self.name = name self.title = title self.long = long def __str__(self): return "{deity.title} {deity.name}, {deity.long}".format(deity=self) def pray(self, prayer_type=RANDOM_PRAYER): if prayer_type == RANDOM_PRAYER: return Prayer.generate(self) if prayer_type == FORGIVE_PRAYER: return ForgivePrayer.generate(self) return AidPrayer.generate(self) @classmethod def generate(cls): next_data = {key: next(d) for key, d in cls.providers.items()} return cls(**next_data)
class HaikuString1(HaikuString): providers = [ ProvidersList(*[ListProvider(part) for part in haiku[0]]), ProvidersList(*[ListProvider(part) for part in haiku[1]]), ProvidersList(*[ListProvider(part) for part in haiku[2]]), ProvidersList(*[ListProvider(part) for part in haiku[3]]), ProvidersList(*[ListProvider(part) for part in haiku[4]]), ]
class ForgivePrayer(BasePrayer): providers = { 'sin': ListProvider(forgive.sins), 'forgive': ListProvider(forgive.forgives), 'description': ListProvider(forgive.descriptions), 'ask1': ListProvider(forgive.asks[0]), 'promise1': ListProvider(forgive.promises[0]), 'ask2': ListProvider(forgive.asks[1]), 'promise2': ListProvider(forgive.promises[1]), } def __init__(self, deity, sin="", forgive="", description="", ask1="", promise1="", ask2="", promise2=""): super().__init__(sin) self.deity = deity self.sin = sin self.forgive = forgive self.sin_description = description self.ask1 = ask1 self.promise1 = promise1 self.ask2 = ask2 self.promise2 = promise2 def __str__(self): return ("{deity}, {prayer.sin}. {prayer.forgive}, {prayer.sin_description}. " "{prayer.ask1}, {prayer.promise1}. {prayer.ask2} so I {prayer.promise2}.").format( deity=str(self.deity), prayer=self )
class AidPrayer(BasePrayer): providers = { 'ask1': ListProvider(aid.asks[0]), 'ask2': ListProvider(aid.asks[1]), 'may': ListProvider(aid.mays), 'subject': ListProvider(aid.subjects), 'ask3': ListProvider(aid.asks[2]), 'asker': ListProvider(aid.askers), 'title': ListProvider(aid.titles), 'bless': ListProvider(aid.blesses), 'bless_description': ListProvider(aid.descriptions), 'bless_subject': ListProvider(aid.bless_subjects), } def __init__(self, deity, ask1="", ask2="", ask3="", may="", subject="", asker="", title="", bless="", bless_description="", bless_subject=""): super().__init__(subject) self.deity = deity self.ask1 = ask1 self.ask2 = ask2 self.ask3 = ask3 self.may = may self.subject = subject self.asker = asker self.title = title self.bless = bless self.bless_description = bless_description self.bless_subject = bless_subject def __str__(self): return ("{prayer.deity}, {prayer.ask1}. {prayer.ask2} so I {prayer.may} {prayer.subject}. " "I {prayer.ask3} this of you {prayer.asker}, o {prayer.title}. " "{prayer.bless} me with your {prayer.bless_description} {prayer.bless_subject}.").format( deity=str(self.deity), prayer=self, )
class Riddle(ListGenerated): provider = ListProvider(riddle) def __init__(self, args): question, answer = args super().__init__(question) self.question = question self.answer = answer def __str__(self): return self.question def __repr__(self): return "Question: {}\nAnswer: {}\n".format(self.question, self.answer)
class StoryConceptEvent(BaseConcept): provider = ProvidersList(*[ListProvider(provider) for provider in events])
class StoryConceptCharacter(BaseConcept): provider = ProvidersList( *[ListProvider(provider) for provider in characters])
class Curse(Generated): provider = ListProvider(swears)
class Toponym2(BaseToponym): providers = single_letter_provider + ListProvider(endings[1])
from genesys.generator import Generated, ComplexGenerated from genesys.generator import ListProvider from fixtures.other import vowel_sounds, consonants, double_vowel_sounds, double_consonants from fixtures.other import endings single_letter_provider = ListProvider(consonants) + ListProvider( vowel_sounds) + ListProvider(double_consonants) double_letter_provider = ListProvider(double_consonants) + ListProvider( double_vowel_sounds + vowel_sounds) class BaseToponym(Generated): providers = None def __init__(self, part1="", part2="", part3="", end=""): super().__init__("".join([part1, part2, part3, end]).capitalize()) @classmethod def generate(cls): if not cls.providers: return cls() next_data = next(cls.providers.items) return cls(*next_data) class Toponym1(BaseToponym): providers = single_letter_provider + ListProvider(endings[2]) class Toponym2(BaseToponym):
class Motto(Generated): provider = ListProvider(mottos)
class BattleCry(Generated): provider = ListProvider(battlecry) def __str__(self): return "{}!".format(self.value)
class BirthdayWish(Generated): provider = ListProvider(birthday_wish)
class ReligiousCommandment(Generated): provider = ListProvider(commandment) def __str__(self): return "You shall {}".format(self.value)
class SchoolSubject(Generated): provider = ListProvider(school_subjects)
class Slogan(Generated): provider = ListProvider(slogans)
class Toponym3(BaseToponym): providers = double_letter_provider + ListProvider(endings[0])
class HaikuString2(HaikuString): providers = [ ProvidersList(*[ListProvider(part) for part in haiku_middle[0]]), ProvidersList(*[ListProvider(part) for part in haiku_middle[1]]), ]
class Toponym4(BaseToponym): providers = ListProvider(vowel_sounds) + ListProvider( double_consonants) + ListProvider(endings[1])
class CharacterGoal(Generated): provider = ListProvider(motivation)
class Toponym5(BaseToponym): providers = double_letter_provider + ListProvider( consonants) + ListProvider(endings[2])
class ArtConceptPlace(BaseConcept): provider = ProvidersList(*[ListProvider(provider) for provider in places])
class ArtConceptBeing(BaseConcept): provider = ProvidersList(*[ListProvider(provider) for provider in beings])
class WisdomQuote(Generated): provider = ListProvider(wisdom)
class Idiom(Generated): provider = ListProvider(idiom)