-
Notifications
You must be signed in to change notification settings - Fork 0
/
AUBRUSHLI.py
171 lines (132 loc) · 4.2 KB
/
AUBRUSHLI.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import fountainplus
import csv
from collections import Counter
from gooey import Gooey
from gooey import GooeyParser
@Gooey(header_show_title=True, header_show_subtitle=True, menus=True, program_name='Aubrushli', menu=[{'name': 'Help', 'items':
[{
'type': 'AboutDialog',
'menuTitle': 'About Aubrushli'
,
'name': 'Aubrushli',
'description': 'A simple app to read and extract production information from screenplays',
'version': '1.0',
'copyright': '2022',
'website': 'https://github.com/StephanosPSteer/AUBRUSHLI',
'developer': 'Stefanos Christofi',
'license': 'MIT'
}]
}]
)
def main():
#mac version
parser = GooeyParser(description="By Stefanos Christofi \nE:stefanoschristofi@yahoo.com")
#windows version
#parser = GooeyParser()
g= parser.add_argument_group()
g.add_argument(
"-i",
"--inputfile",
metavar='Load Fountain File',
required=True,
help="Fountain File",
widget='FileChooser'
)
# parser.add_argument(
# "--castlist",
# metavar='Cast List',
# action='store_true',
# help="create a cast list"
# )
# parser.add_argument('--cast_out_file',
# metavar='Save Cast List',
# #action='store_true',
# widget='FileSaver')
# parser.add_argument(
# "--breakdownsummary",
# metavar='Breakdown Summary',
# action='store_true',
# help="create a breakdown summary"
# )
# parser.add_argument('--break_out_file',
# metavar='Save Breakdown Summary',
# #action='store_true',
# widget='FileSaver')
# parser.add_argument(
# "--shotlist",
# metavar='Shot List',
# action='store_true',
# help="create a shotlist"
# )
# parser.add_argument('--shot_out_file',
# metavar='Save Shot List',
# #action='store_true',
# widget='FileSaver')
cast = g.add_mutually_exclusive_group(gooey_options={
'title': "Cast List"
})
cast.add_argument('--cast_out', metavar='Save Cast List',
help='Select where to save Cast List',
widget='FileSaver',
gooey_options=dict(
wildcard="CSV (.csv)|*.csv", full_width=True
))
breakd = g.add_mutually_exclusive_group(gooey_options={
'title': "Breakdown Summary"
})
breakd.add_argument('--break_out', metavar='Save Breakdown Summary',
help='Select where to save Breakdown Summary', widget='FileSaver',
gooey_options=dict(
wildcard="CSV (.csv)|*.csv", full_width=True))
shot = g.add_mutually_exclusive_group(gooey_options={
'title': "Shot List"
})
shot.add_argument('--shot_out', metavar='Save Shot List',
help='Select where to save Shot List', widget='FileSaver',
gooey_options=dict(
wildcard="CSV (.csv)|*.csv", full_width=True,))
args = parser.parse_args()
# load fountain file
d = open(args.inputfile, 'r')
work_with_me = d.read()
d.close()
this_text = work_with_me
# make it a fountain object
F = fountainplus.Fountain(this_text)
#if args.castlist:
if args.cast_out:
res = list(Counter(F.characters).items())
header = ['Cast Name', 'Dialogue Frequency']
output_cast = args.cast_out
#with open('cast.csv', 'w', encoding='UTF8', newline='') as f:
with open(output_cast, 'w', encoding='UTF8', newline='') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerows(res)
#writer.close()
f.close
print('castlist created')
if args.break_out:
header = F.csvheader
data = F.csvrow
data.sort(key=lambda x: (x[5], x[6], x[7]))
output_break = args.break_out
with open(output_break, 'w', encoding='UTF8', newline='') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerows(data)
f.close
print('breakdown summary created')
if args.shot_out:
header = F.shotheader
data = F.shotrow
output_shot = args.shot_out
with open(output_shot, 'w', encoding='UTF8', newline='') as s:
writer = csv.writer(s)
# write the header
writer.writerow(header)
# write multiple rows
writer.writerows(data)
print('shotlist created')
if __name__ == "__main__":
main()