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

Commit f794a85

Browse files
author
Kamil Sambor
committed
Fix rest of e123 errors
1 parent e263d22 commit f794a85

File tree

4 files changed

+48
-76
lines changed

4 files changed

+48
-76
lines changed

pydot_ng/__init__.py

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ def __repr__(self):
202202

203203
id_re_alpha_nums = re.compile('^[_a-zA-Z][a-zA-Z0-9_,]*$', re.UNICODE)
204204
id_re_alpha_nums_with_ports = re.compile(
205-
'^[_a-zA-Z][a-zA-Z0-9_,:\"]*[a-zA-Z0-9_,\"]+$', re.UNICODE
206-
)
205+
'^[_a-zA-Z][a-zA-Z0-9_,:\"]*[a-zA-Z0-9_,\"]+$', re.UNICODE)
207206
id_re_num = re.compile('^[0-9,]+$', re.UNICODE)
208207
id_re_with_port = re.compile('^([^:]*):([^:]*)$', re.UNICODE)
209208
id_re_dbl_quoted = re.compile('^\".*\"$', re.S | re.UNICODE)
@@ -364,9 +363,7 @@ def graph_from_adjacency_matrix(matrix, node_prefix='', directed=False):
364363
graph.add_edge(
365364
Edge(
366365
node_prefix + node_orig,
367-
node_prefix + node_dest
368-
)
369-
)
366+
node_prefix + node_dest))
370367
node_dest += 1
371368
node_orig += 1
372369

@@ -402,9 +399,7 @@ def graph_from_incidence_matrix(matrix, node_prefix='', directed=False):
402399
graph.add_edge(
403400
Edge(
404401
node_prefix + abs(nodes[0]),
405-
node_prefix + nodes[1]
406-
)
407-
)
402+
node_prefix + nodes[1]))
408403

409404
if not directed:
410405
graph.set_simplify(True)
@@ -521,8 +516,7 @@ def RegQueryValueEx(hkey, valuename):
521516
# this has a return value, which we should probably check
522517
ctypes.windll.advapi32.RegQueryValueExA(
523518
hkey, valuename, 0, ctypes.byref(data_type),
524-
data, ctypes.byref(data_len)
525-
)
519+
data, ctypes.byref(data_len))
526520

527521
return data.value
528522

@@ -537,15 +531,13 @@ def RegQueryValueEx(hkey, valuename):
537531
hkey = None
538532
potentialKeys = [
539533
"SOFTWARE\\ATT\\Graphviz",
540-
"SOFTWARE\\AT&T Research Labs\\Graphviz"
541-
]
534+
"SOFTWARE\\AT&T Research Labs\\Graphviz"]
542535
for potentialKey in potentialKeys:
543536

544537
try:
545538
hkey = RegOpenKeyEx(
546539
HKEY_LOCAL_MACHINE,
547-
potentialKey, 0, KEY_QUERY_VALUE
548-
)
540+
potentialKey, 0, KEY_QUERY_VALUE)
549541

550542
if hkey is not None:
551543
path = RegQueryValueEx(hkey, "InstallPath")
@@ -598,8 +590,7 @@ def RegQueryValueEx(hkey, valuename):
598590
'/usr/bin', '/usr/local/bin',
599591
'/opt/local/bin',
600592
'/opt/bin', '/sw/bin', '/usr/share',
601-
'/Applications/Graphviz.app/Contents/MacOS/'
602-
):
593+
'/Applications/Graphviz.app/Contents/MacOS/'):
603594

604595
progs = __find_executables(path)
605596
if progs is not None:
@@ -705,8 +696,8 @@ def create_attribute_methods(self, obj_attributes):
705696
# Generate all the Setter methods.
706697
self.__setattr__(
707698
'set_' + attr,
708-
lambda x, a=attr: self.obj_dict['attributes'].__setitem__(a, x)
709-
)
699+
lambda x, a=attr: self.obj_dict['attributes'].
700+
__setitem__(a, x))
710701

711702
# Generate all the Getter methods.
712703
self.__setattr__('get_' + attr,
@@ -1040,8 +1031,7 @@ def __init__(
10401031
if graph_type not in ['graph', 'digraph']:
10411032
raise Error((
10421033
'Invalid type "%s". Accepted graph types are: '
1043-
'graph, digraph, subgraph' % graph_type
1044-
))
1034+
'graph, digraph, subgraph' % graph_type))
10451035

10461036
self.obj_dict['name'] = quote_if_necessary(graph_name)
10471037
self.obj_dict['type'] = graph_type
@@ -1244,8 +1234,7 @@ def get_node(self, name):
12441234
match.extend([
12451235
Node(obj_dict=obj_dict)
12461236
for obj_dict
1247-
in self.obj_dict['nodes'][name]
1248-
])
1237+
in self.obj_dict['nodes'][name]])
12491238

12501239
return match
12511240

@@ -1265,8 +1254,7 @@ def get_node_list(self):
12651254
node_objs.extend([
12661255
Node(obj_dict=obj_d)
12671256
for obj_d
1268-
in obj_dict_list
1269-
])
1257+
in obj_dict_list])
12701258

12711259
return node_objs
12721260

@@ -1354,8 +1342,7 @@ def get_edge(self, src_or_list, dst=None):
13541342

13551343
if edge_points in self.obj_dict['edges'] or (
13561344
self.get_top_graph_type() == 'graph' and
1357-
edge_points_reverse in self.obj_dict['edges']
1358-
):
1345+
edge_points_reverse in self.obj_dict['edges']):
13591346

13601347
edges_obj_dict = self.obj_dict['edges'].get(
13611348
edge_points,
@@ -1383,8 +1370,7 @@ def get_edge_list(self):
13831370
edge_objs.extend([
13841371
Edge(obj_dict=obj_d)
13851372
for obj_d
1386-
in obj_dict_list
1387-
])
1373+
in obj_dict_list])
13881374

13891375
return edge_objs
13901376

@@ -1450,8 +1436,7 @@ def get_subgraph_list(self):
14501436
sgraph_objs.extend([
14511437
Subgraph(obj_dict=obj_d)
14521438
for obj_d
1453-
in obj_dict_list
1454-
])
1439+
in obj_dict_list])
14551440

14561441
return sgraph_objs
14571442

@@ -1525,8 +1510,7 @@ def to_string(self):
15251510
obj_list = sorted([
15261511
(obj['sequence'], obj)
15271512
for obj
1528-
in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts)
1529-
])
1513+
in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts)])
15301514

15311515
for idx, obj in obj_list:
15321516
if obj['type'] == 'node':
@@ -1663,35 +1647,31 @@ def __init__(self, *argsl, **argsd):
16631647
'fig', 'gd', 'gd2', 'gif', 'hpgl', 'imap', 'imap_np', 'ismap',
16641648
'jpe', 'jpeg', 'jpg', 'mif', 'mp', 'pcl', 'pdf', 'pic', 'plain',
16651649
'plain-ext', 'png', 'ps', 'ps2', 'svg', 'svgz', 'vml', 'vmlz',
1666-
'vrml', 'vtx', 'wbmp', 'xdot', 'xlib'
1667-
]
1650+
'vrml', 'vtx', 'wbmp', 'xdot', 'xlib']
16681651
self.prog = 'dot'
16691652

16701653
# Automatically creates all the methods enabling the creation
16711654
# of output in any of the supported formats.
16721655
for frmt in self.formats:
16731656
self.__setattr__(
16741657
'create_' + frmt,
1675-
lambda f=frmt, prog=self.prog: self.create(format=f, prog=prog)
1676-
)
1658+
lambda f=frmt, prog=self.prog:
1659+
self.create(format=f, prog=prog))
16771660
f = self.__dict__['create_' + frmt]
16781661
f.__doc__ = (
16791662
'''Refer to the docstring accompanying the'''
1680-
''''create' method for more information.'''
1681-
)
1663+
''''create' method for more information.''')
16821664

16831665
for frmt in self.formats + ['raw']:
16841666
self.__setattr__(
16851667
'write_' + frmt,
16861668
lambda path, f=frmt, prog=self.prog: self.write(path, format=f,
1687-
prog=prog)
1688-
)
1669+
prog=prog))
16891670

16901671
f = self.__dict__['write_' + frmt]
16911672
f.__doc__ = (
16921673
'''Refer to the docstring accompanying the'''
1693-
''''write' method for more information.'''
1694-
)
1674+
''''write' method for more information.''')
16951675

16961676
def __getstate__(self):
16971677
return copy.copy(self.obj_dict)

pydot_ng/_dotparser.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def __init__(self, default_type, attrs):
5757
def __repr__(self):
5858
return "%s(%s, %r)" % (
5959
self.__class__.__name__,
60-
self.default_type, self.attrs
61-
)
60+
self.default_type, self.attrs)
6261

6362

6463
top_graphs = list()
@@ -384,43 +383,42 @@ def parse_html(s, loc, toks):
384383
closer = '>'
385384
html_text = pyparsing.nestedExpr(
386385
opener, closer,
387-
(pyparsing.CharsNotIn(opener + closer))
388-
).setParseAction(parse_html).leaveWhitespace()
386+
(pyparsing.CharsNotIn(opener + closer))).\
387+
setParseAction(parse_html).leaveWhitespace()
389388

390389
ID = (
391390
identifier | html_text |
392391
double_quoted_string |
393-
alphastring_
394-
).setName("ID")
392+
alphastring_).setName("ID")
395393

396394
float_number = pyparsing.Combine(
397395
pyparsing.Optional(minus) +
398-
pyparsing.OneOrMore(pyparsing.Word(pyparsing.nums + "."))
399-
).setName("float_number")
396+
pyparsing.OneOrMore(pyparsing.Word(pyparsing.nums + "."))).\
397+
setName("float_number")
400398

401399
righthand_id = (float_number | ID).setName("righthand_id")
402400

403401
port_angle = (at + ID).setName("port_angle")
404402

405403
port_location = (
406404
pyparsing.OneOrMore(pyparsing.Group(colon + ID)) |
407-
pyparsing.Group(colon + lparen + ID + comma + ID + rparen)
408-
).setName("port_location")
405+
pyparsing.Group(colon + lparen + ID + comma + ID + rparen)).\
406+
setName("port_location")
409407

410408
port = (
411409
pyparsing.Group(port_location + pyparsing.Optional(port_angle)) |
412-
pyparsing.Group(port_angle + pyparsing.Optional(port_location))
413-
).setName("port")
410+
pyparsing.Group(port_angle + pyparsing.Optional(port_location))).\
411+
setName("port")
414412

415413
node_id = (ID + pyparsing.Optional(port))
416414
a_list = pyparsing.OneOrMore(
417415
ID + pyparsing.Optional(equals + righthand_id) +
418-
pyparsing.Optional(comma.suppress())
419-
).setName("a_list")
416+
pyparsing.Optional(comma.suppress())).\
417+
setName("a_list")
420418

421419
attr_list = pyparsing.OneOrMore(
422-
lbrack.suppress() + pyparsing.Optional(a_list) + rbrack.suppress()
423-
).setName("attr_list")
420+
lbrack.suppress() + pyparsing.Optional(a_list) +
421+
rbrack.suppress()).setName("attr_list")
424422

425423
attr_stmt = (pyparsing.Group(graph_ | node_ | edge_) + attr_list).\
426424
setName("attr_stmt")
@@ -431,8 +429,8 @@ def parse_html(s, loc, toks):
431429
stmt_list = pyparsing.Forward()
432430
graph_stmt = pyparsing.Group(
433431
lbrace.suppress() + pyparsing.Optional(stmt_list) +
434-
rbrace.suppress() + pyparsing.Optional(semi.suppress())
435-
).setName("graph_stmt")
432+
rbrace.suppress() + pyparsing.Optional(semi.suppress())).\
433+
setName("graph_stmt")
436434

437435
edge_point = pyparsing.Forward()
438436

@@ -452,16 +450,16 @@ def parse_html(s, loc, toks):
452450
assignment = (ID + equals + righthand_id).setName("assignment")
453451
stmt = (
454452
assignment | edge_stmt | attr_stmt |
455-
subgraph | graph_stmt | node_stmt
456-
).setName("stmt")
453+
subgraph | graph_stmt | node_stmt).\
454+
setName("stmt")
457455
stmt_list << pyparsing.OneOrMore(stmt + pyparsing.Optional(
458456
semi.suppress()))
459457

460458
graphparser = pyparsing.OneOrMore((
461459
pyparsing.Optional(strict_) +
462460
pyparsing.Group((graph_ | digraph_)) +
463-
pyparsing.Optional(ID) + graph_stmt
464-
).setResultsName("graph"))
461+
pyparsing.Optional(ID) + graph_stmt).
462+
setResultsName("graph"))
465463

466464
singleLineComment = (pyparsing.Group("//" + pyparsing.restOfLine) |
467465
pyparsing.Group("#" + pyparsing.restOfLine))

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@
3030
'Operating System :: OS Independent',
3131
'Programming Language :: Python',
3232
'Topic :: Scientific/Engineering :: Visualization',
33-
'Topic :: Software Development :: Libraries :: Python Modules'
34-
],
33+
'Topic :: Software Development :: Libraries :: Python Modules'],
3534
long_description=readme,
3635
packages=['pydot_ng'],
3736
package_dir={'pydot_ng': 'pydot_ng'},
38-
install_requires=[
39-
'pyparsing>=2.0.1',
40-
],
41-
)
37+
install_requires=['pyparsing>=2.0.1'],
38+
)

test/test_pydot.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ def test_graph_with_shapefiles(self):
131131
pngs = [
132132
os.path.join(shapefile_dir, fname)
133133
for fname in os.listdir(shapefile_dir)
134-
if fname.endswith('.png')
135-
]
134+
if fname.endswith('.png')]
136135

137136
f = open(dot_file, 'rt')
138137
graph_data = f.read()
@@ -156,8 +155,7 @@ def _render_with_graphviz(self, filename):
156155
(DOT_BINARY_PATH, '-Tjpe'),
157156
cwd=os.path.dirname(filename),
158157
stdin=open(filename, 'rt'),
159-
stderr=subprocess.PIPE, stdout=subprocess.PIPE
160-
)
158+
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
161159

162160
stdout = p.stdout
163161

@@ -195,8 +193,7 @@ def _render_and_compare_dot_files(self, directory):
195193

196194
dot_files = [
197195
fname for fname in os.listdir(directory)
198-
if fname.endswith('.dot')
199-
]
196+
if fname.endswith('.dot')]
200197

201198
for dot in dot_files:
202199
os.sys.stdout.write('#')

0 commit comments

Comments
 (0)