Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcw committed Feb 7, 2014
1 parent 3e6ba85 commit 06c3652
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
source = src/bobbytemplates/openbsd
source = src/bobbytemplates/openbsd
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
/.coverage
/htmlcov
/docs/build/
/build/
/build/
2 changes: 1 addition & 1 deletion .pep8
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ignore = E501
# E123: closnig bracket must match indent of starting bracket
# E127 continuation line over-indented for visual indent
# E501 line too long (82 characters)
# E128 continuation line indentation
# E128 continuation line indentation
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ script:
- make test -k
after_success:
- easy_install coveralls
- coveralls
- coveralls
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include *.txt *.cfg *.rst
recursive-include docs *
recursive-include src *

global-exclude *pyc .DS_Store .installed.cfg
global-exclude *pyc .DS_Store .installed.cfg
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ nosetests:

flake8:
@echo "==== Running Flake8 ===="
@flake8 src/bobbytemplates *.py
@flake8 src/bobbytemplates *.py
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ bobbytemplates.openbsd is continuously


.. |coveralls| image:: https://coveralls.io/repos/jpcw/bobbytemplates.openbsd/badge.png
.. _coveralls: https://coveralls.io/r/jpcw/bobbytemplates.openbsd
.. _coveralls: https://coveralls.io/r/jpcw/bobbytemplates.openbsd

2 changes: 1 addition & 1 deletion docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Changelog
0.1-dev (unreleased)
------------------------

- Jean-Philippe Camguilhem <jpcw@camguilhem.net>
- Jean-Philippe Camguilhem <jpcw@camguilhem.net>
2 changes: 1 addition & 1 deletion docs/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contributors
==============

Jean-Philippe Camguilhem, Author
Jean-Philippe Camguilhem, Author
2 changes: 1 addition & 1 deletion docs/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ linkcheck:
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
"results in $(BUILDDIR)/doctest/output.txt."
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@
#epub_tocdepth = 3

# Allow duplicate toc entries.
#epub_tocdup = True
#epub_tocdup = True
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Welcome to bobbytemplates.openbsd's documentation!
Indices and tables
==================

* :ref:`search`
* :ref:`search`

3 changes: 2 additions & 1 deletion docs/source/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ do::

mrbobby Documentation
*********************
more infos on mrbobby http://mrbobby.readthedocs.org/
more infos on mrbobby http://mrbobby.readthedocs.org/

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ match=^test
with-coverage=1
cover-package=bobbytemplates.jpcw
cover-min-percentage=100
cover-erase=1
cover-erase=1
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def read_file(*pathes):

long_description = '\n\n'.join([read_file(*pathes) for pathes in desc_files])

install_requires = ['setuptools', 'six>=1.2.0', 'mr.bobby', 'bobbyplugins.jpcw', 'IPy']
install_requires = ['setuptools', 'six>=1.2.0', 'mr.bobby',
'bobbyplugins.jpcw', 'IPy']


setup(name='bobbytemplates.openbsd',
Expand All @@ -33,14 +34,15 @@ def read_file(*pathes):
# Get more strings from
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=["Programming Language :: Python",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"License :: OSI Approved :: BSD License"],
"Programming Language :: Python :: Implementation"
" :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"License :: OSI Approved :: BSD License"],
keywords='templates mrbobby openbsd',
author='Jean-Philippe Camguilhem',
author_email='jpcw@camguilhem.net',
Expand Down Expand Up @@ -68,4 +70,4 @@ def read_file(*pathes):
""",
)

# vim:set et sts=4 ts=4 tw=80:
# vim:set et sts=4 ts=4 tw=80:
2 changes: 1 addition & 1 deletion src/bobbytemplates/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__('pkg_resources').declare_namespace(__name__)
2 changes: 1 addition & 1 deletion src/bobbytemplates/openbsd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

__docformat__ = 'restructuredtext en'

# vim:set et sts=4 ts=4 tw=80:
# vim:set et sts=4 ts=4 tw=80:
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
inet {{{ ip }}} {{{ netmask }}} {{{ broadcast }}} vhid {{{ vhid }}} carpdev {{{ carpdev }}} pass {{{ password }}} group {{{ carp_group }}} description "{{{ description }}}"
# subnet : {{{ subnet }}}
# subnet : {{{ subnet }}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vlandev {{{ physdev }}}
vlandev {{{ physdev }}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
inet {{{ ip }}} {{{ netmask }}} {{{ broadcast }}} vhid {{{ vhid }}} carpdev {{{ carpdev }}} advskew {{{ advskew }}} pass {{{ password }}} group {{{ carp_group }}} description "{{{ description }}}"
# subnet : {{{ subnet }}}
# subnet : {{{ subnet }}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vlandev {{{ physdev }}}
vlandev {{{ physdev }}}
2 changes: 1 addition & 1 deletion src/bobbytemplates/openbsd/carp_iface/.mrbobby.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ slave.required = True

carp_group.question = carp_group hostname
carp_group.help = carp_group hostname
carp_group.required = True
carp_group.required = True
23 changes: 16 additions & 7 deletions src/bobbytemplates/openbsd/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def within_intervall(str_value, name, lower_bound=1, upper_bound=255):
if answer.isdigit():
value = int(answer)
if value not in range(lower_bound, upper_bound + 1):
raise ValidationError("{0} Acceptable values for {1} are from {2} to {3}".format(answer, name, lower_bound, upper_bound))
msg = "{0} Acceptable values for {1} are from {2} to {3}"
raise ValidationError(msg.format(answer, name, lower_bound,
upper_bound))

else:
raise ValidationError("{0} is not a valid number".format(answer))
Expand All @@ -43,21 +45,26 @@ def post_ask_q_carp_iface_cidr(configurator, question, answer):

try:
if answer.count('/') != 1:
raise ValidationError("'{0}' Plz input a cidr subnet notation here".format(answer))
msg = "'{0}' Plz input a cidr subnet notation here"
raise ValidationError(msg.format(answer))
ip, netmask = answer.split('/')
subnet = IP(answer, make_net=True)
if netmask not in ['32', '128']:
# we accept network ip only with /32 or /128
if is_a_network_address(answer):
raise ValidationError("'{0}': oO you provided a network address, within not in [/32 or /128] !".format(answer))
msg = "'{0}': oO you provided a network address,"\
" within not in [/32 or /128] !"
raise ValidationError(msg.format(answer))
net_vars['subnet'] = '%s/%s' % (str(subnet.net()), netmask)
net_vars['netmask'] = str(subnet.netmask())
net_vars['broadcast'] = str(subnet.broadcast())
net_vars['ip'] = ip
if netmask not in ['32', '128', '31', '127']:
# we accept broadcast ip only with /32, /128, /31, /127
if net_vars['ip'] == net_vars['broadcast']:
raise ValidationError("'{0}': oO you provided a broadcast ip within not in [/32, /128, /31, /127]".format(answer))
msg = "'{0}': oO you provided a broadcast ip within"\
" not in [/32, /128, /31, /127]"
raise ValidationError(msg.format(answer))

except ValidationError as e:
raise(e)
Expand Down Expand Up @@ -95,12 +102,14 @@ def post_ask_q_carp_iface_vlan(configurator, question, answer):
vlanid = within_intervall(answer, 'vlan', 1, 4094)
if vlanid:
configurator.variables['carpdev'] = 'vlan%s' % vlanid
configurator.variables['vlandev'] = configurator.variables['physdev']
vlandev = configurator.variables['physdev']
configurator.variables['vlandev'] = vlandev
configurator.variables['rdr_vlan'] = True
return vlanid

else:
configurator.variables['carpdev'] = configurator.variables['physdev']
carpdev = configurator.variables['physdev']
configurator.variables['carpdev'] = carpdev
configurator.variables['rdr_vlan'] = False
return False

Expand All @@ -112,4 +121,4 @@ def carp_iface_pre_render(configurator):
def carp_iface_post_render(configurator):
"""post render stuff."""

# vim:set et sts=4 ts=4 tw=80:
# vim:set et sts=4 ts=4 tw=80:
2 changes: 1 addition & 1 deletion src/bobbytemplates/openbsd/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
# vim:set et sts=4 ts=4 tw=80:
# vim:set et sts=4 ts=4 tw=80:
17 changes: 11 additions & 6 deletions src/bobbytemplates/openbsd/tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Post_ask_q_carp_iface_cidrTest(TestCase):

def call_FUT(self, answer, configurator=None, question=None):
from ..hooks import post_ask_q_carp_iface_cidr
return post_ask_q_carp_iface_cidr(DummyConfigurator(), question, answer)
return post_ask_q_carp_iface_cidr(DummyConfigurator(), question,
answer)

def test_post_ask_q_carp_iface_cidr(self):
from mrbobby.bobbyexceptions import ValidationError
Expand All @@ -60,7 +61,8 @@ class Post_ask_q_carp_iface_advskewTest(TestCase):

def call_FUT(self, answer, configurator=None, question=None):
from ..hooks import post_ask_q_carp_iface_advskew
return post_ask_q_carp_iface_advskew(DummyConfigurator(), question, answer)
return post_ask_q_carp_iface_advskew(DummyConfigurator(), question,
answer)

def test_post_ask_q_carp_iface_advskew(self):
from mrbobby.bobbyexceptions import ValidationError
Expand All @@ -74,7 +76,8 @@ class Post_ask_q_carp_iface_vlanTest(TestCase):

def call_FUT(self, answer, configurator=None, question=None):
from ..hooks import post_ask_q_carp_iface_vlan
return post_ask_q_carp_iface_vlan(DummyConfigurator(), question, answer)
return post_ask_q_carp_iface_vlan(DummyConfigurator(), question,
answer)

def test_post_ask_q_carp_iface_vlan(self):
from mrbobby.bobbyexceptions import ValidationError
Expand All @@ -87,7 +90,8 @@ class Post_ask_q_carp_iface_descriptionTest(TestCase):

def call_FUT(self, answer, configurator=None, question=None):
from ..hooks import post_ask_q_carp_iface_description
return post_ask_q_carp_iface_description(DummyConfigurator(), question, answer)
return post_ask_q_carp_iface_description(DummyConfigurator(), question,
answer)

def test_post_ask_q_carp_iface_description(self):
from string import ascii_letters
Expand All @@ -105,12 +109,13 @@ def setUp(self):
def call_FUT(self, answer, configurator=None, question=None):
from mrbobby.configurator import Configurator
from ..hooks import post_ask_q_carp_iface_vhid
return post_ask_q_carp_iface_vhid(Configurator(self.fs_templates, '', {}), question, answer)
return post_ask_q_carp_iface_vhid(Configurator(self.fs_templates, '',
{}), question, answer)

def test_post_ask_q_carp_iface_vhid(self):
from mrbobby.bobbyexceptions import ValidationError
self.assertRaises(ValidationError, self.call_FUT, 'test')
self.assertRaises(ValidationError, self.call_FUT, '0')
self.assertEquals(self.call_FUT('255'), '255')

# vim:set et sts=4 ts=4 tw=80:
# vim:set et sts=4 ts=4 tw=80:

0 comments on commit 06c3652

Please sign in to comment.