Skip to content
This repository was archived by the owner on Nov 22, 2019. It is now read-only.

Commit cae8735

Browse files
author
mfe
committed
Correct multi-lines continuation #1
1 parent 0f21178 commit cae8735

File tree

2 files changed

+70
-67
lines changed

2 files changed

+70
-67
lines changed

plotThatLut/plot_that_lut.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
class PlotThatLutException(Exception):
2323
pass
2424

25+
2526
def set_matplotlib_backend():
2627
""" Select display backend
2728
@@ -61,10 +62,10 @@ def show_plot(fig, filename):
6162
split_filename[1].replace(".", "_"))
6263
export_path = 'img/export_{0}.png'.format(filename)
6364
fig.savefig(export_path)
64-
return """
65-
<img src="/{0}"" width="640" height="480"
66-
border="0"/>
67-
""".format(export_path)
65+
return (
66+
'<img src="/{0}" width="640" height="480"'
67+
'border="0"/>'
68+
).format(export_path)
6869
else:
6970
matplotlib.pyplot.show()
7071
return ""
@@ -232,21 +233,19 @@ def help():
232233
str.
233234
234235
"""
235-
return """
236-
----
237-
plot_that_lut.py <path to a LUT>
238-
dispay a cube ({0} segments) for 3D LUTs and matrixes
239-
or a curve ({1} points) for 1D/2D LUTs.
240-
241-
plot_that_lut.py <path to a LUT> curve [points count]
242-
display a curve with x points (default value : {2}).
243-
244-
plot_that_lut.py <path to a LUT> cube [cube size]
245-
display a cube with x segments (default value : {3}).
236+
return (
237+
"----\n"
238+
"plot_that_lut.py <path to a LUT>\n"
239+
" dispay a cube ({0} segments) for 3D LUTs and matrixes\n"
240+
" or a curve ({1} points) for 1D/2D LUTs.\n"
246241

247-
{4}
248-
""".format(DEFAULT_CUBE_SIZE, DEFAULT_SAMPLE, DEFAULT_SAMPLE,
249-
DEFAULT_CUBE_SIZE, supported_formats())
242+
"plot_that_lut.py <path to a LUT> curve [points count]\n"
243+
" display a curve with x points (default value : {2}).\n"
244+
" plot_that_lut.py <path to a LUT> cube [cube size]\n"
245+
" display a cube with x segments (default value : {3}).\n"
246+
"\n{4}"
247+
).format(DEFAULT_CUBE_SIZE, DEFAULT_SAMPLE, DEFAULT_SAMPLE,
248+
DEFAULT_CUBE_SIZE, supported_formats())
250249

251250

252251
def plot_that_lut(lutfile, plot_type=None, count=None):
@@ -268,10 +267,10 @@ def plot_that_lut(lutfile, plot_type=None, count=None):
268267
# check if LUT format is supported
269268
fileext = os.path.splitext(lutfile)[1]
270269
if not fileext:
271-
raise PlotThatLutException("""
272-
Error: Couldn't extract extension in this
273-
path : {0}
274-
""".format(lutfile))
270+
raise PlotThatLutException((
271+
"Error: Couldn't extract extension in this\n"
272+
"path : {0}"
273+
).format(lutfile))
275274
if fileext not in OCIO_LUTS_FORMATS:
276275
raise PlotThatLutException("Error: {0} file aren't supported.\n{1}"
277276
.format(fileext, supported_formats()))
@@ -296,9 +295,10 @@ def plot_that_lut(lutfile, plot_type=None, count=None):
296295
elif plot_type == 'cube':
297296
return plot_cube(lutfile, count, processor)
298297
else:
299-
raise PlotThatLutException("""Unknown plot type : {0}
300-
Plot type should be curve or cube.\n{1}
301-
""".format(plot_type, help()))
298+
raise PlotThatLutException((
299+
"Unknown plot type : {0}\n"
300+
"Plot type should be curve or cube.\n{1}"
301+
).format(plot_type, help()))
302302

303303
if __name__ == '__main__':
304304
""" Command line interface for plot_that_lut

plotThatLut/plot_that_lut_web.py

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ def html(self, body):
2727
str.
2828
2929
"""
30-
return """
31-
<html>
32-
<head>
33-
<title>Plot That Lut</title>
34-
<link rel="stylesheet" type="text/css" href="css/style.css">
35-
</head>
36-
<body>
37-
<div id="content">
38-
<div id='header'><h1># Plot That LUT #</h1></div>
39-
<div id='text'>
40-
{0}
41-
</div>
42-
</div>
43-
</body>
44-
</html>
45-
""".format(body)
30+
return (
31+
"<html>\n"
32+
"<head>\n"
33+
" <title>Plot That Lut</title>\n"
34+
' <link rel="stylesheet" type="text/css" href="css/style.css">\n'
35+
"</head>\n"
36+
"<body>\n"
37+
' <div id="content">\n'
38+
' <div id="header"><h1># Plot That LUT #</h1></div>\n'
39+
' <div id="text">\n'
40+
' {0}\n'
41+
' </div>\n'
42+
' </div>\n'
43+
'</body>\n'
44+
'</html>\n'
45+
).format(body)
4646

4747
def form(self):
4848
"""Return plot that lut web ui
@@ -51,22 +51,25 @@ def form(self):
5151
str.
5252
5353
"""
54-
return """
55-
<form action="upload" method="post" enctype="multipart/form-data">
56-
Choose LUT file: <input type="file" name="lutfile" /><br/>
57-
Lut Type:
58-
<input type="radio" name="lut_type" value="auto" checked=true> auto
59-
<input type="radio" name="lut_type" value="curve"> curve
60-
<input type="radio" name="lut_type" value="cube"> cube
61-
<br>
62-
Samples count:
63-
<input type="radio" name="count" value="auto" checked=true> auto
64-
<input type="radio" name="count" value="custom"> custom :
65-
<input type="text" name="custom_count" value=17 size=5>
66-
<br>
67-
<input type="submit" />
68-
</form>
69-
"""
54+
return (
55+
'<form action="upload" method="post" '
56+
'enctype="multipart/form-data">\n'
57+
' Choose LUT file: <input type="file" name="lutfile"/><br/>\n'
58+
" Lut Type:"
59+
' <input type="radio" name="lut_type" value="auto" '
60+
'checked=true> auto\n'
61+
' <input type="radio" name="lut_type" value="curve"> curve\n'
62+
' <input type="radio" name="lut_type" value="cube"> cube\n'
63+
" <br>\n"
64+
" Samples count:\n"
65+
' <input type="radio" name="count" value="auto" checked=true> '
66+
'auto\n'
67+
' <input type="radio" name="count" value="custom"> custom :\n'
68+
' <input type="text" name="custom_count" value=17 size=5>\n'
69+
" <br>\n"
70+
' <input type="submit"/>\n'
71+
"</form>"
72+
)
7073

7174
def index(self):
7275
"""Index page
@@ -124,16 +127,16 @@ def upload(self, lutfile, lut_type, count, custom_count):
124127
result = plot_that_lut(backup_filename, lut_type, tmp_count)
125128
except Exception, e:
126129
error = str(e).replace('\n', '<br>')
127-
result = """
128-
<h2>Something went wrong ! </h2>
129-
<br>
130-
<font color="#FF0000">{0}</font><br>
131-
""".format(error)
132-
return self.html("""
133-
{0}<br>
134-
{1}<br>
135-
<a href=javascript:history.back()>Go back</a>
136-
""".format(label, result))
130+
result = (
131+
"<h2>Something went wrong ! </h2>"
132+
"<br>"
133+
'<font color="#FF0000">{0}</font><br>'
134+
).format(error)
135+
return self.html((
136+
"{0}<br>"
137+
"{1}<br>"
138+
"<a href=javascript:history.back()>Go back</a>"
139+
).format(label, result))
137140
upload.exposed = True
138141

139142
# CherryPy configuration

0 commit comments

Comments
 (0)