Skip to content
This repository was archived by the owner on Jul 15, 2019. It is now read-only.

Commit f027f60

Browse files
author
Anders Eurenius
committed
Add flake8 config and fix some style issues
1 parent 40d1dd4 commit f027f60

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

graphwalker/gml.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (c) 2013 Spotify AB
3-
"""Parser for GML files
3+
"""Parser for GML files.
44
5-
# http://www.fim.uni-passau.de/fileadmin/files/lehrstuhl/\
6-
brandenburg/projekte/gml/gml-technical-report.pdf
5+
# http://www.fim.uni-passau.de/fileadmin/files/lehrstuhl/brandenburg/projekte/gml/gml-technical-report.pdf
76
87
Grammar:
98
@@ -71,7 +70,7 @@ def build_vert(vl):
7170

7271

7372
def build_edge(el, serial):
74-
e_id, e_name, e_src, e_tgt = 'e%d' % serial, None, None, None
73+
e_id, e_name, e_src, e_tgt = 'e%d' % serial, None, None, None
7574

7675
for key, value in el:
7776
if key == 'label':

graphwalker/planning.py

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def __iter__(self):
9292

9393
class Random(EvenRandom):
9494
"""Walk through the graph by random edges until done."""
95+
9596
def choose_edge(self, edges):
9697
naive, weighted = [], []
9798
for e in edges:
@@ -131,6 +132,7 @@ def choose_edge(self, edges):
131132

132133
class Euler(Planner):
133134
"""Walk through the graph by ordered edges until done."""
135+
134136
def __call__(self, g, stop, start, context):
135137
self._setup(g, stop, start, context)
136138

@@ -186,6 +188,7 @@ def loop(vert):
186188

187189
class Goto(Planner):
188190
"""Plan direct path to goal state(s), repeating [repeat] times."""
191+
189192
def __init__(self, *al, **kw):
190193
self.al, self.kw = al, kw
191194
self.goals = self.al
@@ -226,6 +229,7 @@ class Interactive(Planner):
226229
The protocol between choose and iterplan is deliberately kept simple to
227230
keep it simple to replace the choose method.
228231
"""
232+
229233
raw_input = raw_input
230234
out = sys.stderr
231235
debugger = pdb.Pdb('\t', sys.stdin, sys.stderr)

graphwalker/reporting.py

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
class ReportingPlugin(object):
1414
"""Common (optional) base or example for Graphwalker reporting plugins."""
15+
1516
def __init__(self, **kw):
1617
self.context = kw
1718

@@ -51,6 +52,7 @@ def attach_to_step(self, name, data):
5152

5253
class Print(ReportingPlugin):
5354
"""Print report to [output]; 'stdout', 'stderr' or object with write()."""
55+
5456
outputs_map = {'stderr': sys.stderr, 'stdout': sys.stdout}
5557

5658
def initiate(self, test_name):
@@ -88,6 +90,7 @@ def emit(self, message):
8890

8991
class Log(Print):
9092
"""Log report to (name or object) [logger], at [level]."""
93+
9194
getLogger = staticmethod(logging.getLogger)
9295
levels = dict(
9396
(n, getattr(logging, n))
@@ -116,6 +119,7 @@ def emit(self, message, *al, **kw):
116119

117120
class PathRecorder(ReportingPlugin):
118121
"""Report steps to a file at [path]/[name], saving attachments by name."""
122+
119123
file = file
120124

121125
def __init__(self, **kw):
@@ -143,6 +147,7 @@ def finalize(self, failure=False):
143147

144148
class Cartographer(ReportingPlugin):
145149
"""Report graph and path steps to a graphviz file and run dot."""
150+
146151
file = file
147152
system = os.system
148153
command = 'dot -T%(imgtype)s -o %(imgfname)s %(dotfname)s'
@@ -176,6 +181,7 @@ def step_begin(self, step):
176181

177182
class Attachments(ReportingPlugin):
178183
"""Save attachments to [path]/name."""
184+
179185
file = file
180186

181187
def attach_to_suite(self, name, data):

graphwalker/stopcond.py

+5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ def progress(self):
2424

2525
class Never(StopCond):
2626
"""Never stop."""
27+
2728
pass
2829

2930

3031
class Seconds(StopCond):
3132
"""Stop after [timeout] (default: 30) seconds."""
33+
3234
clock = time.time
3335

3436
def __init__(self, *al, **kw):
@@ -50,6 +52,7 @@ def progress(self):
5052

5153
class SeenSteps(StopCond):
5254
"""Stop when all given vertices have been visited."""
55+
5356
def __init__(self, *al, **kw):
5457
self.targets = set(al)
5558

@@ -63,6 +66,7 @@ def progress(self):
6366

6467
class CountSteps(StopCond):
6568
"""Stop after [steps] steps."""
69+
6670
def __init__(self, *al, **kw):
6771
self.i, self.n = 0, int(al[0]) if al else kw.get('steps', 100)
6872

@@ -76,6 +80,7 @@ def add(self, thing):
7680

7781
class Coverage(StopCond):
7882
"""Stop after [vertices] or [edges] number of vertices/edges visited."""
83+
7984
def __init__(self, *al, **kw):
8085
kw['verts'] = kw.pop('vertices', kw.get('verts', 0))
8186
self.edge_cov = min(1.0, float(kw.get('edges', 0)) / 100.0)

graphwalker/test/interaction_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ def test_cli_models_with_actor(self):
3737
self.assertEqual(subprocess.call(argl), 0)
3838

3939
def test_by_interaction(self):
40-
"""Interaction self-test.
40+
r"""Interaction self-test.
4141
4242
For comparison, try this:
4343
44-
PYTHONPATH=. python graphwalker/cli.py --reporter=Print \\
45-
graphwalker/test/examples/selftest.graphml \\
44+
PYTHONPATH=. python graphwalker/cli.py --reporter=Print \
45+
graphwalker/test/examples/selftest.graphml \
4646
graphwalker.test.interactor.Interactor
4747
"""
4848
outer = self

setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = I100,Q000,D100,D101,D102,D103,D104,D105

0 commit comments

Comments
 (0)