Fix rest of e123 errors
This commit is contained in:
parent
e263d22247
commit
f794a85300
@ -202,8 +202,7 @@ dot_keywords = ['graph', 'subgraph', 'digraph', 'node', 'edge', 'strict']
|
||||
|
||||
id_re_alpha_nums = re.compile('^[_a-zA-Z][a-zA-Z0-9_,]*$', re.UNICODE)
|
||||
id_re_alpha_nums_with_ports = re.compile(
|
||||
'^[_a-zA-Z][a-zA-Z0-9_,:\"]*[a-zA-Z0-9_,\"]+$', re.UNICODE
|
||||
)
|
||||
'^[_a-zA-Z][a-zA-Z0-9_,:\"]*[a-zA-Z0-9_,\"]+$', re.UNICODE)
|
||||
id_re_num = re.compile('^[0-9,]+$', re.UNICODE)
|
||||
id_re_with_port = re.compile('^([^:]*):([^:]*)$', re.UNICODE)
|
||||
id_re_dbl_quoted = re.compile('^\".*\"$', re.S | re.UNICODE)
|
||||
@ -364,9 +363,7 @@ def graph_from_adjacency_matrix(matrix, node_prefix='', directed=False):
|
||||
graph.add_edge(
|
||||
Edge(
|
||||
node_prefix + node_orig,
|
||||
node_prefix + node_dest
|
||||
)
|
||||
)
|
||||
node_prefix + node_dest))
|
||||
node_dest += 1
|
||||
node_orig += 1
|
||||
|
||||
@ -402,9 +399,7 @@ def graph_from_incidence_matrix(matrix, node_prefix='', directed=False):
|
||||
graph.add_edge(
|
||||
Edge(
|
||||
node_prefix + abs(nodes[0]),
|
||||
node_prefix + nodes[1]
|
||||
)
|
||||
)
|
||||
node_prefix + nodes[1]))
|
||||
|
||||
if not directed:
|
||||
graph.set_simplify(True)
|
||||
@ -521,8 +516,7 @@ def find_graphviz():
|
||||
# this has a return value, which we should probably check
|
||||
ctypes.windll.advapi32.RegQueryValueExA(
|
||||
hkey, valuename, 0, ctypes.byref(data_type),
|
||||
data, ctypes.byref(data_len)
|
||||
)
|
||||
data, ctypes.byref(data_len))
|
||||
|
||||
return data.value
|
||||
|
||||
@ -537,15 +531,13 @@ def find_graphviz():
|
||||
hkey = None
|
||||
potentialKeys = [
|
||||
"SOFTWARE\\ATT\\Graphviz",
|
||||
"SOFTWARE\\AT&T Research Labs\\Graphviz"
|
||||
]
|
||||
"SOFTWARE\\AT&T Research Labs\\Graphviz"]
|
||||
for potentialKey in potentialKeys:
|
||||
|
||||
try:
|
||||
hkey = RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
potentialKey, 0, KEY_QUERY_VALUE
|
||||
)
|
||||
potentialKey, 0, KEY_QUERY_VALUE)
|
||||
|
||||
if hkey is not None:
|
||||
path = RegQueryValueEx(hkey, "InstallPath")
|
||||
@ -598,8 +590,7 @@ def find_graphviz():
|
||||
'/usr/bin', '/usr/local/bin',
|
||||
'/opt/local/bin',
|
||||
'/opt/bin', '/sw/bin', '/usr/share',
|
||||
'/Applications/Graphviz.app/Contents/MacOS/'
|
||||
):
|
||||
'/Applications/Graphviz.app/Contents/MacOS/'):
|
||||
|
||||
progs = __find_executables(path)
|
||||
if progs is not None:
|
||||
@ -705,8 +696,8 @@ class Common(object):
|
||||
# Generate all the Setter methods.
|
||||
self.__setattr__(
|
||||
'set_' + attr,
|
||||
lambda x, a=attr: self.obj_dict['attributes'].__setitem__(a, x)
|
||||
)
|
||||
lambda x, a=attr: self.obj_dict['attributes'].
|
||||
__setitem__(a, x))
|
||||
|
||||
# Generate all the Getter methods.
|
||||
self.__setattr__('get_' + attr,
|
||||
@ -1040,8 +1031,7 @@ class Graph(Common):
|
||||
if graph_type not in ['graph', 'digraph']:
|
||||
raise Error((
|
||||
'Invalid type "%s". Accepted graph types are: '
|
||||
'graph, digraph, subgraph' % graph_type
|
||||
))
|
||||
'graph, digraph, subgraph' % graph_type))
|
||||
|
||||
self.obj_dict['name'] = quote_if_necessary(graph_name)
|
||||
self.obj_dict['type'] = graph_type
|
||||
@ -1244,8 +1234,7 @@ class Graph(Common):
|
||||
match.extend([
|
||||
Node(obj_dict=obj_dict)
|
||||
for obj_dict
|
||||
in self.obj_dict['nodes'][name]
|
||||
])
|
||||
in self.obj_dict['nodes'][name]])
|
||||
|
||||
return match
|
||||
|
||||
@ -1265,8 +1254,7 @@ class Graph(Common):
|
||||
node_objs.extend([
|
||||
Node(obj_dict=obj_d)
|
||||
for obj_d
|
||||
in obj_dict_list
|
||||
])
|
||||
in obj_dict_list])
|
||||
|
||||
return node_objs
|
||||
|
||||
@ -1354,8 +1342,7 @@ class Graph(Common):
|
||||
|
||||
if edge_points in self.obj_dict['edges'] or (
|
||||
self.get_top_graph_type() == 'graph' and
|
||||
edge_points_reverse in self.obj_dict['edges']
|
||||
):
|
||||
edge_points_reverse in self.obj_dict['edges']):
|
||||
|
||||
edges_obj_dict = self.obj_dict['edges'].get(
|
||||
edge_points,
|
||||
@ -1383,8 +1370,7 @@ class Graph(Common):
|
||||
edge_objs.extend([
|
||||
Edge(obj_dict=obj_d)
|
||||
for obj_d
|
||||
in obj_dict_list
|
||||
])
|
||||
in obj_dict_list])
|
||||
|
||||
return edge_objs
|
||||
|
||||
@ -1450,8 +1436,7 @@ class Graph(Common):
|
||||
sgraph_objs.extend([
|
||||
Subgraph(obj_dict=obj_d)
|
||||
for obj_d
|
||||
in obj_dict_list
|
||||
])
|
||||
in obj_dict_list])
|
||||
|
||||
return sgraph_objs
|
||||
|
||||
@ -1525,8 +1510,7 @@ class Graph(Common):
|
||||
obj_list = sorted([
|
||||
(obj['sequence'], obj)
|
||||
for obj
|
||||
in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts)
|
||||
])
|
||||
in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts)])
|
||||
|
||||
for idx, obj in obj_list:
|
||||
if obj['type'] == 'node':
|
||||
@ -1663,8 +1647,7 @@ class Dot(Graph):
|
||||
'fig', 'gd', 'gd2', 'gif', 'hpgl', 'imap', 'imap_np', 'ismap',
|
||||
'jpe', 'jpeg', 'jpg', 'mif', 'mp', 'pcl', 'pdf', 'pic', 'plain',
|
||||
'plain-ext', 'png', 'ps', 'ps2', 'svg', 'svgz', 'vml', 'vmlz',
|
||||
'vrml', 'vtx', 'wbmp', 'xdot', 'xlib'
|
||||
]
|
||||
'vrml', 'vtx', 'wbmp', 'xdot', 'xlib']
|
||||
self.prog = 'dot'
|
||||
|
||||
# Automatically creates all the methods enabling the creation
|
||||
@ -1672,26 +1655,23 @@ class Dot(Graph):
|
||||
for frmt in self.formats:
|
||||
self.__setattr__(
|
||||
'create_' + frmt,
|
||||
lambda f=frmt, prog=self.prog: self.create(format=f, prog=prog)
|
||||
)
|
||||
lambda f=frmt, prog=self.prog:
|
||||
self.create(format=f, prog=prog))
|
||||
f = self.__dict__['create_' + frmt]
|
||||
f.__doc__ = (
|
||||
'''Refer to the docstring accompanying the'''
|
||||
''''create' method for more information.'''
|
||||
)
|
||||
''''create' method for more information.''')
|
||||
|
||||
for frmt in self.formats + ['raw']:
|
||||
self.__setattr__(
|
||||
'write_' + frmt,
|
||||
lambda path, f=frmt, prog=self.prog: self.write(path, format=f,
|
||||
prog=prog)
|
||||
)
|
||||
prog=prog))
|
||||
|
||||
f = self.__dict__['write_' + frmt]
|
||||
f.__doc__ = (
|
||||
'''Refer to the docstring accompanying the'''
|
||||
''''write' method for more information.'''
|
||||
)
|
||||
''''write' method for more information.''')
|
||||
|
||||
def __getstate__(self):
|
||||
return copy.copy(self.obj_dict)
|
||||
|
@ -57,8 +57,7 @@ class DefaultStatement(P_AttrList):
|
||||
def __repr__(self):
|
||||
return "%s(%s, %r)" % (
|
||||
self.__class__.__name__,
|
||||
self.default_type, self.attrs
|
||||
)
|
||||
self.default_type, self.attrs)
|
||||
|
||||
|
||||
top_graphs = list()
|
||||
@ -384,19 +383,18 @@ def graph_definition():
|
||||
closer = '>'
|
||||
html_text = pyparsing.nestedExpr(
|
||||
opener, closer,
|
||||
(pyparsing.CharsNotIn(opener + closer))
|
||||
).setParseAction(parse_html).leaveWhitespace()
|
||||
(pyparsing.CharsNotIn(opener + closer))).\
|
||||
setParseAction(parse_html).leaveWhitespace()
|
||||
|
||||
ID = (
|
||||
identifier | html_text |
|
||||
double_quoted_string |
|
||||
alphastring_
|
||||
).setName("ID")
|
||||
alphastring_).setName("ID")
|
||||
|
||||
float_number = pyparsing.Combine(
|
||||
pyparsing.Optional(minus) +
|
||||
pyparsing.OneOrMore(pyparsing.Word(pyparsing.nums + "."))
|
||||
).setName("float_number")
|
||||
pyparsing.OneOrMore(pyparsing.Word(pyparsing.nums + "."))).\
|
||||
setName("float_number")
|
||||
|
||||
righthand_id = (float_number | ID).setName("righthand_id")
|
||||
|
||||
@ -404,23 +402,23 @@ def graph_definition():
|
||||
|
||||
port_location = (
|
||||
pyparsing.OneOrMore(pyparsing.Group(colon + ID)) |
|
||||
pyparsing.Group(colon + lparen + ID + comma + ID + rparen)
|
||||
).setName("port_location")
|
||||
pyparsing.Group(colon + lparen + ID + comma + ID + rparen)).\
|
||||
setName("port_location")
|
||||
|
||||
port = (
|
||||
pyparsing.Group(port_location + pyparsing.Optional(port_angle)) |
|
||||
pyparsing.Group(port_angle + pyparsing.Optional(port_location))
|
||||
).setName("port")
|
||||
pyparsing.Group(port_angle + pyparsing.Optional(port_location))).\
|
||||
setName("port")
|
||||
|
||||
node_id = (ID + pyparsing.Optional(port))
|
||||
a_list = pyparsing.OneOrMore(
|
||||
ID + pyparsing.Optional(equals + righthand_id) +
|
||||
pyparsing.Optional(comma.suppress())
|
||||
).setName("a_list")
|
||||
pyparsing.Optional(comma.suppress())).\
|
||||
setName("a_list")
|
||||
|
||||
attr_list = pyparsing.OneOrMore(
|
||||
lbrack.suppress() + pyparsing.Optional(a_list) + rbrack.suppress()
|
||||
).setName("attr_list")
|
||||
lbrack.suppress() + pyparsing.Optional(a_list) +
|
||||
rbrack.suppress()).setName("attr_list")
|
||||
|
||||
attr_stmt = (pyparsing.Group(graph_ | node_ | edge_) + attr_list).\
|
||||
setName("attr_stmt")
|
||||
@ -431,8 +429,8 @@ def graph_definition():
|
||||
stmt_list = pyparsing.Forward()
|
||||
graph_stmt = pyparsing.Group(
|
||||
lbrace.suppress() + pyparsing.Optional(stmt_list) +
|
||||
rbrace.suppress() + pyparsing.Optional(semi.suppress())
|
||||
).setName("graph_stmt")
|
||||
rbrace.suppress() + pyparsing.Optional(semi.suppress())).\
|
||||
setName("graph_stmt")
|
||||
|
||||
edge_point = pyparsing.Forward()
|
||||
|
||||
@ -452,16 +450,16 @@ def graph_definition():
|
||||
assignment = (ID + equals + righthand_id).setName("assignment")
|
||||
stmt = (
|
||||
assignment | edge_stmt | attr_stmt |
|
||||
subgraph | graph_stmt | node_stmt
|
||||
).setName("stmt")
|
||||
subgraph | graph_stmt | node_stmt).\
|
||||
setName("stmt")
|
||||
stmt_list << pyparsing.OneOrMore(stmt + pyparsing.Optional(
|
||||
semi.suppress()))
|
||||
|
||||
graphparser = pyparsing.OneOrMore((
|
||||
pyparsing.Optional(strict_) +
|
||||
pyparsing.Group((graph_ | digraph_)) +
|
||||
pyparsing.Optional(ID) + graph_stmt
|
||||
).setResultsName("graph"))
|
||||
pyparsing.Optional(ID) + graph_stmt).
|
||||
setResultsName("graph"))
|
||||
|
||||
singleLineComment = (pyparsing.Group("//" + pyparsing.restOfLine) |
|
||||
pyparsing.Group("#" + pyparsing.restOfLine))
|
||||
|
9
setup.py
9
setup.py
@ -30,12 +30,9 @@ setup(
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Scientific/Engineering :: Visualization',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
],
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'],
|
||||
long_description=readme,
|
||||
packages=['pydot_ng'],
|
||||
package_dir={'pydot_ng': 'pydot_ng'},
|
||||
install_requires=[
|
||||
'pyparsing>=2.0.1',
|
||||
],
|
||||
)
|
||||
install_requires=['pyparsing>=2.0.1'],
|
||||
)
|
||||
|
@ -131,8 +131,7 @@ class TestGraphAPI(unittest.TestCase):
|
||||
pngs = [
|
||||
os.path.join(shapefile_dir, fname)
|
||||
for fname in os.listdir(shapefile_dir)
|
||||
if fname.endswith('.png')
|
||||
]
|
||||
if fname.endswith('.png')]
|
||||
|
||||
f = open(dot_file, 'rt')
|
||||
graph_data = f.read()
|
||||
@ -156,8 +155,7 @@ class TestGraphAPI(unittest.TestCase):
|
||||
(DOT_BINARY_PATH, '-Tjpe'),
|
||||
cwd=os.path.dirname(filename),
|
||||
stdin=open(filename, 'rt'),
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE
|
||||
)
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
|
||||
stdout = p.stdout
|
||||
|
||||
@ -195,8 +193,7 @@ class TestGraphAPI(unittest.TestCase):
|
||||
|
||||
dot_files = [
|
||||
fname for fname in os.listdir(directory)
|
||||
if fname.endswith('.dot')
|
||||
]
|
||||
if fname.endswith('.dot')]
|
||||
|
||||
for dot in dot_files:
|
||||
os.sys.stdout.write('#')
|
||||
|
Loading…
x
Reference in New Issue
Block a user