dribbling
11 |snivelling
12 |braindead
13 |tentacled
14 |three eyed
15 |one dimensional
16 |borg loving
17 |slime sucking
18 |borg sniffing
19 |bug eyed
20 |single celled
21 |scruffy looking
22 | 23 | 24 |son of a
25 |clone of a
26 |excuse for a
27 |hologram of a
28 |apology for a
29 |pimp for a
30 | 31 | 32 |mutant
33 |parasitic
34 |vat-grown
35 |Ferengi
36 |radiation damaged
37 |deranged
38 |space sick
39 |warp sick
40 |deviant
41 |clockwork
42 | 43 | 44 |star goat
45 |space weevil
46 |toilet cleaning droid
47 |bilge spore
48 |nose worm
49 |hyper slug
50 |replicant
51 |android
52 |garbage droid
53 |cyborg
54 |pleasure droid
55 |nerf herder
56 | 57 | 58 | 59 |artless
60 |bawdy
61 |beslubbering
62 |bootless
63 |churlish
64 |cockered
65 |clouted
66 |craven
67 |currish
68 |dankish
69 |dissembling
70 |droning
71 |errant
72 |fawning
73 |fobbing
74 |froward
75 |frothy
76 |gleeking
77 |goatish
78 |gorbellied
79 |impertinent
80 |infectious
81 |jarring
82 |loggerheaded
83 |lumpish
84 |mammering
85 |mangled
86 |mewling
87 |paunchy
88 |pribbling
89 |puking
90 |puny
91 |qualling
92 |rank
93 |reeky
94 |roguish
95 |ruttish
96 |saucy
97 |spleeny
98 |spongy
99 |surly
100 |tottering
101 |unmuzzled
102 |vain
103 |venomed
104 |villainous
105 |warped
106 |wayward
107 |weedy
108 |yeasty
109 | 110 | 111 |base-court
112 |bat-fowling
113 |beef-witted
114 |beetle-headed
115 |boil-brained
116 |clapper-clawed
117 |clay-brained
118 |common-kissing
119 |crook-pated
120 |dismal-dreaming
121 |dizzy-eyed
122 |doghearted
123 |dread-bolted
124 |earth-vexing
125 |elf-skinned
126 |fat-kidneyed
127 |fen-sucked
128 |flap-mouthed
129 |fly-bitten
130 |folly-fallen
131 |fool-born
132 |full-gorged
133 |guts-griping
134 |half-faced
135 |hasty-witted
136 |hedge-born
137 |hell-hated
138 |idle-headed
139 |ill-breeding
140 |ill-nurtured
141 |knotty-pated
142 |milk-livered
143 |motley-minded
144 |onion-eyed
145 |plume-plucked
146 |pottle-deep
147 |pox-marked
148 |reeling-ripe
149 |rough-hewn
150 |rude-growing
151 |rump-fed
152 |shard-borne
153 |sheep-biting
154 |spur-galled
155 |swag-bellied
156 |tardy-gaited
157 |tickle-brained
158 |toad-spotted
159 |unchin-snouted
160 |weather-bitten
161 | 162 | 163 |apple-john
164 |baggage
165 |barnacle
166 |bladder
167 |boar-pig
168 |bugbear
169 |bum-bailey
170 |canker-blossom
171 |clack-dish
172 |clotpole
173 |coxcomb
174 |codpiece
175 |death-token
176 |dewberry
177 |flap-dragon
178 |flax-wench
179 |flirt-gill
180 |foot-licker
181 |fustilarian
182 |giglet
183 |gudgeon
184 |haggard
185 |harpy
186 |hedge-pig
187 |horn-beast
188 |hugger-mugger
189 |joithead
190 |lewdster
191 |lout
192 |maggot-pie
193 |malt-worm
194 |mammet
195 |measle
196 |minnow
197 |miscreant
198 |moldwarp
199 |mumble-news
200 |nut-hook
201 |pigeon-egg
202 |pignut
203 |puttock
204 |pumpion
205 |ratsbane
206 |scut
207 |skainsmate
208 |strumpet
209 |varlot
210 |vassal
211 |whey-face
212 |wagtail
213 | 214 | 215 | 216 | 217 |back stabbing
218 |bawdy
219 |beer-bellied
220 |bone-headed
221 |conniving
222 |cross eyed
223 |disagreeable
224 |knock-kneed
225 |lily-livered
226 |lard eatin
227 |lop-jawed
228 |pea-brained
229 |pot-bellied
230 |whimpy
231 | 232 | 233 |aggravatin
234 |awkward
235 |back-woods
236 |high falutin
237 |impertinent
238 |illiterate
239 |low down
240 |mealy-mouthed
241 |shiftless
242 |smart-mouth
243 |worthless
244 | 245 | 246 |bean pole
247 |boob
248 |brat
249 |buzzard bait
250 |cracker
251 |clod hopper
252 |dufus
253 |hick
254 |jerk
255 |moron
256 |mule
257 |nimrod
258 |plow boy
259 |pole cat
260 |red neck
261 |rip snorter
262 |river rat
263 |sap sucker
264 |skunk
265 |slop wallower
266 |swamp momma
267 |trailer bum
268 | 269 | 270 | 271 |ignorant
272 |selfish
273 |self-absorbed
274 |prejudiced
275 |stupid
276 |inhuman
277 |unfeeling
278 |amoral
279 |craven
280 |close-minded
281 |elitist
282 |self-rightous
283 |loud-mouth
284 |bigoted
285 | 286 | 287 |blind-to-reality
288 |money-grubbing
289 |Gingrich-suckling
290 |holier-than-thou
291 |party-line
292 |thick-skulled
293 |upper-class
294 |flapping-mouthed
295 |flag-worshipping
296 |school-prayer-supporting
297 |anti-choice
298 |cash-worshipping
299 |obstructing
300 |bible-thumping
301 |militaristic
302 |selfish
303 | 304 | 305 |moron
306 |ditto-head
307 |elephant-lover
308 |pork-barrel
309 |automaton
310 |oppressor
311 |animal-hater
312 |industrialist
313 |bourgoisie
314 |redneck
315 |dipshit
316 |forest-cutter
317 |Limbaugh-lover
318 |fascist
319 |bonehead
320 |muckraker
321 |retroeconomist
322 | 323 | 324 | 325 | 326 |You
You
You
You
Differences: | %i |
Total delta: | %i |
Max delta: | %i |
Mean: | %.4f |
Stdev: | %.4f |
sets
199 | a flag to capitalize the first letter of the next word. If
200 | that flag is set, we capitalize the text and reset the flag.
201 | """
202 | text = node.data
203 | if self.capitalizeNextWord:
204 | self.pieces.append(text[0].upper())
205 | self.pieces.append(text[1:])
206 | self.capitalizeNextWord = 0
207 | else:
208 | self.pieces.append(text)
209 |
210 | def parse_Element(self, node):
211 | """parse an element
212 |
213 | An XML element corresponds to an actual tag in the source:
214 | , tag
242 |
243 | The tag is the core of the grammar. It can contain almost
244 | anything: freeform text, tags. If a "class='sentence'" attribute is found, a flag
246 | is set and the next word will be capitalized. If a "chance='X'"
247 | attribute is found, there is an X% chance that the tag will be
248 | evaluated (and therefore a (100-X)% chance that it will be
249 | completely ignored)
250 | """
251 | keys = node.attributes.keys()
252 | if "class" in keys:
253 | if node.attributes["class"].value == "sentence":
254 | self.capitalizeNextWord = 1
255 | if "chance" in keys:
256 | chance = int(node.attributes["chance"].value)
257 | doit = (chance > random.randrange(100))
258 | else:
259 | doit = 1
260 | if doit:
261 | for child in node.childNodes: self.parse(child)
262 |
263 | def do_choice(self, node):
264 | """handle tags. One tag
267 | is chosen at random and evaluated; the rest are ignored.
268 | """
269 | self.parse(self.randomChildElement(node))
270 |
271 | def usage():
272 | print __doc__
273 |
274 | def main(argv):
275 | grammar = "kant.xml"
276 | try:
277 | opts, args = getopt.getopt(argv, "hg:d", ["help", "grammar="])
278 | except getopt.GetoptError:
279 | usage()
280 | sys.exit(2)
281 | for opt, arg in opts:
282 | if opt in ("-h", "--help"):
283 | usage()
284 | sys.exit()
285 | elif opt == '-d':
286 | global _debug
287 | _debug = 1
288 | elif opt in ("-g", "--grammar"):
289 | grammar = arg
290 |
291 | source = "".join(args)
292 | k = KantGenerator(grammar, source)
293 | print k.output()
294 |
295 | if __name__ == "__main__":
296 | main(sys.argv[1:])
297 |
--------------------------------------------------------------------------------
/nodebox/util/ottobot.py:
--------------------------------------------------------------------------------
1 | from AppKit import NSFontManager
2 |
3 | from nodebox.util import random, choice
4 |
5 | COMP_WIDTH = 500
6 | COMP_HEIGHT = 500
7 |
8 | XCOORD = 1
9 | YCOORD = 2
10 | XSIZE = 3
11 | YSIZE = 4
12 | ROTATION = 5
13 | SCALE = 6
14 | CONTROLPOINT = 7
15 | COLOR = 8
16 | STROKEWIDTH = 9
17 | LOOP = 10
18 | GRIDDELTA = 12
19 | GRIDCOUNT = 13
20 | GRIDWIDTH = 14
21 | GRIDHEIGHT = 15
22 | SKEW = 16
23 | STARPOINTS = 17
24 |
25 | class Context:
26 | def __init__(self):
27 | self._indent = 0
28 | self._grid = False
29 |
30 | def indent(self):
31 | self._indent += 1
32 |
33 | def dedent(self):
34 | self._indent -= 1
35 |
36 | def spaces(self):
37 | return " " * self._indent
38 |
39 | def inGrid(self):
40 | return self._grid
41 |
42 | def nrReally(ctx, numberclass):
43 | if numberclass == XCOORD:
44 | if ctx.inGrid():
45 | #return "x"
46 | return "x + %s" % nr(ctx,GRIDDELTA)
47 | else:
48 | return random(-COMP_WIDTH/2,COMP_WIDTH/2)
49 | elif numberclass == YCOORD:
50 | if ctx.inGrid():
51 | #return "y"
52 | return "y + %s" % nr(ctx,GRIDDELTA)
53 | else:
54 | return random(-COMP_HEIGHT/2,COMP_HEIGHT/2)
55 | elif numberclass == XSIZE:
56 | return random(0,COMP_WIDTH)
57 | elif numberclass == YSIZE:
58 | return random(0,COMP_HEIGHT)
59 | elif numberclass == ROTATION:
60 | return random(0,360)
61 | elif numberclass == SCALE:
62 | return random(0.5,1.5)
63 | elif numberclass == CONTROLPOINT:
64 | return random(-100,100)
65 | elif numberclass == COLOR:
66 | return random()
67 | elif numberclass == STROKEWIDTH:
68 | return random(1,20)
69 | elif numberclass == LOOP:
70 | return random(2, 20)
71 | elif numberclass == GRIDDELTA:
72 | return random(-100,100)
73 | elif numberclass == GRIDCOUNT:
74 | return random(2, 10)
75 | elif numberclass == GRIDWIDTH:
76 | return 20
77 | return random(1,100)
78 | elif numberclass == GRIDHEIGHT:
79 | return 20
80 | return random(1, 100)
81 | elif numberclass == SKEW:
82 | return random(1,80)
83 | elif numberclass == STARPOINTS:
84 | return random(2,100)
85 |
86 | def nr(ctx, numberclass):
87 | if not ctx.inGrid() and random() > 0.5:
88 | return "random(%s)" % nrReally(ctx, numberclass)
89 | else:
90 | return "%s" % nrReally(ctx, numberclass)
91 |
92 | ### DRAWING COMMANDS ###
93 |
94 | def genDraw(ctx):
95 | fn = choice((genRect,genOval,genArrow,genStar,genPath))
96 | return fn(ctx)
97 |
98 | def genRect(ctx):
99 | return ctx.spaces() + """rect(%s,%s,%s,%s)\n""" % (
100 | nr(ctx,XCOORD),nr(ctx,YCOORD),nr(ctx,XSIZE),nr(ctx,YSIZE))
101 |
102 | def genOval(ctx):
103 | return ctx.spaces() + """oval(%s,%s,%s,%s)\n""" % (
104 | nr(ctx,XCOORD),nr(ctx,YCOORD),nr(ctx,XSIZE),nr(ctx,YSIZE))
105 |
106 | def genArrow(ctx):
107 | return ctx.spaces() + """arrow(%s,%s,%s)\n""" % (
108 | nr(ctx,XCOORD),nr(ctx,YCOORD),nr(ctx,XSIZE))
109 |
110 | def genStar(ctx):
111 | return ctx.spaces() + """star(%s,%s,%s,%s,%s)\n""" % (
112 | nr(ctx,XCOORD),nr(ctx,YCOORD),nr(ctx,STARPOINTS),nr(ctx,XSIZE),nr(ctx,XSIZE))
113 |
114 | def genPath(ctx):
115 | s = ctx.spaces() + """beginpath(%s,%s)\n""" % (
116 | nr(ctx,XCOORD),nr(ctx,YCOORD))
117 | for i in range(random(1,10)):
118 | s += genPathDraw(ctx)
119 | s += ctx.spaces() + """endpath()\n"""
120 | return s
121 |
122 | def genPathDraw(ctx):
123 | fn = choice((genLineto, genCurveto))
124 | return fn(ctx)
125 |
126 | def genLineto(ctx):
127 | return ctx.spaces() + """lineto(%s,%s)\n""" % (nr(ctx,XCOORD),nr(ctx,YCOORD))
128 |
129 | def genCurveto(ctx):
130 | return ctx.spaces() + """curveto(%s,%s,%s,%s,%s,%s)\n""" % (
131 | nr(ctx,XCOORD),nr(ctx,YCOORD),nr(ctx,CONTROLPOINT),nr(ctx,CONTROLPOINT),nr(ctx,CONTROLPOINT),nr(ctx,CONTROLPOINT))
132 |
133 | ### TRANSFORM ###
134 |
135 | def genTransform(ctx):
136 | fn = choice((genRotate, genTranslate, genScale, genSkew, genReset))
137 | return fn(ctx)
138 |
139 | def genRotate(ctx):
140 | return ctx.spaces() + """rotate(%s)\n""" % nr(ctx,ROTATION)
141 |
142 | def genTranslate(ctx):
143 | return ctx.spaces() + """translate(%s,%s)\n""" % (nr(ctx,XCOORD), nr(ctx,YCOORD))
144 |
145 | def genScale(ctx):
146 | return ctx.spaces() + """scale(%s)\n""" % (nr(ctx,SCALE))
147 |
148 | def genSkew(ctx):
149 | return ctx.spaces() + """skew(%s)\n""" % (nr(ctx,SKEW))
150 |
151 | def genReset(ctx):
152 | return ctx.spaces() + """reset()\n"""
153 |
154 | ### COLOR ###
155 |
156 | def genColor(ctx):
157 | fn = choice((genFill,genFill,genFill,genFill,genFill,genFill,genStroke,genStroke,genStroke,genNofill,genNostroke,genStrokewidth))
158 | return fn(ctx)
159 |
160 | def genFill(ctx):
161 | return ctx.spaces() + """fill(%s,%s,%s,%s)\n""" % (nr(ctx,COLOR),nr(ctx,COLOR), nr(ctx,COLOR), nr(ctx,COLOR))
162 |
163 | def genStroke(ctx):
164 | return ctx.spaces() + """stroke(%s,%s,%s,%s)\n""" % (nr(ctx,COLOR), nr(ctx,COLOR), nr(ctx,COLOR), nr(ctx,COLOR))
165 |
166 | def genNofill(ctx):
167 | return ctx.spaces() + """nofill()\n"""
168 |
169 | def genNostroke(ctx):
170 | return ctx.spaces() + """nostroke()\n"""
171 |
172 | def genStrokewidth(ctx):
173 | return ctx.spaces() + """strokewidth(%s)\n""" % nr(ctx,STROKEWIDTH)
174 |
175 | ### LOOP ###
176 | def genLoop(ctx):
177 | fn = choice((genFor, genGrid))
178 | return fn(ctx)
179 |
180 | def genFor(ctx):
181 | if ctx._indent >= 2: return ""
182 | s = ctx.spaces() + """for i in range(%s):\n""" % nr(ctx,LOOP)
183 | ctx.indent()
184 | for i in range(random(5)):
185 | s += genStatement(ctx)
186 | s += genVisual(ctx)
187 | ctx.dedent()
188 | return s
189 |
190 | def genGrid(ctx):
191 | if ctx.inGrid(): return ""
192 | s = ctx.spaces() + """for x, y in grid(%s,%s,%s,%s):\n""" % (nr(ctx,GRIDCOUNT), nr(ctx,GRIDCOUNT), nr(ctx,GRIDWIDTH), nr(ctx,GRIDHEIGHT))
193 | ctx.indent()
194 | ctx._grid = True
195 | for i in range(random(5)):
196 | s += genStatement(ctx)
197 | s += genVisual(ctx)
198 | ctx.dedent()
199 | ctx._grid = False
200 | return s
201 |
202 | ### MAIN ###
203 |
204 | def genVisual(ctx):
205 | fn = choice((genDraw,))
206 | return fn(ctx)
207 |
208 | def genStatement(ctx):
209 | fn = choice((genVisual,genLoop,genColor,genTransform))
210 | return fn(ctx)
211 |
212 | def genProgram():
213 | s = """# This code is generated with OTTOBOT,
214 | # the automatic NodeBox code generator.
215 | size(%s, %s)
216 | translate(%s, %s)
217 | colormode(HSB)
218 | """ % (COMP_WIDTH, COMP_HEIGHT, COMP_WIDTH/2, COMP_HEIGHT/2)
219 | ctx = Context()
220 | for i in range(random(10,20)):
221 | s += genStatement(ctx)
222 | return s
223 |
224 | if __name__ == '__main__':
225 | print genProgram()
--------------------------------------------------------------------------------
/nodebox/util/vdiff.py:
--------------------------------------------------------------------------------
1 | import os
2 | import Image
3 |
4 | HTML_HEADER = r'''
5 |
6 | vdiff tests
25 | '''
26 |
27 | HTML_FOOTER = r'''
28 |
29 |