Skip to content

Commit c2ca09b

Browse files
author
afabiani
committed
- preparing for test suite / introducing pep8 format checks
1 parent 14dfecf commit c2ca09b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1944
-1490
lines changed

autopep8.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
autopep8 -v -i -a -a -r *.py
5+
autopep8 -v -i -a -a -r src
6+
autopep8 -v -i -a -a -r test

flake8.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
flake8 *.py
5+
flake8 src/wpsremote
6+
flake8 test

requirements.txt

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
asn1crypto==0.24.0
12
astroid==1.4.4
3+
autopep8==1.4.3
4+
bcrypt==3.1.4
5+
cffi==1.11.5
26
colorama==0.3.6
7+
cryptography==2.3.1
8+
enum34==1.1.6
39
flake8==2.5.4
410
functools32==3.2.3.post2
11+
idna==2.7
12+
ipaddress==1.0.22
513
jsonschema==2.5.1
614
lazy-object-proxy==1.2.1
715
mccabe==0.4.0
8-
pep8==1.7.0
9-
psutil==4.0.0
16+
paramiko==2.4.1
17+
pep8==1.7.1
18+
psutil==5.4.7
19+
pyasn1==0.4.4
20+
pycodestyle==2.4.0
21+
pycparser==2.18
22+
pycrypto==2.6.1
1023
pyflakes==1.0.0
1124
pylint==1.5.4
25+
PyNaCl==1.2.1
1226
six==1.10.0
13-
sleekxmpp==1.3.1
14-
wheel==0.24.0
15-
wrapt==1.10.6
27+
sleekxmpp==1.3.3
28+
wrapt==1.10.10

setup.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[metadata]
22
description-file = README.md
3+
4+
[flake8]
5+
max-line-length = 120
6+
exclude=management,scripts,docs,static
7+
ignore=E121,E122,E124,E126,E226

setup.py

+32-37
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,38 @@
2424
python setup.py bdist --format=gztar upload -r pypi
2525
python setup.py bdist_wheel upload -r pypi
2626
"""
27-
from setuptools import setup, find_packages
27+
try: # for pip >= 10
28+
from pip._internal.req import parse_requirements
29+
from pip._internal.download import PipSession
30+
except ImportError: # for pip <= 9.0.3
31+
from pip.req import parse_requirements
32+
from pip.download import PipSession
33+
from distutils.core import setup
34+
35+
from setuptools import find_packages
36+
37+
# Parse requirements.txt to get the list of dependencies
38+
inst_req = parse_requirements('requirements.txt',
39+
session=PipSession())
40+
REQUIREMENTS = [str(r.req) for r in inst_req]
2841

2942
try:
3043
readme_text = file('README.md', 'rb').read()
31-
except IOError,e:
44+
except IOError as e:
3245
readme_text = ''
3346

3447
setup(
35-
name = "wps-remote",
36-
version = "2.15.0",
37-
author = "GeoServer Developers",
38-
author_email = "[email protected]",
39-
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",
40-
keywords = "XMPP Beckend for GeoServer Remote WPS ProcessFactory.",
41-
long_description = readme_text,
42-
license = "GPL",
43-
url = "https://github.com/geoserver/wps-remote",
44-
#https://pypi.python.org/pypi?%3Aaction=list_classifiers
45-
classifiers = [
48+
name="wps-remote",
49+
version="2.15.0",
50+
author="GeoServer Developers",
51+
author_email="[email protected]",
52+
description="A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol", # noqa
53+
keywords="XMPP Beckend for GeoServer Remote WPS ProcessFactory.",
54+
long_description=readme_text,
55+
license="GPL",
56+
url="https://github.com/geoserver/wps-remote",
57+
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
58+
classifiers=[
4659
'Environment :: Web Environment',
4760
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
4861
'Intended Audience :: Developers',
@@ -51,9 +64,9 @@
5164
'Programming Language :: Python',
5265
'Topic :: Scientific/Engineering :: GIS',
5366
],
54-
package_dir = {'':'src'},
55-
packages = find_packages('src'),
56-
package_data = {
67+
package_dir={'': 'src'},
68+
packages=find_packages('src'),
69+
package_data={
5770
'': [
5871
'xmpp_data/*.*',
5972
'xmpp_data/configs/*.*',
@@ -67,25 +80,7 @@
6780
'xmpp_data/test/*.*',
6881
]
6982
},
70-
include_package_data = True,
71-
test_suite = "test",
72-
install_requires = [
73-
"astroid==1.4.4",
74-
"colorama==0.3.6",
75-
"flake8==2.5.4",
76-
"functools32",
77-
"jsonschema==2.5.1",
78-
"lazy-object-proxy==1.2.1",
79-
"mccabe==0.4.0",
80-
"paramiko",
81-
"pep8==1.7.0",
82-
"psutil>=4.0.0",
83-
"pycrypto",
84-
"pyflakes==1.0.0",
85-
"pylint==1.5.4",
86-
"six==1.10.0",
87-
"sleekxmpp>=1.3.1",
88-
"wheel==0.24.0",
89-
"wrapt==1.10.10",
90-
],
83+
include_package_data=True,
84+
test_suite="test",
85+
install_requires=REQUIREMENTS,
9186
)

src/wpsremote/ConfigParser.py

+23-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# This code is licensed under the GPL 2.0 license, available at the root
55
# application directory.
66

7+
import re
8+
import UserDict as _UserDict
9+
710
__author__ = "Alessio Fabiani"
811
__copyright__ = "Copyright 2016 Open Source Geospatial Foundation - all rights reserved"
912
__license__ = "GPL"
@@ -103,8 +106,6 @@
103106
# fallback for setup.py which hasn't yet built _collections
104107
_default_dict = dict
105108

106-
import re
107-
108109
__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
109110
"InterpolationError", "InterpolationDepthError",
110111
"InterpolationSyntaxError", "ParsingError",
@@ -117,7 +118,6 @@
117118
MAX_INTERPOLATION_DEPTH = 10
118119

119120

120-
121121
# exception classes
122122
class Error(Exception):
123123
"""Base class for ConfigParser exceptions."""
@@ -146,6 +146,7 @@ def __repr__(self):
146146

147147
__str__ = __repr__
148148

149+
149150
class NoSectionError(Error):
150151
"""Raised when no section matches a requested option."""
151152

@@ -154,6 +155,7 @@ def __init__(self, section):
154155
self.section = section
155156
self.args = (section, )
156157

158+
157159
class DuplicateSectionError(Error):
158160
"""Raised when a section is multiply-created."""
159161

@@ -162,6 +164,7 @@ def __init__(self, section):
162164
self.section = section
163165
self.args = (section, )
164166

167+
165168
class NoOptionError(Error):
166169
"""A requested option was not found."""
167170

@@ -172,6 +175,7 @@ def __init__(self, option, section):
172175
self.section = section
173176
self.args = (option, section)
174177

178+
175179
class InterpolationError(Error):
176180
"""Base class for interpolation-related exceptions."""
177181

@@ -181,6 +185,7 @@ def __init__(self, option, section, msg):
181185
self.section = section
182186
self.args = (option, section, msg)
183187

188+
184189
class InterpolationMissingOptionError(InterpolationError):
185190
"""A string substitution required a setting which was not available."""
186191

@@ -195,10 +200,12 @@ def __init__(self, option, section, rawval, reference):
195200
self.reference = reference
196201
self.args = (option, section, rawval, reference)
197202

203+
198204
class InterpolationSyntaxError(InterpolationError):
199205
"""Raised when the source text into which substitutions are made
200206
does not conform to the required syntax."""
201207

208+
202209
class InterpolationDepthError(InterpolationError):
203210
"""Raised when substitutions are nested too deeply."""
204211

@@ -211,6 +218,7 @@ def __init__(self, option, section, rawval):
211218
InterpolationError.__init__(self, option, section, msg)
212219
self.args = (option, section, rawval)
213220

221+
214222
class ParsingError(Error):
215223
"""Raised when a configuration file does not follow legal syntax."""
216224

@@ -224,6 +232,7 @@ def append(self, lineno, line):
224232
self.errors.append((lineno, line))
225233
self.message += '\n\t[line %2d]: %s' % (lineno, line)
226234

235+
227236
class MissingSectionHeaderError(ParsingError):
228237
"""Raised when a key-value pair is found before any section header."""
229238

@@ -268,7 +277,7 @@ def add_section(self, section):
268277
case-insensitive variants.
269278
"""
270279
if section.lower() == "default":
271-
raise ValueError, 'Invalid section name: %s' % section
280+
raise ValueError('Invalid section name: %s' % section)
272281

273282
if section in self._sections:
274283
raise DuplicateSectionError(section)
@@ -377,7 +386,7 @@ def getfloat(self, section, option):
377386
def getboolean(self, section, option):
378387
v = self.get(section, option)
379388
if v.lower() not in self._boolean_states:
380-
raise ValueError, 'Not a boolean: %s' % v
389+
raise ValueError('Not a boolean: %s' % v)
381390
return self._boolean_states[v.lower()]
382391

383392
def optionxform(self, optionstr):
@@ -392,8 +401,8 @@ def has_option(self, section, option):
392401
return False
393402
else:
394403
option = self.optionxform(option)
395-
return (option in self._sections[section]
396-
or option in self._defaults)
404+
return (option in self._sections[section] or
405+
option in self._defaults)
397406

398407
def set(self, section, option, value=None):
399408
"""Set an option."""
@@ -452,15 +461,15 @@ def remove_section(self, section):
452461
r'\[' # [
453462
r'(?P<header>[^]]+)' # very permissive!
454463
r'\]' # ]
455-
)
464+
)
456465
OPTCRE = re.compile(
457466
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
458467
r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
459468
# followed by separator
460469
# (either : or =), followed
461470
# by any # space/tab
462471
r'(?P<value>.*)$' # everything up to eol
463-
)
472+
)
464473
OPTCRE_NV = re.compile(
465474
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
466475
r'\s*(?:' # any number of space/tab,
@@ -469,7 +478,7 @@ def remove_section(self, section):
469478
# =), followed by any #
470479
# space/tab
471480
r'(?P<value>.*))?$' # everything up to eol
472-
)
481+
)
473482

474483
def _read(self, fp, fpname):
475484
"""Parse a sectioned setup file.
@@ -563,7 +572,6 @@ def _read(self, fp, fpname):
563572
if isinstance(val, list):
564573
options[name] = '\n'.join(val)
565574

566-
import UserDict as _UserDict
567575

568576
class _Chainmap(_UserDict.DictMixin):
569577
"""Combine multiple mappings for successive lookups.
@@ -595,6 +603,7 @@ def keys(self):
595603
seen.add(key)
596604
return result
597605

606+
598607
class ConfigParser(RawConfigParser):
599608

600609
def get(self, section, option, raw=False, vars=None):
@@ -674,7 +683,7 @@ def _interpolate(self, section, option, rawval, vars):
674683
value = self._KEYCRE.sub(self._interpolation_replace, value)
675684
try:
676685
value = value % vars
677-
except KeyError, e:
686+
except KeyError as e:
678687
raise InterpolationMissingOptionError(
679688
option, section, rawval, e.args[0])
680689
else:
@@ -723,7 +732,7 @@ def _interpolate_some(self, option, accum, rest, section, map, depth):
723732
m = self._interpvar_re.match(rest)
724733
if m is None:
725734
raise InterpolationSyntaxError(option, section,
726-
"bad interpolation variable reference %r" % rest)
735+
"bad interpolation variable reference %r" % rest)
727736
var = self.optionxform(m.group(1))
728737
rest = rest[m.end():]
729738
try:
@@ -759,5 +768,5 @@ def set(self, section, option, value=None):
759768
# then, check if there's a lone percent sign left
760769
if '%' in tmp_value:
761770
raise ValueError("invalid interpolation syntax in %r at "
762-
"position %d" % (value, tmp_value.find('%')))
771+
"position %d" % (value, tmp_value.find('%')))
763772
ConfigParser.set(self, section, option, value)

src/wpsremote/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
# (c) 2013 - 2014 German Aerospace Center (DLR)
44
# This code is licensed under the GPL 2.0 license, available at the root
55
# application directory.
6-

0 commit comments

Comments
 (0)