Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] autopep8 -aa --experimental # 1.5.7 pycodestyle 2.7.0 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dot_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def __init__(self, toks):

while i < len(toks):
attrname = toks[i]
if i+2 < len(toks) and toks[i+1] == '=':
attrvalue = toks[i+2]
if i + 2 < len(toks) and toks[i + 1] == '=':
attrvalue = toks[i + 2]
i += 3
else:
attrvalue = None
Expand Down Expand Up @@ -221,7 +221,7 @@ def add_elements(g, toks, defaults_graph=None,
else:
raise ValueError(
'Unknown DefaultStatement: {s}'.format(
s=element.default_type))
s=element.default_type))

elif isinstance(element, P_AttrList):

Expand Down Expand Up @@ -290,7 +290,7 @@ def get_port(node):
def do_node_ports(node):
node_port = ''
if len(node) > 1:
node_port = ''.join([str(a)+str(b) for a, b in node[1]])
node_port = ''.join([str(a) + str(b) for a, b in node[1]])

return node_port

Expand All @@ -314,7 +314,7 @@ def push_edge_stmt(str, loc, toks):
n_next_list = [[n.get_name(), ] for n in toks[2][0]]
for n_next in [n for n in n_next_list]:
n_next_port = do_node_ports(n_next)
e.append(pydot.Edge(n_prev, n_next[0]+n_next_port, **attrs))
e.append(pydot.Edge(n_prev, n_next[0] + n_next_port, **attrs))

elif isinstance(toks[2][0], pydot.Graph):

Expand Down Expand Up @@ -343,9 +343,9 @@ def push_edge_stmt(str, loc, toks):
continue

n_next_port = do_node_ports(n_next)
e.append(pydot.Edge(n_prev, n_next[0]+n_next_port, **attrs))
e.append(pydot.Edge(n_prev, n_next[0] + n_next_port, **attrs))

n_prev = n_next[0]+n_next_port
n_prev = n_next[0] + n_next_port
else:
raise Exception(
'Edge target {r} with type {s} unsupported.'.format(
Expand Down
32 changes: 16 additions & 16 deletions pydot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'shape', 'shapefile', 'showboxes', 'sides', 'skew', 'sortv', 'style',
'target', 'tooltip', 'vertices', 'width', 'z',
# The following are attributes dot2tex
'texlbl', 'texmode'
'texlbl', 'texmode'
}


Expand Down Expand Up @@ -370,7 +370,7 @@ def graph_from_adjacency_matrix(matrix, node_prefix=u'', directed=False):
else:
skip = 0
r = row
node_dest = skip+1
node_dest = skip + 1

for e in r:
if e:
Expand Down Expand Up @@ -403,7 +403,7 @@ def graph_from_incidence_matrix(matrix, node_prefix='', directed=False):

for node in row:
if node:
nodes.append(c*node)
nodes.append(c * node)
c += 1
nodes.sort()

Expand Down Expand Up @@ -518,15 +518,15 @@ def create_attribute_methods(self, obj_attributes):
# Generate all the Setter methods.
#
self.__setattr__(
'set_'+attr,
'set_' + attr,
lambda x, a=attr:
self.obj_dict['attributes'].__setitem__(a, x)
)

# Generate all the Getter methods.
#
self.__setattr__(
'get_'+attr, lambda a=attr: self.__get_attribute__(a)
'get_' + attr, lambda a=attr: self.__get_attribute__(a)
)


Expand Down Expand Up @@ -593,7 +593,7 @@ def __init__(self, name='', obj_dict=None, **attrs):
port = None
if isinstance(name, str_type) and not name.startswith('"'):
idx = name.find(':')
if idx > 0 and idx+1 < len(name):
if idx > 0 and idx + 1 < len(name):
name, port = name[:idx], name[idx:]

if isinstance(name, int):
Expand Down Expand Up @@ -778,12 +778,12 @@ def parse_node_ref(self, node_str):
node_port_idx = node_str.rfind(':')

if (node_port_idx > 0 and node_str[0] == '"' and
node_str[node_port_idx-1] == '"'):
node_str[node_port_idx - 1] == '"'):
return node_str

if node_port_idx > 0:
a = node_str[:node_port_idx]
b = node_str[node_port_idx+1:]
b = node_str[node_port_idx + 1:]

node = quote_if_necessary(a)
node += ':' + quote_if_necessary(b)
Expand Down Expand Up @@ -1424,7 +1424,7 @@ def to_string(self):

else:
sgraph = Subgraph(obj_dict=obj)
graph.append(sgraph.to_string()+'\n')
graph.append(sgraph.to_string() + '\n')

graph.append('}\n')

Expand Down Expand Up @@ -1522,7 +1522,7 @@ def __init__(self, graph_name='subG',
if obj_dict is None:

self.obj_dict['type'] = 'subgraph'
self.obj_dict['name'] = quote_if_necessary('cluster_'+graph_name)
self.obj_dict['name'] = quote_if_necessary('cluster_' + graph_name)

self.create_attribute_methods(CLUSTER_ATTRIBUTES)

Expand Down Expand Up @@ -1565,7 +1565,7 @@ def new_method(
name = 'create_{fmt}'.format(fmt=frmt)
self.__setattr__(name, new_method)

for frmt in self.formats+['raw']:
for frmt in self.formats + ['raw']:
def new_method(
path, f=frmt, prog=self.prog,
encoding=None):
Expand Down Expand Up @@ -1776,11 +1776,11 @@ def create(self, prog=None, format='ps', encoding=None):
print(message)

assert process.returncode == 0, (
'"{prog}" with args {arguments} returned code: {code}'.format(
prog=prog,
arguments=arguments,
code=process.returncode,
)
'"{prog}" with args {arguments} returned code: {code}'.format(
prog=prog,
arguments=arguments,
code=process.returncode,
)
)

return stdout_data
14 changes: 7 additions & 7 deletions test/pydot_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,22 @@ def test_names_of_a_thousand_nodes(self):

def test_executable_not_found_exception(self):
graph = pydot.Dot('graphname', graph_type='digraph')
self.assertRaises(Exception, graph.create, prog='dothehe')
self.assertRaises(Exception, graph.create, prog='dothehe')

def test_graph_add_node_argument_type(self):
self._reset_graphs()
self.assertRaises(TypeError, self.graph_directed.add_node, 1)
self.assertRaises(TypeError, self.graph_directed.add_node, 'a')
self.assertRaises(TypeError, self.graph_directed.add_node, 1)
self.assertRaises(TypeError, self.graph_directed.add_node, 'a')

def test_graph_add_edge_argument_type(self):
self._reset_graphs()
self.assertRaises(TypeError, self.graph_directed.add_edge, 1)
self.assertRaises(TypeError, self.graph_directed.add_edge, 'a')
self.assertRaises(TypeError, self.graph_directed.add_edge, 1)
self.assertRaises(TypeError, self.graph_directed.add_edge, 'a')

def test_graph_add_subgraph_argument_type(self):
self._reset_graphs()
self.assertRaises(TypeError, self.graph_directed.add_subgraph, 1)
self.assertRaises(TypeError, self.graph_directed.add_subgraph, 'a')
self.assertRaises(TypeError, self.graph_directed.add_subgraph, 1)
self.assertRaises(TypeError, self.graph_directed.add_subgraph, 'a')

def test_quoting(self):
g = pydot.Dot()
Expand Down