minor changes
[o_s.git] / character_spices.py
blob93cb18902abadeb83a984968985c13cd81ca1c8d
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
8 from texts import *
9 from liblove import *
11 class CharSpice(Spice):
12 def __init__(self, spices, words):
13 Spice.__init__(self, ["sexy", "champagne", "lungo"], [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"])
15 def special_kinda_p(paragraphic_style, boldstyle, text, textbox):
16 sectioned = text.split()
17 p = P(text=u"", stylename=paragraphic_style)
18 try:
19 sectioned[-1]
20 for i in range(len(sectioned)-1):
21 if sectioned[i].lower() in self.words:
22 boldpart = Span(stylename=boldstyle, text=sectioned[i] + u" ")
23 p.addElement(boldpart)
24 else:
25 normalpart = Span(text=sectioned[i] + u" ")
26 p.addElement(normalpart)
27 p.addText(sectioned[-1])
28 except IndexError:
29 p.addText(u"")
30 textbox.addElement(p)
32 def character_text_frame(self, odt, spice):
33 # character spice !
34 if spice == "sexy":
35 boldstyle = Style(name=spice + "Bold", family="text")
36 boldprop = TextProperties(fontfamily="diluvienne", fontsize="28pt")
37 boldstyle.addElement(boldprop)
38 odt.automaticstyles.addElement(boldstyle)
39 elif spice == "champagne":
40 boldstyle = Style(name=spice + "Bold", family="text")
41 boldprop = TextProperties(fontfamily="Cimatics_Trash")
42 boldstyle.addElement(boldprop)
43 odt.automaticstyles.addElement(boldstyle)
44 else:
45 boldstyle = Style(name=spice + "Bold", family="text")
46 boldprop = TextProperties(fontweight="bold", fontfamily="NotCourierSans", letterspacing="2mm")
47 boldstyle.addElement(boldprop)
48 odt.automaticstyles.addElement(boldstyle)
50 ### header frame (for letter)
51 if self.genre == "brief":
52 self.header(odt)
54 ### textframe
55 graphic_style = Style(name="Main Body Frame", family="graphic")
56 graphic_properties = GraphicProperties(backgroundcolor="#ffffff", border="10mm double #ffffff")
57 graphic_style.addElement(graphic_properties)
58 frame = self.make_frame(odt, graphic_style, "240mm", "170mm", "0mm", "0mm", "1")
59 frameframe = frame["frame"]
60 textbox = frame["textbox"]
62 for paragraph in txt[self.genre]:
63 special_kinda_p("Body Text", boldstyle, paragraph, textbox)
65 odt.text.addElement(frameframe)
67 def main_loop(self):
68 for myspice in self.spices:
70 myodt = OpenDocumentText()
72 # genredotstyle... is this really the name we want?
73 genredotstyle = self.read_stylesheet(self.genre, self.style)
74 myodt.styles.addElement(genredotstyle)
75 self.frame_border(myodt)
77 self.character_text_frame(self, myodt, myspice)
80 self.label(myodt, myspice, self.style)
82 self.myname = self.genre + "/" + self.style + "/character/" + self.genre + "_" + self.style + "_" + myspice
83 myodt.save(self.myname, True)
85 directory_structure()
86 for genre in ["brief", "verhaal", "gedicht"]:
87 for style in text_style[genre].keys():
88 one_odt = CharSpice()
89 one_odt.setgenrestyle(genre, style)
90 one_odt.main_loop()