Skip to content

Commit

Permalink
- preparing for test suite / introducing pep8 format checks
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Nov 15, 2018
1 parent 14dfecf commit c2ca09b
Show file tree
Hide file tree
Showing 53 changed files with 1,944 additions and 1,490 deletions.
6 changes: 6 additions & 0 deletions autopep8.sh
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

autopep8 -v -i -a -a -r *.py
autopep8 -v -i -a -a -r src
autopep8 -v -i -a -a -r test
6 changes: 6 additions & 0 deletions flake8.sh
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

flake8 *.py
flake8 src/wpsremote
flake8 test
23 changes: 18 additions & 5 deletions requirements.txt
@@ -1,15 +1,28 @@
asn1crypto==0.24.0
astroid==1.4.4
autopep8==1.4.3
bcrypt==3.1.4
cffi==1.11.5
colorama==0.3.6
cryptography==2.3.1
enum34==1.1.6
flake8==2.5.4
functools32==3.2.3.post2
idna==2.7
ipaddress==1.0.22
jsonschema==2.5.1
lazy-object-proxy==1.2.1
mccabe==0.4.0
pep8==1.7.0
psutil==4.0.0
paramiko==2.4.1
pep8==1.7.1
psutil==5.4.7
pyasn1==0.4.4
pycodestyle==2.4.0
pycparser==2.18
pycrypto==2.6.1
pyflakes==1.0.0
pylint==1.5.4
PyNaCl==1.2.1
six==1.10.0
sleekxmpp==1.3.1
wheel==0.24.0
wrapt==1.10.6
sleekxmpp==1.3.3
wrapt==1.10.10
5 changes: 5 additions & 0 deletions setup.cfg
@@ -1,2 +1,7 @@
[metadata]
description-file = README.md

[flake8]
max-line-length = 120
exclude=management,scripts,docs,static
ignore=E121,E122,E124,E126,E226
69 changes: 32 additions & 37 deletions setup.py
Expand Up @@ -24,25 +24,38 @@
python setup.py bdist --format=gztar upload -r pypi
python setup.py bdist_wheel upload -r pypi
"""
from setuptools import setup, find_packages
try: # for pip >= 10
from pip._internal.req import parse_requirements
from pip._internal.download import PipSession
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements
from pip.download import PipSession
from distutils.core import setup

from setuptools import find_packages

# Parse requirements.txt to get the list of dependencies
inst_req = parse_requirements('requirements.txt',
session=PipSession())
REQUIREMENTS = [str(r.req) for r in inst_req]

try:
readme_text = file('README.md', 'rb').read()
except IOError,e:
except IOError as e:
readme_text = ''

setup(
name = "wps-remote",
version = "2.15.0",
author = "GeoServer Developers",
author_email = "geoserver-devel@lists.sourceforge.net",
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",
keywords = "XMPP Beckend for GeoServer Remote WPS ProcessFactory.",
long_description = readme_text,
license = "GPL",
url = "https://github.com/geoserver/wps-remote",
#https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
name="wps-remote",
version="2.15.0",
author="GeoServer Developers",
author_email="geoserver-devel@lists.sourceforge.net",
description="A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol", # noqa
keywords="XMPP Beckend for GeoServer Remote WPS ProcessFactory.",
long_description=readme_text,
license="GPL",
url="https://github.com/geoserver/wps-remote",
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Environment :: Web Environment',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Intended Audience :: Developers',
Expand All @@ -51,9 +64,9 @@
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: GIS',
],
package_dir = {'':'src'},
packages = find_packages('src'),
package_data = {
package_dir={'': 'src'},
packages=find_packages('src'),
package_data={
'': [
'xmpp_data/*.*',
'xmpp_data/configs/*.*',
Expand All @@ -67,25 +80,7 @@
'xmpp_data/test/*.*',
]
},
include_package_data = True,
test_suite = "test",
install_requires = [
"astroid==1.4.4",
"colorama==0.3.6",
"flake8==2.5.4",
"functools32",
"jsonschema==2.5.1",
"lazy-object-proxy==1.2.1",
"mccabe==0.4.0",
"paramiko",
"pep8==1.7.0",
"psutil>=4.0.0",
"pycrypto",
"pyflakes==1.0.0",
"pylint==1.5.4",
"six==1.10.0",
"sleekxmpp>=1.3.1",
"wheel==0.24.0",
"wrapt==1.10.10",
],
include_package_data=True,
test_suite="test",
install_requires=REQUIREMENTS,
)
37 changes: 23 additions & 14 deletions src/wpsremote/ConfigParser.py
Expand Up @@ -4,6 +4,9 @@
# This code is licensed under the GPL 2.0 license, available at the root
# application directory.

import re
import UserDict as _UserDict

__author__ = "Alessio Fabiani"
__copyright__ = "Copyright 2016 Open Source Geospatial Foundation - all rights reserved"
__license__ = "GPL"
Expand Down Expand Up @@ -103,8 +106,6 @@
# fallback for setup.py which hasn't yet built _collections
_default_dict = dict

import re

__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
"InterpolationError", "InterpolationDepthError",
"InterpolationSyntaxError", "ParsingError",
Expand All @@ -117,7 +118,6 @@
MAX_INTERPOLATION_DEPTH = 10



# exception classes
class Error(Exception):
"""Base class for ConfigParser exceptions."""
Expand Down Expand Up @@ -146,6 +146,7 @@ def __repr__(self):

__str__ = __repr__


class NoSectionError(Error):
"""Raised when no section matches a requested option."""

Expand All @@ -154,6 +155,7 @@ def __init__(self, section):
self.section = section
self.args = (section, )


class DuplicateSectionError(Error):
"""Raised when a section is multiply-created."""

Expand All @@ -162,6 +164,7 @@ def __init__(self, section):
self.section = section
self.args = (section, )


class NoOptionError(Error):
"""A requested option was not found."""

Expand All @@ -172,6 +175,7 @@ def __init__(self, option, section):
self.section = section
self.args = (option, section)


class InterpolationError(Error):
"""Base class for interpolation-related exceptions."""

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


class InterpolationMissingOptionError(InterpolationError):
"""A string substitution required a setting which was not available."""

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


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


class InterpolationDepthError(InterpolationError):
"""Raised when substitutions are nested too deeply."""

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


class ParsingError(Error):
"""Raised when a configuration file does not follow legal syntax."""

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


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

Expand Down Expand Up @@ -268,7 +277,7 @@ def add_section(self, section):
case-insensitive variants.
"""
if section.lower() == "default":
raise ValueError, 'Invalid section name: %s' % section
raise ValueError('Invalid section name: %s' % section)

if section in self._sections:
raise DuplicateSectionError(section)
Expand Down Expand Up @@ -377,7 +386,7 @@ def getfloat(self, section, option):
def getboolean(self, section, option):
v = self.get(section, option)
if v.lower() not in self._boolean_states:
raise ValueError, 'Not a boolean: %s' % v
raise ValueError('Not a boolean: %s' % v)
return self._boolean_states[v.lower()]

def optionxform(self, optionstr):
Expand All @@ -392,8 +401,8 @@ def has_option(self, section, option):
return False
else:
option = self.optionxform(option)
return (option in self._sections[section]
or option in self._defaults)
return (option in self._sections[section] or
option in self._defaults)

def set(self, section, option, value=None):
"""Set an option."""
Expand Down Expand Up @@ -452,15 +461,15 @@ def remove_section(self, section):
r'\[' # [
r'(?P<header>[^]]+)' # very permissive!
r'\]' # ]
)
)
OPTCRE = re.compile(
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
# followed by separator
# (either : or =), followed
# by any # space/tab
r'(?P<value>.*)$' # everything up to eol
)
)
OPTCRE_NV = re.compile(
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
r'\s*(?:' # any number of space/tab,
Expand All @@ -469,7 +478,7 @@ def remove_section(self, section):
# =), followed by any #
# space/tab
r'(?P<value>.*))?$' # everything up to eol
)
)

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

import UserDict as _UserDict

class _Chainmap(_UserDict.DictMixin):
"""Combine multiple mappings for successive lookups.
Expand Down Expand Up @@ -595,6 +603,7 @@ def keys(self):
seen.add(key)
return result


class ConfigParser(RawConfigParser):

def get(self, section, option, raw=False, vars=None):
Expand Down Expand Up @@ -674,7 +683,7 @@ def _interpolate(self, section, option, rawval, vars):
value = self._KEYCRE.sub(self._interpolation_replace, value)
try:
value = value % vars
except KeyError, e:
except KeyError as e:
raise InterpolationMissingOptionError(
option, section, rawval, e.args[0])
else:
Expand Down Expand Up @@ -723,7 +732,7 @@ def _interpolate_some(self, option, accum, rest, section, map, depth):
m = self._interpvar_re.match(rest)
if m is None:
raise InterpolationSyntaxError(option, section,
"bad interpolation variable reference %r" % rest)
"bad interpolation variable reference %r" % rest)
var = self.optionxform(m.group(1))
rest = rest[m.end():]
try:
Expand Down Expand Up @@ -759,5 +768,5 @@ def set(self, section, option, value=None):
# then, check if there's a lone percent sign left
if '%' in tmp_value:
raise ValueError("invalid interpolation syntax in %r at "
"position %d" % (value, tmp_value.find('%')))
"position %d" % (value, tmp_value.find('%')))
ConfigParser.set(self, section, option, value)
1 change: 0 additions & 1 deletion src/wpsremote/__init__.py
Expand Up @@ -3,4 +3,3 @@
# (c) 2013 - 2014 German Aerospace Center (DLR)
# This code is licensed under the GPL 2.0 license, available at the root
# application directory.

0 comments on commit c2ca09b

Please sign in to comment.