Skip to content

Commit

Permalink
Refs #53
Browse files Browse the repository at this point in the history
  • Loading branch information
claeyswo committed Dec 7, 2020
1 parent 6d656c3 commit 063e9e8
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 34 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.8"
env:
- LC_ALL=en_US.utf-8
install:
Expand Down
6 changes: 3 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
0.3.0 (12-04-2016)
0.3.0 (12-4-2016)
------------------

- Added http caching to the `/uris` endpoint.

0.2.0 (28-09-2015)
0.2.0 (28-9-2015)
------------------

- Added a `/uris` endpoint that does not redirect, but just returns information.

0.1.0 (27-09-2015)
0.1.0 (27-9-2015)
------------------

- Initial version
Expand Down
18 changes: 7 additions & 11 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Runtime requirements
--requirement requirements.txt

# Documentation
Sphinx==1.7.1
sphinxcontrib-httpdomain==1.6.1

waitress==1.1.0
pyramid_debugtoolbar==4.4
waitress==1.4.4
pyramid_debugtoolbar==4.9

#testing
pytest==3.4.2
pytest-cov==2.5.1
webtest==2.0.29
coveralls==1.3.0
pytest==6.1.2
pytest-cov==2.10.1
webtest==2.0.35
coveralls==2.2.0

# Wheel
wheel==0.30.0
wheel==0.36.1
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pyramid==1.9.2

PyYAML==3.13
pyramid==1.10.5
PyYAML==5.3.1
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.8",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
Expand Down
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ def handlerconfig():
cfg = {
'uris': [
{
'match': '^/foobar/(?P<id>\d+)$',
'match': r'^/foobar/(?P<id>\d+)$',
'mount': True,
'redirect': 'http://localhost:5555/foobar/{id}'
}, {
'match': '^/bar/(?P<name>\w+)$',
'match': r'^/bar/(?P<name>\w+)$',
'redirect': 'http://localhost:5555/bar/{name}'
} , {
'match': '^urn:x-barbar:(?P<namespace>\w+):(?P<id>\d+)$',
'match': r'^urn:x-barbar:(?P<namespace>\w+):(?P<id>\d+)$',
'mount': False,
'redirect': 'http://localhost:2222/{namespace}/{id}'
}, {
'match': 'override/(?P<namespace>\w+)/(?P<id>\d+)$',
'match': r'override/(?P<namespace>\w+)/(?P<id>\d+)$',
'redirect': 'http://localhost:2222/{namespace}/{id}'
}, {
'match': '^/foo/(?P<foo_id>\d+)/bar/(?P<bar_id>\d+)$',
'match': r'^/foo/(?P<foo_id>\d+)/bar/(?P<bar_id>\d+)$',
'mount': True,
'redirect': 'http://localhost:5555/foo/{foo_id}/bar/{bar_id}'
}
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35, cover
envlist = py38, cover

[testenv]
commands =
Expand All @@ -11,7 +11,7 @@ setenv =

[testenv:cover]
basepython =
python2.7
python3.8
commands =
pip install -r requirements-dev.txt
python setup.py develop
Expand Down
4 changes: 2 additions & 2 deletions urihandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def _parse_settings(settings):
urihand_settings = defaults.copy()

for short_key_name in ('config', ):
key_name = '%s.%s' % (prefix, short_key_name)
key_name = '{}.{}'.format(prefix, short_key_name)
if key_name in settings:
urihand_settings[short_key_name] = \
settings.get(key_name, defaults.get(short_key_name, None))

for short_key in urihand_settings:
long_key = '%s.%s' % (prefix, short_key)
long_key = '{}.{}'.format(prefix, short_key)
settings[long_key] = urihand_settings[short_key]

return urihand_settings
Expand Down
4 changes: 2 additions & 2 deletions urihandler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def handle(self, uri, request):
u['match'] = u['match'].replace('^', '^' + request.host_url)
else:
u['match'] = request.host_url + '/.*' + u['match']
log.debug('Matching {0} to {1}.'.format(uri, u['match']))
log.debug('Matching {} to {}.'.format(uri, u['match']))
m = re.match(u['match'], uri)
if m:
redirect = u['redirect'].format(**m.groupdict())
log.debug('Match found. Redirecting to {0}.'.format(redirect,))
log.debug('Match found. Redirecting to {}.'.format(redirect,))
return redirect
return None

Expand Down

0 comments on commit 063e9e8

Please sign in to comment.