forked from pool/python-Protego
- added patches fix https://github.com/scrapy/protego/issues/31 + python-Protego-no-six.patch OBS-URL: https://build.opensuse.org/request/show/1012073 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Protego?expand=0&rev=5
52 lines
1.9 KiB
Diff
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)
|