15
0
Files
python-Protego/python-Protego-no-six.patch

52 lines
1.9 KiB
Diff

Index: Protego-0.2.1/src/protego.py
===================================================================
--- Protego-0.2.1.orig/src/protego.py
+++ Protego-0.2.1/src/protego.py
@@ -3,9 +3,8 @@ import re
from collections import namedtuple
from datetime import time
-import six
-from six.moves.urllib.parse import (ParseResult, quote, urlparse,
- urlunparse)
+from urllib.parse import (ParseResult, quote, urlparse,
+ urlunparse)
logger = logging.getLogger(__name__)
@@ -122,8 +121,6 @@ class _RuleSet(object):
def hex_to_byte(h):
"""Replaces a %xx escape with equivalent binary sequence."""
- if six.PY2:
- return chr(int(h, 16))
return bytes.fromhex(h)
# ignore contains %xy escapes for characters that are not
@@ -162,11 +159,7 @@ class _RuleSet(object):
"""Return percent encoded path."""
parts = urlparse(path)
path = self._unquote(parts.path, ignore='/%')
- # quote do not work with unicode strings in Python 2.7
- if six.PY2:
- path = quote(path.encode('utf-8'), safe='/%')
- else:
- path = quote(path, safe='/%')
+ path = quote(path, safe='/%')
parts = ParseResult('', '', path, parts.params, parts.query, parts.fragment)
path = urlunparse(parts)
@@ -182,11 +175,7 @@ class _RuleSet(object):
parts = urlparse(pattern)
pattern = self._unquote(parts.path, ignore='/*$%')
- # quote do not work with unicode strings in Python 2.7
- if six.PY2:
- pattern = quote(pattern.encode('utf-8'), safe='/*%')
- else:
- pattern = quote(pattern, safe='/*%')
+ pattern = quote(pattern, safe='/*%')
parts = ParseResult('', '', pattern + last_char, parts.params, parts.query, parts.fragment)
pattern = urlunparse(parts)