1 # -*- coding: utf-8 -*-
2 # drawing hearts in the snow!
3 from odf
.opendocument
import OpenDocumentText
4 from odf
.text
import P
, Span
5 from odf
.style
import Style
, TextProperties
, ParagraphProperties
, BackgroundImage
, GraphicProperties
6 from odf
.draw
import Frame
, TextBox
11 class CharSpice(Spice
):
12 def __init__(self
, genre
, style
):
13 Spice
.__init
__(self
, genre
, style
)
17 # leaving it here because it was built for this spice
18 def kinda_p4char_spice(self
, paragraphic_style
, boldstyle
, text
, textbox
):
19 sectioned
= text
.split()
20 p
= P(text
=u
"", stylename
=paragraphic_style
)
23 for i
in range(len(sectioned
)-1):
24 if sectioned
[i
].lower() in self
.words
:
25 boldpart
= Span(stylename
=boldstyle
, text
=sectioned
[i
] + u
" ")
26 p
.addElement(boldpart
)
28 normalpart
= Span(text
=sectioned
[i
] + u
" ")
29 p
.addElement(normalpart
)
30 p
.addText(sectioned
[-1])
35 def character_text_frame(self
, odt
, spice
):
38 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
39 boldprop
= TextProperties(fontfamily
="diluvienne", fontsize
="28pt")
40 boldstyle
.addElement(boldprop
)
41 odt
.automaticstyles
.addElement(boldstyle
)
42 elif spice
== "champagne":
43 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
44 boldprop
= TextProperties(fontfamily
="Cimatics_Trash")
45 boldstyle
.addElement(boldprop
)
46 odt
.automaticstyles
.addElement(boldstyle
)
48 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
49 boldprop
= TextProperties(fontweight
="bold", fontfamily
="NotCourierSans", letterspacing
="2mm")
50 boldstyle
.addElement(boldprop
)
51 odt
.automaticstyles
.addElement(boldstyle
)
53 ### header frame (for letter)
54 if self
.genre
== "brief":
58 graphic_style
= Style(name
="Main Body Frame", family
="graphic")
59 graphic_properties
= GraphicProperties(backgroundcolor
="#ffffff", border
="10mm double #ffffff")
60 graphic_style
.addElement(graphic_properties
)
61 frame
= make_frame(odt
, graphic_style
, "240mm", "170mm", "0mm", "0mm", "1")
62 frameframe
= frame
["frame"]
63 textbox
= frame
["textbox"]
65 for paragraph
in txt
[self
.genre
]:
66 self
.kinda_p4char_spice("Body Text", boldstyle
, paragraph
, textbox
)
68 odt
.text
.addElement(frameframe
)
70 def loop_over_spices(self
):
71 for myspice
in self
.spices
:
73 myodt
= OpenDocumentText()
75 # genredotstyle... is this really the name we want?
76 genredotstyle
= self
.read_stylesheet()
77 myodt
.styles
.addElement(genredotstyle
)
80 self
.character_text_frame(myodt
, myspice
)
83 self
.label(myodt
, myspice
)
85 myname
= self
.genre
+ "/" + self
.style
+ "/character/" + self
.genre
+ "_" + self
.style
+ "_" + myspice
86 myodt
.save(myname
, True)
88 if __name__
== "__main__":
89 spices
= ["sexy", "champagne", "lungo"]
90 words
= [u
"aai", u
"aan", u
"alleen", u
"beloofde", u
"bemind", u
"benen", u
"bewust", u
"borst", u
"eenzaam", u
"elkaar", u
"geloofde", u
"gesmoord", u
"gevoel", u
"gezicht", u
"giechelend", u
"glimlachte", u
"haar", u
"hand", u
"haren", u
"hem", u
"hen", u
"herinner", u
"herinneren", u
"herinneringen", u
"hier", u
"hij", u
"hoofd", u
"hoop", u
"huilen", u
"ik", u
"ja", u
"je", u
"jij", u
"jou", u
"jouw", u
"kiezen", u
"kleurde", u
"leven", u
"liefde", u
"liefdes", u
"liefs", u
"liefste", u
"lieve", u
"lippen", u
"man", u
"me", u
"mijn", u
"moed", u
"moeilijk", u
"ogen", u
"ons", u
"ontmoeting", u
"onze", u
"opnieuw", u
"rituelen", u
"roos", u
"routine", u
"ruggen", u
"samen", u
"smoorverliefd", u
"spijt", u
"stotterde", u
"streelde", u
"tenen", u
"troost", u
"vergat", u
"vergeet", u
"vergeten", u
"voorzichtig", u
"vriend", u
"vrienden", u
"vrijheid", u
"vrouw", u
"we", u
"wij", u
"wil", u
"wilde", u
"wilden", u
"willen", u
"ze", u
"zelf", u
"zij", u
"zijn", u
"zinnen"]
92 for genre
in ["brief", "verhaal", "gedicht"]:
93 for style
in text_style
[genre
].keys():
94 to_season
= CharSpice(genre
, style
)
95 to_season
.loop_over_spices()