Skip to content

Commit 186988c

Browse files
committed
flake8 aafig
1 parent 3c95f90 commit 186988c

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

doc/_ext/aafig.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
from docutils.parsers.rst.directives import flag, images, nonnegative_int
2020
from sphinx.errors import SphinxError
2121
from sphinx.util import ensuredir, relative_uri
22-
from sphinx.util.compat import Directive
2322

2423
try:
2524
from hashlib import sha1 as sha
2625
except ImportError:
2726
from sha import sha
2827

2928

30-
3129
try:
3230
import aafigure
3331
except ImportError:
@@ -64,20 +62,19 @@ class AafigDirective(images.Image):
6462
has_content = True
6563
required_arguments = 0
6664
own_option_spec = dict(
67-
line_width = float,
68-
background = str,
69-
foreground = str,
70-
fill = str,
71-
aspect = nonnegative_int,
72-
textual = flag,
73-
proportional = flag,
65+
line_width=float,
66+
background=str,
67+
foreground=str,
68+
fill=str,
69+
aspect=nonnegative_int,
70+
textual=flag,
71+
proportional=flag,
7472
)
7573
option_spec = images.Image.option_spec.copy()
7674
option_spec.update(own_option_spec)
7775

7876
def run(self):
7977
aafig_options = dict()
80-
image_attrs = dict()
8178
own_options_keys = self.own_option_spec.keys() + ['scale']
8279
for (k, v) in self.options.items():
8380
if k in own_options_keys:
@@ -94,7 +91,7 @@ def run(self):
9491
if isinstance(image_node, nodes.system_message):
9592
return [image_node]
9693
text = '\n'.join(self.content)
97-
image_node.aafig = dict(options = aafig_options, text = text)
94+
image_node.aafig = dict(options=aafig_options, text=text)
9895
return [image_node]
9996

10097

@@ -103,12 +100,11 @@ def render_aafig_images(app, doctree):
103100
merge_dict(format_map, DEFAULT_FORMATS)
104101
if aafigure is None:
105102
app.builder.warn('aafigure module not installed, ASCII art images '
106-
'will be redered as literal text')
103+
'will be redered as literal text')
107104
for img in doctree.traverse(nodes.image):
108105
if not hasattr(img, 'aafig'):
109106
continue
110107
if aafigure is None:
111-
img.replace_self(nodes.literal_block(text, text))
112108
continue
113109
options = img.aafig['options']
114110
text = img.aafig['text']
@@ -118,8 +114,8 @@ def render_aafig_images(app, doctree):
118114
options['format'] = format_map[format]
119115
else:
120116
app.builder.warn('unsupported builder format "%s", please '
121-
'add a custom entry in aafig_format config option '
122-
'for this builder' % format)
117+
'add a custom entry in aafig_format config '
118+
'option for this builder' % format)
123119
img.replace_self(nodes.literal_block(text, text))
124120
continue
125121
if options['format'] is None:
@@ -135,9 +131,9 @@ def render_aafig_images(app, doctree):
135131
# FIXME: find some way to avoid this hack in aafigure
136132
if extra:
137133
(width, height) = [x.split('"')[1] for x in extra.split()]
138-
if not img.has_key('width'):
134+
if 'width' not in img:
139135
img['width'] = width
140-
if not img.has_key('height'):
136+
if 'height' not in img:
141137
img['height'] = height
142138

143139

@@ -160,9 +156,10 @@ def render_aafigure(app, text, options):
160156
# Non-HTML
161157
if app.builder.format != 'latex':
162158
app.builder.warn('aafig: the builder format %s is not officially '
163-
'supported, aafigure images could not work. Please report '
164-
'problems and working builder to avoid this warning in '
165-
'the future' % app.builder.format)
159+
'supported, aafigure images could not work. '
160+
'Please report problems and working builder to '
161+
'avoid this warning inthe future' %
162+
app.builder.format)
166163
relfn = fname
167164
outfn = path.join(app.builder.outdir, fname)
168165
metadata_fname = '%s.aafig' % outfn

0 commit comments

Comments
 (0)