1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# Copyright (c) 2011 Martin Vilcans
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
class Slug(object):
def __init__(self, line, scene_number=None):
"""Creates a scene heading (slug).
The line parameter is a RichString with the slugline.
The scene_number parameter is an optional RichString.
"""
self.line = line
self.scene_number = scene_number
self.synopsis = None
@property
def lines(self):
return [self.line]
def set_synopsis(self, text):
self.synopsis = text
class Section(object):
"""A section heading."""
def __init__(self, text, level, synopsis=None):
self.text = text
self.level = level
self.synopsis = synopsis
def set_synopsis(self, text):
self.synopsis = text
def __repr__(self):
return 'Section(%r, %r, %r)' % (self.text, self.level, self.synopsis)
def __eq__(self, other):
return (
self.text == other.text and
self.level == other.level and
self.synopsis == other.synopsis
)
class Dialog(object):
def __init__(self, character, lines):
self.character = character
self.blocks = [] # list of tuples of (is_parenthetical, text)
self._parse(lines)
def _parse(self, lines):
inside_parenthesis = False
for line in lines:
if line.startswith('('):
inside_parenthesis = True
self.blocks.append((inside_parenthesis, line))
if line.endswith(')'):
inside_parenthesis = False
class DualDialog(object):
def __init__(self, left_dialog, right_dialog):
self.left = left_dialog
self.right = right_dialog
class Action(object):
def __init__(self, lines, centered=False):
self.lines = lines
self.centered = centered
class Transition(object):
def __init__(self, line):
self.line = line
@property
def lines(self):
return [self.line]
class PageBreak(object):
pass
|