Skip to content
Merged
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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ strict = 1
restructuredtext = 1

[flake8]
ignore=_
ignore = W504
copyright-check = True
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
requires = ['blockdiag>=1.5.0']
test_requires = ['nose',
'pep8>=1.3',
'flake8',
'flake8-coding',
'flake8-copyright',
'reportlab',
'docutils']

# only for Python2.6
if sys.version_info > (2, 6) and sys.version_info < (2, 7):
test_requires.append('unittest2')

if (3, 2) < sys.version_info < (3, 3):
requires.append('webcolors < 1.5') # webcolors-1.5 does not support py32

Expand Down
2 changes: 1 addition & 1 deletion src/nwdiag/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def set_attributes(self, network, attrs=None):

for attr in attrs:
if attr.name == 'address':
address = re.sub('\s*,\s*', '\n', unquote(attr.value))
address = re.sub(r'\s*,\s*', '\n', unquote(attr.value))
self.address[network] = address
else:
self.set_attribute(attr)
Expand Down
12 changes: 6 additions & 6 deletions src/nwdiag/tests/test_rst_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_setup_noviewbox_is_true(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg height="\d+" width="\d+" ')
self.assertRegexpMatches(svg, r'<svg height="\d+" width="\d+" ')

def test_setup_noviewbox_is_false(self):
directives.setup(format='SVG', outputdir=self.tmpdir, noviewbox=False)
Expand All @@ -166,7 +166,7 @@ def test_setup_noviewbox_is_false(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg viewBox="0 0 \d+ \d+" ')
self.assertRegexpMatches(svg, r'<svg viewBox="0 0 \d+ \d+" ')

def test_setup_inline_svg_is_true(self):
directives.setup(format='SVG', outputdir=self.tmpdir, inline_svg=True)
Expand Down Expand Up @@ -238,7 +238,7 @@ def test_setup_inline_svg_is_true_and_width_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="100" ')
r'<svg height="\d+" width="100" ')

def test_setup_inline_svg_is_true_and_width_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -255,7 +255,7 @@ def test_setup_inline_svg_is_true_and_width_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="10000" ')
r'<svg height="\d+" width="10000" ')

def test_setup_inline_svg_is_true_and_height_option1(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -272,7 +272,7 @@ def test_setup_inline_svg_is_true_and_height_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="100" width="\d+" ')
r'<svg height="100" width="\d+" ')

def test_setup_inline_svg_is_true_and_height_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -289,7 +289,7 @@ def test_setup_inline_svg_is_true_and_height_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="10000" width="\d+" ')
r'<svg height="10000" width="\d+" ')

def test_setup_inline_svg_is_true_and_width_and_height_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand Down
12 changes: 6 additions & 6 deletions src/packetdiag/tests/test_rst_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_setup_noviewbox_is_true(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg height="\d+" width="\d+" ')
self.assertRegexpMatches(svg, r'<svg height="\d+" width="\d+" ')

def test_setup_noviewbox_is_false(self):
directives.setup(format='SVG', outputdir=self.tmpdir, noviewbox=False)
Expand All @@ -152,7 +152,7 @@ def test_setup_noviewbox_is_false(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg viewBox="0 0 \d+ \d+" ')
self.assertRegexpMatches(svg, r'<svg viewBox="0 0 \d+ \d+" ')

def test_setup_inline_svg_is_true(self):
directives.setup(format='SVG', outputdir=self.tmpdir, inline_svg=True)
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_setup_inline_svg_is_true_and_width_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="100" ')
r'<svg height="\d+" width="100" ')

def test_setup_inline_svg_is_true_and_width_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -229,7 +229,7 @@ def test_setup_inline_svg_is_true_and_width_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="10000" ')
r'<svg height="\d+" width="10000" ')

def test_setup_inline_svg_is_true_and_height_option1(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -244,7 +244,7 @@ def test_setup_inline_svg_is_true_and_height_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="100" width="\d+" ')
r'<svg height="100" width="\d+" ')

def test_setup_inline_svg_is_true_and_height_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -259,7 +259,7 @@ def test_setup_inline_svg_is_true_and_height_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="10000" width="\d+" ')
r'<svg height="10000" width="\d+" ')

def test_setup_inline_svg_is_true_and_width_and_height_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand Down
10 changes: 5 additions & 5 deletions src/rackdiag/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def display_label(self):
return u("\n").join(labels)

def set_attribute(self, attr):
if re.search('^\d+U$', attr.name):
if re.search(r'^\d+U$', attr.name):
self.colheight = int(attr.name[:-1])
elif re.search('^\d+(\.[0-9]+)?A$', attr.name):
elif re.search(r'^\d+(\.[0-9]+)?A$', attr.name):
self.ampere = float(attr.name[:-1])
elif re.search('^\d+(\.[0-9]+)?kg$', attr.name):
elif re.search(r'^\d+(\.[0-9]+)?kg$', attr.name):
self.weight = float(attr.name[:-2])
else:
return super(RackItem, self).set_attribute(attr)
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_linked_levels(self, level):
def get_max_height(self, y):
try:
return max(n.colheight for n in self.items(y))
except:
except Exception:
return 0

height = get_max_height(self, level)
Expand Down Expand Up @@ -199,7 +199,7 @@ def set_ascending(self, attr):
self.descending = False

def set_attribute(self, attr):
if re.search('^\d+U$', attr.name):
if re.search(r'^\d+U$', attr.name):
self.colheight = int(attr.name[:-1])
else:
return super(Rack, self).set_attribute(attr)
Expand Down
12 changes: 6 additions & 6 deletions src/rackdiag/tests/test_rst_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_setup_noviewbox_is_true(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg height="\d+" width="\d+" ')
self.assertRegexpMatches(svg, r'<svg height="\d+" width="\d+" ')

def test_setup_noviewbox_is_false(self):
directives.setup(format='SVG', outputdir=self.tmpdir, noviewbox=False)
Expand All @@ -152,7 +152,7 @@ def test_setup_noviewbox_is_false(self):
self.assertEqual(1, len(doctree))
self.assertEqual(nodes.image, type(doctree[0]))
svg = open(doctree[0]['uri']).read()
self.assertRegexpMatches(svg, '<svg viewBox="0 0 \d+ \d+" ')
self.assertRegexpMatches(svg, r'<svg viewBox="0 0 \d+ \d+" ')

def test_setup_inline_svg_is_true(self):
directives.setup(format='SVG', outputdir=self.tmpdir, inline_svg=True)
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_setup_inline_svg_is_true_and_width_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="100" ')
r'<svg height="\d+" width="100" ')

def test_setup_inline_svg_is_true_and_width_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -229,7 +229,7 @@ def test_setup_inline_svg_is_true_and_width_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="\d+" width="10000" ')
r'<svg height="\d+" width="10000" ')

def test_setup_inline_svg_is_true_and_height_option1(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -244,7 +244,7 @@ def test_setup_inline_svg_is_true_and_height_option1(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="100" width="\d+" ')
r'<svg height="100" width="\d+" ')

def test_setup_inline_svg_is_true_and_height_option2(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand All @@ -259,7 +259,7 @@ def test_setup_inline_svg_is_true_and_height_option2(self):
self.assertEqual(nodes.raw, type(doctree[0]))
self.assertEqual(nodes.Text, type(doctree[0][0]))
self.assertRegexpMatches(doctree[0][0],
'<svg height="10000" width="\d+" ')
r'<svg height="10000" width="\d+" ')

def test_setup_inline_svg_is_true_and_width_and_height_option(self):
directives.setup(format='SVG', outputdir=self.tmpdir,
Expand Down
23 changes: 7 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
[tox]
envlist=py26,py27,py32,py33,py34,blockdiag_dev
envlist=py27,py32,py33,py34,blockdiag_dev

[testenv]
usedevelop = True
extras =
pdf
rst
testing
deps=
nose
flake8
flake8-coding
flake8-copyright
docutils
reportlab
passenv=
ALL_TESTS
commands=
nosetests
flake8 src


[testenv:py26]
deps=
nose
flake8
docutils
reportlab
unittest2

[testenv:blockdiag_dev]
deps=
{[testenv]deps}
hg+https://bitbucket.org/blockdiag/blockdiag
git+https://github.com/blockdiag/blockdiag.git