forked from pool/python-Routes
Accepting request 1179223 from home:mcalabkova:branches:devel:languages:python
- Add remove-six.patch to get rid of six OBS-URL: https://build.opensuse.org/request/show/1179223 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Routes?expand=0&rev=35
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 7 12:54:57 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add remove-six.patch to get rid of six
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 18 15:15:10 UTC 2022 - Ben Greiner <code@bnavigator.de>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-Routes
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -16,7 +16,6 @@
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-Routes
|
||||
Version: 2.5.1
|
||||
Release: 0
|
||||
@@ -24,17 +23,17 @@ Summary: Routing Recognition and Generation Tools
|
||||
License: BSD-3-Clause
|
||||
URL: https://routes.readthedocs.io/
|
||||
Source: https://files.pythonhosted.org/packages/source/R/Routes/Routes-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM https://github.com/bbangert/routes/pull/113 remove python2 support
|
||||
Patch: remove-six.patch
|
||||
# for testing
|
||||
BuildRequires: %{python_module WebOb}
|
||||
BuildRequires: %{python_module WebTest}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module repoze.lru}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module six}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python-repoze.lru >= 0.3
|
||||
Requires: python-six
|
||||
Provides: python-routes = %{version}-%{release}
|
||||
Obsoletes: python-routes < %{version}-%{release}
|
||||
BuildArch: noarch
|
||||
@@ -44,7 +43,7 @@ BuildArch: noarch
|
||||
A Routing package for Python that matches URL's to dicts and vice versa.
|
||||
|
||||
%prep
|
||||
%setup -q -n Routes-%{version}
|
||||
%autosetup -p1 -n Routes-%{version}
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
||||
371
remove-six.patch
Normal file
371
remove-six.patch
Normal file
@@ -0,0 +1,371 @@
|
||||
From 44d96530bb52642a52e2a14921ebda6af0f7afc5 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Detiste <alexandre.detiste@gmail.com>
|
||||
Date: Fri, 20 Oct 2023 15:39:04 +0200
|
||||
Subject: [PATCH] remove python2 support
|
||||
|
||||
---
|
||||
routes/mapper.py | 27 +++++-------
|
||||
routes/route.py | 12 +++--
|
||||
routes/util.py | 44 +++++++++----------
|
||||
setup.py | 13 ++----
|
||||
tests/test_functional/test_generation.py | 3 +-
|
||||
tests/test_functional/test_nonminimization.py | 2 +-
|
||||
tests/test_functional/test_recognition.py | 3 +-
|
||||
7 files changed, 45 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/routes/mapper.py b/routes/mapper.py
|
||||
index 72981cb..9de7e60 100644
|
||||
--- a/routes/mapper.py
|
||||
+++ b/routes/mapper.py
|
||||
@@ -5,7 +5,6 @@
|
||||
import threading
|
||||
|
||||
from repoze.lru import LRUCache
|
||||
-import six
|
||||
|
||||
from routes import request_config
|
||||
from routes.util import (
|
||||
@@ -168,7 +167,7 @@ def connect(self, routename, path=None, **kwargs):
|
||||
newkargs = {}
|
||||
_routename = routename
|
||||
_path = path
|
||||
- for key, value in six.iteritems(self.kwargs):
|
||||
+ for key, value in self.kwargs.items():
|
||||
if key == 'path_prefix':
|
||||
if path is not None:
|
||||
# if there's a name_prefix, add it to the route name
|
||||
@@ -595,7 +594,7 @@ def _create_gens(self):
|
||||
if 'controller' in route.hardcoded:
|
||||
clist = [route.defaults['controller']]
|
||||
if 'action' in route.hardcoded:
|
||||
- alist = [six.text_type(route.defaults['action'])]
|
||||
+ alist = [str(route.defaults['action'])]
|
||||
for controller in clist:
|
||||
for action in alist:
|
||||
actiondict = gendict.setdefault(controller, {})
|
||||
@@ -625,7 +624,7 @@ def _create_regs(self, clist=None):
|
||||
else:
|
||||
clist = self.controller_scan
|
||||
|
||||
- for key, val in six.iteritems(self.maxkeys):
|
||||
+ for key, val in self.maxkeys.items():
|
||||
for route in val:
|
||||
route.makeregexp(clist)
|
||||
|
||||
@@ -801,15 +800,11 @@ def generate(self, *args, **kargs):
|
||||
# If the URL didn't depend on the SCRIPT_NAME, we'll cache it
|
||||
# keyed by just by kargs; otherwise we need to cache it with
|
||||
# both SCRIPT_NAME and kargs:
|
||||
- cache_key = six.text_type(args).encode('utf8') + \
|
||||
- six.text_type(kargs).encode('utf8')
|
||||
+ cache_key = str(args).encode('utf8') + str(kargs).encode('utf8')
|
||||
|
||||
if self.urlcache is not None:
|
||||
- if six.PY3:
|
||||
- cache_key_script_name = b':'.join((script_name.encode('utf-8'),
|
||||
- cache_key))
|
||||
- else:
|
||||
- cache_key_script_name = '%s:%s' % (script_name, cache_key)
|
||||
+ cache_key_script_name = b':'.join((script_name.encode('utf-8'),
|
||||
+ cache_key))
|
||||
|
||||
# Check the url cache to see if it exists, use it if it does
|
||||
val = self.urlcache.get(cache_key_script_name, self)
|
||||
@@ -829,7 +824,7 @@ def generate(self, *args, **kargs):
|
||||
|
||||
keys = frozenset(kargs.keys())
|
||||
cacheset = False
|
||||
- cachekey = six.text_type(keys)
|
||||
+ cachekey = str(keys)
|
||||
cachelist = sortcache.get(cachekey)
|
||||
if args:
|
||||
keylist = args
|
||||
@@ -1110,7 +1105,7 @@ def resource(self, member_name, collection_name, **kwargs):
|
||||
def swap(dct, newdct):
|
||||
"""Swap the keys and values in the dict, and uppercase the values
|
||||
from the dict during the swap."""
|
||||
- for key, val in six.iteritems(dct):
|
||||
+ for key, val in dct.items():
|
||||
newdct.setdefault(val.upper(), []).append(key)
|
||||
return newdct
|
||||
collection_methods = swap(collection, {})
|
||||
@@ -1153,7 +1148,7 @@ def requirements_for(meth):
|
||||
return opts
|
||||
|
||||
# Add the routes for handling collection methods
|
||||
- for method, lst in six.iteritems(collection_methods):
|
||||
+ for method, lst in collection_methods.items():
|
||||
primary = (method != 'GET' and lst.pop(0)) or None
|
||||
route_options = requirements_for(method)
|
||||
for action in lst:
|
||||
@@ -1177,7 +1172,7 @@ def requirements_for(meth):
|
||||
action='index', conditions={'method': ['GET']}, **options)
|
||||
|
||||
# Add the routes that deal with new resource methods
|
||||
- for method, lst in six.iteritems(new_methods):
|
||||
+ for method, lst in new_methods.items():
|
||||
route_options = requirements_for(method)
|
||||
for action in lst:
|
||||
name = "new_" + member_name
|
||||
@@ -1196,7 +1191,7 @@ def requirements_for(meth):
|
||||
requirements_regexp = '[^\\/]+(?<!\\\\)'
|
||||
|
||||
# Add the routes that deal with member methods of a resource
|
||||
- for method, lst in six.iteritems(member_methods):
|
||||
+ for method, lst in member_methods.items():
|
||||
route_options = requirements_for(method)
|
||||
route_options['requirements'] = {'id': requirements_regexp}
|
||||
if method not in ['POST', 'GET', 'any']:
|
||||
diff --git a/routes/route.py b/routes/route.py
|
||||
index 719636a..b3f5dca 100644
|
||||
--- a/routes/route.py
|
||||
+++ b/routes/route.py
|
||||
@@ -1,8 +1,6 @@
|
||||
import re
|
||||
import sys
|
||||
-
|
||||
-import six
|
||||
-from six.moves.urllib import parse as urlparse
|
||||
+from urllib import parse as urlparse
|
||||
|
||||
from routes.util import _url_quote as url_quote, _str_encode, as_unicode
|
||||
|
||||
@@ -97,7 +95,7 @@ def _setup_route(self):
|
||||
|
||||
# Build a req list with all the regexp requirements for our args
|
||||
self.req_regs = {}
|
||||
- for key, val in six.iteritems(self.reqs):
|
||||
+ for key, val in self.reqs.items():
|
||||
self.req_regs[key] = re.compile('^' + val + '$')
|
||||
# Update our defaults and set new default keys if needed. defaults
|
||||
# needs to be saved
|
||||
@@ -133,14 +131,14 @@ def make_full_route(self):
|
||||
|
||||
def make_unicode(self, s):
|
||||
"""Transform the given argument into a unicode string."""
|
||||
- if isinstance(s, six.text_type):
|
||||
+ if isinstance(s, str):
|
||||
return s
|
||||
elif isinstance(s, bytes):
|
||||
return s.decode(self.encoding)
|
||||
elif callable(s):
|
||||
return s
|
||||
else:
|
||||
- return six.text_type(s)
|
||||
+ return str(s)
|
||||
|
||||
def _pathkeys(self, routepath):
|
||||
"""Utility function to walk the route, and pull out the valid
|
||||
@@ -567,7 +565,7 @@ def match(self, url, environ=None, sub_domains=False,
|
||||
matchdict = match.groupdict()
|
||||
result = {}
|
||||
extras = self._default_keys - frozenset(matchdict.keys())
|
||||
- for key, val in six.iteritems(matchdict):
|
||||
+ for key, val in matchdict.items():
|
||||
if key != 'path_info' and self.encoding:
|
||||
# change back into python unicode objects from the URL
|
||||
# representation
|
||||
diff --git a/routes/util.py b/routes/util.py
|
||||
index 54c8951..be229ae 100644
|
||||
--- a/routes/util.py
|
||||
+++ b/routes/util.py
|
||||
@@ -7,9 +7,7 @@
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
-
|
||||
-import six
|
||||
-from six.moves import urllib
|
||||
+import urllib
|
||||
|
||||
from routes import request_config
|
||||
|
||||
@@ -34,8 +32,8 @@ def _screenargs(kargs, mapper, environ, force_explicit=False):
|
||||
"""
|
||||
# Coerce any unicode args with the encoding
|
||||
encoding = mapper.encoding
|
||||
- for key, val in six.iteritems(kargs):
|
||||
- if isinstance(val, six.text_type):
|
||||
+ for key, val in kargs.items():
|
||||
+ if isinstance(val, str):
|
||||
kargs[key] = val.encode(encoding)
|
||||
|
||||
if mapper.explicit and mapper.sub_domains and not force_explicit:
|
||||
@@ -60,7 +58,7 @@ def _screenargs(kargs, mapper, environ, force_explicit=False):
|
||||
memory_kargs = {}
|
||||
|
||||
# Remove keys from memory and kargs if kargs has them as None
|
||||
- empty_keys = [key for key, value in six.iteritems(kargs) if value is None]
|
||||
+ empty_keys = [key for key, value in kargs.items() if value is None]
|
||||
for key in empty_keys:
|
||||
del kargs[key]
|
||||
memory_kargs.pop(key, None)
|
||||
@@ -79,7 +77,7 @@ def _subdomain_check(kargs, mapper, environ):
|
||||
on the current subdomain or lack therof."""
|
||||
if mapper.sub_domains:
|
||||
subdomain = kargs.pop('sub_domain', None)
|
||||
- if isinstance(subdomain, six.text_type):
|
||||
+ if isinstance(subdomain, str):
|
||||
subdomain = str(subdomain)
|
||||
|
||||
fullhost = environ.get('HTTP_HOST') or environ.get('SERVER_NAME')
|
||||
@@ -112,13 +110,13 @@ def _subdomain_check(kargs, mapper, environ):
|
||||
def _url_quote(string, encoding):
|
||||
"""A Unicode handling version of urllib.quote."""
|
||||
if encoding:
|
||||
- if isinstance(string, six.text_type):
|
||||
+ if isinstance(string, str):
|
||||
s = string.encode(encoding)
|
||||
- elif isinstance(string, six.text_type):
|
||||
+ elif isinstance(string, str):
|
||||
# assume the encoding is already correct
|
||||
s = string
|
||||
else:
|
||||
- s = six.text_type(string).encode(encoding)
|
||||
+ s = str(string).encode(encoding)
|
||||
else:
|
||||
s = str(string)
|
||||
return urllib.parse.quote(s, '/')
|
||||
@@ -126,13 +124,13 @@ def _url_quote(string, encoding):
|
||||
|
||||
def _str_encode(string, encoding):
|
||||
if encoding:
|
||||
- if isinstance(string, six.text_type):
|
||||
+ if isinstance(string, str):
|
||||
s = string.encode(encoding)
|
||||
- elif isinstance(string, six.text_type):
|
||||
+ elif isinstance(string, str):
|
||||
# assume the encoding is already correct
|
||||
s = string
|
||||
else:
|
||||
- s = six.text_type(string).encode(encoding)
|
||||
+ s = str(string).encode(encoding)
|
||||
return s
|
||||
|
||||
|
||||
@@ -216,16 +214,16 @@ def url_for(*args, **kargs):
|
||||
if kargs:
|
||||
url += '?'
|
||||
query_args = []
|
||||
- for key, val in six.iteritems(kargs):
|
||||
+ for key, val in kargs.items():
|
||||
if isinstance(val, (list, tuple)):
|
||||
for value in val:
|
||||
query_args.append("%s=%s" % (
|
||||
- urllib.parse.quote(six.text_type(key).encode(encoding)),
|
||||
- urllib.parse.quote(six.text_type(value).encode(encoding))))
|
||||
+ urllib.parse.quote(str(key).encode(encoding)),
|
||||
+ urllib.parse.quote(str(value).encode(encoding))))
|
||||
else:
|
||||
query_args.append("%s=%s" % (
|
||||
- urllib.parse.quote(six.text_type(key).encode(encoding)),
|
||||
- urllib.parse.quote(six.text_type(val).encode(encoding))))
|
||||
+ urllib.parse.quote(str(key).encode(encoding)),
|
||||
+ urllib.parse.quote(str(val).encode(encoding))))
|
||||
url += '&'.join(query_args)
|
||||
environ = getattr(config, 'environ', {})
|
||||
if 'wsgiorg.routing_args' not in environ:
|
||||
@@ -366,16 +364,16 @@ def __call__(self, *args, **kargs):
|
||||
if kargs:
|
||||
url += '?'
|
||||
query_args = []
|
||||
- for key, val in six.iteritems(kargs):
|
||||
+ for key, val in kargs.items():
|
||||
if isinstance(val, (list, tuple)):
|
||||
for value in val:
|
||||
query_args.append("%s=%s" % (
|
||||
- urllib.parse.quote(six.text_type(key).encode(encoding)),
|
||||
- urllib.parse.quote(six.text_type(value).encode(encoding))))
|
||||
+ urllib.parse.quote(str(key).encode(encoding)),
|
||||
+ urllib.parse.quote(str(value).encode(encoding))))
|
||||
else:
|
||||
query_args.append("%s=%s" % (
|
||||
- urllib.parse.quote(six.text_type(key).encode(encoding)),
|
||||
- urllib.parse.quote(six.text_type(val).encode(encoding))))
|
||||
+ urllib.parse.quote(str(key).encode(encoding)),
|
||||
+ urllib.parse.quote(str(val).encode(encoding))))
|
||||
url += '&'.join(query_args)
|
||||
if not static:
|
||||
route_args = []
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 18d886f..b6052cc 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -11,7 +11,6 @@
|
||||
README = f.read()
|
||||
with io.open(os.path.join(here, 'CHANGELOG.rst'), encoding='utf8') as f:
|
||||
CHANGES = f.read()
|
||||
-PY3 = sys.version_info[0] == 3
|
||||
|
||||
extra_options = {
|
||||
"packages": find_packages(),
|
||||
@@ -24,11 +23,10 @@
|
||||
}
|
||||
extras_require['docs'] = ['Sphinx'] + extras_require['middleware']
|
||||
|
||||
-if PY3:
|
||||
- if "test" in sys.argv or "develop" in sys.argv:
|
||||
- for root, directories, files in os.walk("tests"):
|
||||
- for directory in directories:
|
||||
- extra_options["packages"].append(os.path.join(root, directory))
|
||||
+if "test" in sys.argv or "develop" in sys.argv:
|
||||
+ for root, directories, files in os.walk("tests"):
|
||||
+ for directory in directories:
|
||||
+ extra_options["packages"].append(os.path.join(root, directory))
|
||||
|
||||
setup(name="Routes",
|
||||
version=__version__,
|
||||
@@ -42,8 +40,6 @@
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
'Programming Language :: Python',
|
||||
- "Programming Language :: Python :: 2",
|
||||
- "Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
@@ -67,7 +63,6 @@
|
||||
zip_safe=False,
|
||||
tests_require=["soupsieve<2.0", 'nose', 'webtest', 'webob', 'coverage'],
|
||||
install_requires=[
|
||||
- "six",
|
||||
"repoze.lru>=0.3"
|
||||
],
|
||||
extras_require=extras_require,
|
||||
diff --git a/tests/test_functional/test_generation.py b/tests/test_functional/test_generation.py
|
||||
index b461b5f..cb6732d 100644
|
||||
--- a/tests/test_functional/test_generation.py
|
||||
+++ b/tests/test_functional/test_generation.py
|
||||
@@ -1,6 +1,5 @@
|
||||
"""test_generation"""
|
||||
-import sys, time, unittest
|
||||
-from six.moves import urllib
|
||||
+import sys, time, unittest, urllib
|
||||
|
||||
from nose.tools import eq_, assert_raises
|
||||
from routes import *
|
||||
diff --git a/tests/test_functional/test_nonminimization.py b/tests/test_functional/test_nonminimization.py
|
||||
index 1b152c4..7f2d0e1 100644
|
||||
--- a/tests/test_functional/test_nonminimization.py
|
||||
+++ b/tests/test_functional/test_nonminimization.py
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Test non-minimization recognition"""
|
||||
-from six.moves import urllib
|
||||
+import urllib
|
||||
|
||||
from nose.tools import eq_
|
||||
|
||||
diff --git a/tests/test_functional/test_recognition.py b/tests/test_functional/test_recognition.py
|
||||
index 03fe6a7..6295979 100644
|
||||
--- a/tests/test_functional/test_recognition.py
|
||||
+++ b/tests/test_functional/test_recognition.py
|
||||
@@ -3,7 +3,8 @@
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
-from six.moves import urllib
|
||||
+import urllib
|
||||
+
|
||||
from nose.tools import eq_, assert_raises
|
||||
from routes import *
|
||||
from routes.util import RoutesException
|
||||
Reference in New Issue
Block a user