-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfe.py
129 lines (95 loc) · 2.71 KB
/
fe.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
"""
Flask-based application that will generate patch lists for X32 show files.
User uploads their show file to /generate which will create an HTML file based on
their options.
The template has a checkbox for each section/line to show that row. There is also a
remarks and source column that user can enter text in.
(c) Chris Stranex 2017 <[email protected]>
Under the GNU GPL v2 Licence
"""
from flask import Flask, request, render_template, redirect, url_for
from main import ScnParser
app = Flask(__name__, static_url_path='/')
app.debug = True
parser = ScnParser()
TYPE_NAMES = {
'in': 'Local',
'aux': 'Aux',
'aes': 'AES',
'aes50a': 'AES50-A',
'aes50b': 'AES50-B',
'card': 'Card',
'p16': 'Ultranet',
'out': 'Local',
'mtx': 'Matrix'
}
MIX_NAMES = {
'bus': 'Bus',
'main': 'Main',
'fxrtn': 'FX',
'mtx': 'Matrix'
}
CHANNEL_NAMES = {
'auxin': 'Aux',
}
def GetMixName(type, n):
""" Prefix a channel with its mix name """
name = MIX_NAMES[type]
if type == 'main':
return '{} {}'.format(name, n.upper())
if n.isdigit():
n = "{:02}".format(int(n))
return '{} {}'.format(name, n)
def GetChannelName(type, n):
""" Prefix a channel with its channel type """
if type in CHANNEL_NAMES:
return ('{} {}'.format(CHANNEL_NAMES[type], n))
else:
return n
def GetDeskName(chan):
""" Return either an input or output channel name """
if not chan:
return ''
if 'mix' in chan:
return GetMixName(chan['mix'], chan['mix_index'])
elif 'channel' in chan:
return GetChannelName(chan['channel'], chan['channel_index'])
return ''
def GetTypeName(type, n):
""" Return correct name from type """
if type == 'in' and n > 32:
return 'Aux In'
else:
return TYPE_NAMES[type]
def GetSourceIndex(type, n):
""" Return correct source names """
if type == 'in':
if n < 33:
return n
elif n < 39:
return 'Aux {:01}'.format(n - 32)
elif n < 40:
return 'USB L'
elif n < 41:
return 'USB R'
else:
return n
@app.route('/')
def index():
return redirect(url_for('static', filename='index.html'))
@app.route('/generate', methods=['POST'])
def generate():
"""
Generation method, accepts an uploaded scn file
"""
parser.ParseFile(request.files['scene'])
kwargs = {
'parser': parser,
'TYPE_NAMES': TYPE_NAMES,
'GetTypeName': GetTypeName,
'GetSourceIndex': GetSourceIndex,
'GetDeskName': GetDeskName
}
return render_template('template.html', **kwargs)
if __name__ == '__main__':
app.run()