Permalink
Browse files

add book titles, TrueOrFalse

  • Loading branch information...
1 parent 5773beb commit 4cd6d824e9df98d600e1c4499435b8877f7ca30f Simon Bächler committed Mar 28, 2013
Showing with 148 additions and 3 deletions.
  1. +9 −0 README.rst
  2. +1 −0 requirements.txt
  3. +3 −2 scaffolding/__init__.py
  4. +113 −0 scaffolding/library/booktitles.py
  5. +22 −1 scaffolding/tubes.py
View
@@ -109,6 +109,15 @@ AlwaysFalse
Returns False
+
+TrueOrFalse
+-----------
+
+Randomly returns true or false.
+You can set a ratio for true or false by specifying true or false:
+e.g. ``false=3`` returns 3 times as many False than Trues.
+
+
Contrib
-------
View
@@ -0,0 +1 @@
+flickrapi==1.4.2
View
@@ -7,14 +7,15 @@
from django.utils.importlib import import_module
from tubes import (Tube, Name, LoremIpsum, RandInt, Contrib, AlwaysTrue,
- AlwaysFalse, StaticValue, RandomValue, EveryValue, RandomInternetImage, ForeignKey,
- FirstName, LastName
+ AlwaysFalse, StaticValue, RandomValue, EveryValue, RandomInternetImage,
+ ForeignKey, FirstName, LastName, TrueOrFalse, BookTitle
)
__all__ = ['Tube', 'Name', 'LoremIpsum', 'RandInt', 'Contrib', 'AlwaysTrue',
'AlwaysFalse', 'StaticValue', 'RandomValue', 'EveryValue',
'RandomInternetImage', 'FirstName', 'LastName',
+ 'TrueOrFalse', 'BookTitle',
'ForeignKey', 'register', 'scaffold_for_model']
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+""" taken from http://mdbenoit.com/rtg.htm """
+
+import random
+
+NOUNS = (
+ "Dream","Dreamer","Dreams","Waves",
+ "Sword","Kiss","Sex","Lover",
+ "Slave","Slaves","Pleasure","Servant",
+ "Servants","Snake","Soul","Touch",
+ "Men","Women","Gift","Scent",
+ "Ice","Snow","Night","Silk","Secret","Secrets",
+ "Game","Fire","Flame","Flames",
+ "Husband","Wife","Man","Woman","Boy","Girl",
+ "Truth","Edge","Boyfriend","Girlfriend",
+ "Body","Captive","Male","Wave","Predator",
+ "Female","Healer","Trainer","Teacher",
+ "Hunter","Obsession","Hustler","Consort",
+ "Dream", "Dreamer", "Dreams","Rainbow",
+ "Dreaming","Flight","Flying","Soaring",
+ "Wings","Mist","Sky","Wind",
+ "Winter","Misty","River","Door",
+ "Gate","Cloud","Fairy","Dragon",
+ "End","Blade","Beginning","Tale",
+ "Tales","Emperor","Prince","Princess",
+ "Willow","Birch","Petals","Destiny",
+ "Theft","Thief","Legend","Prophecy",
+ "Spark","Sparks","Stream","Streams","Waves",
+ "Sword","Darkness","Swords","Silence","Kiss",
+ "Butterfly","Shadow","Ring","Rings","Emerald",
+ "Storm","Storms","Mists","World","Worlds",
+ "Alien","Lord","Lords","Ship","Ships","Star",
+ "Stars","Force","Visions","Vision","Magic",
+ "Wizards","Wizard","Heart","Heat","Twins",
+ "Twilight","Moon","Moons","Planet","Shores",
+ "Pirates","Courage","Time","Academy",
+ "School","Rose","Roses","Stone","Stones",
+ "Sorcerer","Shard","Shards","Slave","Slaves",
+ "Servant","Servants","Serpent","Serpents",
+ "Snake","Soul","Souls","Savior","Spirit",
+ "Spirits","Voyage","Voyages","Voyager","Voyagers",
+ "Return","Legacy","Birth","Healer","Healing",
+ "Year","Years","Death","Dying","Luck","Elves",
+ "Tears","Touch","Son","Sons","Child","Children",
+ "Illusion","Sliver","Destruction","Crying","Weeping",
+ "Gift","Word","Words","Thought","Thoughts","Scent",
+ "Ice","Snow","Night","Silk","Guardian","Angel",
+ "Angels","Secret","Secrets","Search","Eye","Eyes",
+ "Danger","Game","Fire","Flame","Flames","Bride",
+ "Husband","Wife","Time","Flower","Flowers",
+ "Light","Lights","Door","Doors","Window","Windows",
+ "Bridge","Bridges","Ashes","Memory","Thorn",
+ "Thorns","Name","Names","Future","Past",
+ "History","Something","Nothing","Someone",
+ "Nobody","Person","Man","Woman","Boy","Girl",
+ "Way","Mage","Witch","Witches","Lover",
+ "Tower","Valley","Abyss","Hunter",
+ "Truth","Edge"
+)
+ADJECTIVES = (
+ "Lost","Only","Last","First",
+ "Third","Sacred","Bold","Lovely",
+ "Final","Missing","Shadowy","Seventh",
+ "Dwindling","Missing","Absent",
+ "Vacant","Cold","Hot","Burning","Forgotten",
+ "Weeping","Dying","Lonely","Silent",
+ "Laughing","Whispering","Forgotten","Smooth",
+ "Silken","Rough","Frozen","Wild",
+ "Trembling","Fallen","Ragged","Broken",
+ "Cracked","Splintered","Slithering","Silky",
+ "Wet","Magnificent","Luscious","Swollen",
+ "Erect","Bare","Naked","Stripped",
+ "Captured","Stolen","Sucking","Licking",
+ "Growing","Kissing","Green","Red","Blue",
+ "Azure","Rising","Falling","Elemental",
+ "Bound","Prized","Obsessed","Unwilling",
+ "Hard","Eager","Ravaged","Sleeping",
+ "Wanton","Professional","Willing","Devoted",
+ "Misty","Lost","Only","Last","First",
+ "Final","Missing","Shadowy","Seventh",
+ "Dark","Darkest","Silver","Silvery","Living",
+ "Black","White","Hidden","Entwined","Invisible",
+ "Next","Seventh","Red","Green","Blue",
+ "Purple","Grey","Bloody","Emerald","Diamond",
+ "Frozen","Sharp","Delicious","Dangerous",
+ "Deep","Twinkling","Dwindling","Missing","Absent",
+ "Vacant","Cold","Hot","Burning","Forgotten",
+ "Some","No","All","Every","Each","Which","What",
+ "Playful","Silent","Weeping","Dying","Lonely","Silent",
+ "Laughing","Whispering","Forgotten","Smooth","Silken",
+ "Rough","Frozen","Wild","Trembling","Fallen",
+ "Ragged","Broken","Cracked","Splintered"
+)
+
+class Title(object):
+ def __iter__(self):
+ return self
+
+ def make_title(self):
+ adj = random.choice(ADJECTIVES)
+ noun = random.choice(NOUNS)
+ noun2 = random.choice(NOUNS)
+ return random.choice([
+ lambda: u"%s %s" % (adj, noun),
+ lambda: u"The %s %s" % (adj, noun),
+ lambda: u"%s of %s" % (noun, noun2),
+ lambda: u"%s's %s" % (noun, noun2),
+ lambda: u"The %s of the %s" % (noun, noun2),
+ lambda: u"%s in the %s" % (noun, noun2)
+ ])()
+
+ def next(self):
+ return self.make_title()
View
@@ -4,7 +4,7 @@
import random
import urllib
-from scaffolding.library import lorem_ipsum, names
+from scaffolding.library import lorem_ipsum
from django.core.files import File
class Tube(object):
@@ -63,6 +63,7 @@ class Name(Tube):
""" Generates a random name. <gender> can be 'male', 'female', 'm' or 'f'.
"""
def __init__(self, max_length=30, gender=None, **kwargs):
+ from scaffolding.library import names
super(Name, self).__init__(**kwargs)
self.max_length = max_length
self.first_names = names.FirstNames(gender=gender)
@@ -82,6 +83,16 @@ def next(self):
return u'%s'[:self.max_length] % self.last_names.next()
+class BookTitle(Tube):
+ def __init__(self, **kwargs):
+ from scaffolding.library import booktitles
+ super(BookTitle, self).__init__(**kwargs)
+ self.title = booktitles.Title()
+
+ def next(self):
+ return self.title.next()
+
+
class LoremIpsum(Tube):
""" Generates a Lorem Ipsum Text. The number of paragraphs is defined in paragraphs.
"""
@@ -149,6 +160,16 @@ def __init__(self):
self.value = False
+class TrueOrFalse(RandomValue):
+ """ Randomly returns true or false.
+ You can set a ratio for true or false by specifying true and false:
+ e.g. true=1, false=3 returns 3 times as many False than Trues.
+ """
+ def __init__(self, true=1, false=1):
+ self.lst = [True for i in range(true)]
+ self.lst.extend([False for i in range(false)])
+
+
class RandomInternetImage(Tube):
""" Creates a random image for an ImageField using an internet source.
"""

0 comments on commit 4cd6d82

Please sign in to comment.