8000 PEP8 fixes. Rename web_static -> web_backend · matplotlib/matplotlib@ae884b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae884b0

Browse files
committed
PEP8 fixes. Rename web_static -> web_backend
1 parent c5479c2 commit ae884b0

23 files changed

+77
-54
lines changed

lib/matplotlib/backends/backend_webagg.py

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def mainloop(self):
4646
WebAggApplication.initialize()
4747
for manager in Gcf.get_all_fig_managers():
4848
url = "http://127.0.0.1:{0}/{1}/".format(
49-
WebAggApplication.port, manager.num)
49+
WebAggApplication.port, manager.num)
5050
if rcParams['webagg.open_in_browser']:
5151
import webbrowser
5252
webbrowser.open(url)
@@ -191,8 +191,8 @@ def get_diff_image(self):
191191
self._png_buffer)
192192

193193
# Swap the renderer frames
194-
self._renderer, self._last_renderer = \
195-
self._last_renderer, self._renderer
194+
self._renderer, self._last_renderer = (
195+
self._last_renderer, self._renderer)
196196
self._force_full = False
197197
self._png_is_old = False
198198
return self._png_buffer.getvalue()
@@ -208,8 +208,10 @@ def get_renderer(self):
208208
need_new_renderer = (self._lastKey != key)
209209

210210
if need_new_renderer:
211-
self._renderer = backend_agg.RendererAgg(w, h, self.figure.dpi)
212-
self._last_renderer = backend_agg.RendererAgg(w, h, self.figure.dpi)
211+
self._renderer = backend_agg.RendererAgg(
212+
w, h, self.figure.dpi)
213+
self._last_renderer = backend_agg.RendererAgg(
214+
w, h, self.figure.dpi)
213215
self._lastKey = key
214216

215217
return self._renderer
@@ -261,11 +263,13 @@ def new_timer(self, *args, **kwargs):
261263
def start_event_loop(self, timeout):
262264
backend_bases.FigureCanvasBase.start_event_loop_default(
263265
self, timeout)
264-
start_event_loop.__doc__ = backend_bases.FigureCanvasBase.start_event_loop_default.__doc__
266+
start_event_loop.__doc__ = \
267+
backend_bases.FigureCanvasBase.start_event_loop_default.__doc__
265268

266269
def stop_event_loop(self):
267270
backend_bases.FigureCanvasBase.stop_event_loop_default(self)
268-
stop_event_loop.__doc__ = backend_bases.FigureCanvasBase.stop_event_loop_default.__doc__
271+
stop_event_loop.__doc__ = \
272+
backend_bases.FigureCanvasBase.stop_event_loop_default.__doc__
269273

270274

271275
class FigureManagerWebAgg(backend_bases.FigureManagerBase):
@@ -304,18 +308,22 @@ def resize(self, w, h):
304308
class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
305309
toolitems = list(backend_bases.NavigationToolbar2.toolitems[:6]) + [
306310
('Download', 'Download plot', 'filesave', 'download')
307-
]
311+
]
308312

309313
def _init_toolbar(self):
310-
jqueryui_icons = ['ui-icon ui-icon-home',
314+
jqueryui_icons = [
315+
'ui-icon ui-icon-home',
311316
'ui-icon ui-icon-circle-arrow-w',
312-
'ui-icon ui-icon-circle-arrow-e', None,
317+
'ui-icon ui-icon-circle-arrow-e',
318+
None,
313319
'ui-icon ui-icon-arrow-4',
314320
'ui-icon ui-icon-search',
315-
'ui-icon ui-icon-disk']
321+
'ui-icon ui-icon-disk'
322+
]
316323
for index, item in enumerate(self.toolitems):
317324
if item[0] is not None:
318-
self.toolitems[index]=(item[0],item[1],jqueryui_icons[index],item[3])
325+
self.toolitems[index] = (
326+
item[0], item[1], jqueryui_icons[index], item[3])
319327
self.message = ''
320328
self.cursor = 0
321329

@@ -361,7 +369,7 @@ class IndexPage(tornado.web.RequestHandler):
361369
def get(self, fignum):
362370
with open(os.path.join(
363371
os.path.dirname(__file__),
364-
'web_static', 'index.html')) as fd:
372+
'web_backend', 'index.html')) as fd:
365373
tpl = fd.read()
366374

367375
fignum = int(fignum)
@@ -387,7 +395,7 @@ def get(self, fignum, format):
387395
'jpeg': 'image/jpeg',
388396
'tif': 'image/tiff',
389397
'emf': 'application/emf'
390-
}
398+
}
391399

392400
self.set_header('Content-Type', mimetypes.get(format, 'binary'))
393401

@@ -438,25 +446,32 @@ def send_image(self):
438446
def __init__(self):
439447
super(WebAggApplication, self).__init__([
440448
# Static files for the CSS and JS
441-
(r'/static/(.*)', tornado.web.StaticFileHandler,
449+
(r'/static/(.*)',
450+
tornado.web.StaticFileHandler,
442451
{'path':
443-
os.path.join(os.path.dirname(__file__), 'web_static')}),
452+
os.path.join(os.path.dirname(__file__), 'web_backend')}),
444453
# Static images for toolbar buttons
445-
(r'/images/(.*)', tornado.web.StaticFileHandler,
454+
(r'/images/(.*)',
455+
tornado.web.StaticFileHandler,
446456
{'path':
447457
os.path.join(os.path.dirname(__file__), '../mpl-data/images')}),
448-
(r'/static/jquery/css/themes/base/(.*)', tornado.web.StaticFileHandler,
458+
(r'/static/jquery/css/themes/base/(.*)',
459+
tornado.web.StaticFileHandler,
449460
{'path':
450-
os.path.join(os.path.dirname(__file__), 'web_static/jquery/css/themes/base')}),
451-
(r'/static/jquery/css/themes/base/images/(.*)', tornado.web.StaticFileHandler,
461+
os.path.join(os.path.dirname(__file__),
462+
'web_backend/jquery/css/themes/base')}),
463+
(r'/static/jquery/css/themes/base/images/(.*)',
464+
tornado.web.StaticFileHandler,
452465
{'path':
453-
os.path.join(os.path.dirname(__file__), 'web_static/jquery/css/themes/base/images')}),
466+
os.path.join(os.path.dirname(__file__),
467+
'web_backend/jquery/css/themes/base/images')}),
454468
(r'/static/jquery/js/(.*)', tornado.web.StaticFileHandler,
455469
{'path':
456-
os.path.join(os.path.dirname(__file__), 'web_static/jquery/js')}),
470+
os.path.join(os.path.dirname(__file__),
471+
'web_backend/jquery/js')}),
457472
(r'/static/css/(.*)', tornado.web.StaticFileHandler,
458473
{'path':
459-
os.path.join(os.path.dirname(__file__), 'web_static/css')}),
474+
os.path.join(os.path.dirname(__file__), 'web_backend/css')}),
460475
# An MPL favicon
461476
(r'/favicon.ico', self.FavIcon),
462477
# The page that contains all of the pieces
@@ -466,7 +481,7 @@ def __init__(self):
466481
(r'/([0-9]+)/ws', self.WebSocket),
467482
# Handles the downloading (i.e., saving) of static images
468483
(r'/([0-9]+)/download.([a-z]+)', self.Download)
469-
])
484+
])
470485

471486
@classmethod
472487
def initialize(cls):

lib/matplotlib/backends/web_static/index.html renamed to lib/matplotlib/backends/web_backend/index.html

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<html>
2-
<head>
2+
<head>
33
<link rel="stylesheet" href="/static/css/page.css" type="text/css">
44
<link rel="stylesheet" href="/static/css/boilerplate.css" type="text/css" />
55
<link rel="stylesheet" href="/static/css/fbm.css" type="text/css" />
@@ -24,7 +24,8 @@
2424
<body
2525
onkeydown="key_event(event, 'key_press')"
2626
onkeyup="key_event(event, 'key_release')">
27-
<div id="mpl-div" style="margin-left: auto ; margin-right: auto ; width: 800px;">
27+
<div id="mpl-div"
28+
style="margin-left: auto ; margin-right: auto ; width: 800px;">
2829
<div id="mpl-warnings" class="mpl-warnings">
2930
</div>
3031

@@ -46,37 +47,44 @@
4647
</div>
4748

4849
<div id="toolbar" class="ui-widget ui-widget-content"
49-
style="border-top-style: none; border-left-style: none; border-right-style: none; border-bottom-style: none;">
50+
style="border-top-style: none; border-left-style: none;
51+
border-right-style: none; border-bottom-style: none;">
5052
{% for name, tooltip, image, method in toolitems %}
51-
{% if name is None %}
52-
<span style='width: 0.1em'></span>
53-
{% else %}
54-
<button id="{{ name }}"
55-
onclick="toolbar_button_onclick('{{ method }}');"
56-
role="button"
57-
aria-disabled="false"
58-
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only">
59-
<span class="ui-button-icon-primary ui-icon {{ image }} ui-corner-all"></span>
60-
<span class="ui-button-text">{{ tooltip }}</span>
61-
</button>
62-
{% end %}
53+
{% if name is None %}
54+
<span style='width: 0.1em'></span>
55+
{% else %}
56+
<button id="{{ name }}"
57+
onclick="toolbar_button_onclick('{{ method }}');"
58+
role="button"
59+
aria-disabled="false"
60+
class="ui-button ui-widget ui-state-default ui-corner-all
61+
ui-button-icon-only">
62+
<span
63+
class="ui-button-icon-primary ui-icon {{ image }}
64+
ui-corner-all">
65+
</span>
66+
<span class="ui-button-text">
67+
{{ tooltip }}
68+
</span>
69+
</button>
6370
{% end %}
64-
<span>
65-
<select id="mpl-format" class="mpl-toolbar-option ui-widget ui-widget-content" style="margin-top: 0px;">
66-
{% for filetype, extensions in sorted(canvas.get_supported_filetypes_grouped().items()) %}
67-
<option value="{{ extensions[0] }}"
68-
{% if extensions[0] == canvas.get_default_filetype() %}
69-
selected
70-
{% end %}
71-
>{{filetype}} ({{", ".join(extensions)}})</option>
72-
{% end %}
73-
</select>
74-
</span>
75-
71+
{% end %}
72+
<span>
73+
<select id="mpl-format" class="mpl-toolbar-option ui-widget ui-widget-content" style="margin-top: 0px;">
74+
{% for filetype, extensions in sorted(canvas.get_supported_filetypes_grouped().items()) %}
75+
<option value="{{ extensions[0] }}"
76+
{% if extensions[0] == canvas.get_default_filetype() %}
77+
selected
78+
{% end %}
79+
>{{filetype}} ({{", ".join(extensions)}})
80+
</option>
81+
{% end %}
82+
</select>
83+
</span>
84+
</div>
85+
<div>
86+
<span id="mpl-message" class="mpl-message"/>
7687
</div>
77-
<div>
78-
<span id="mpl-message" class="mpl-message"/>
79-
</div>
8088
</div>
8189
</body>
8290
</html>

0 commit comments

Comments
 (0)
0