1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
From c3b305cc5d2f596f7fdd738e8bf66f4e977d19d4 Mon Sep 17 00:00:00 2001
From: Nikita Karamov <me@kytta.dev>
Date: Mon, 23 Jan 2023 06:47:48 +0100
Subject: [PATCH 06/14] Remove unneeded six stuff
Forwarded: https://github.com/scour-project/scour/pull/306
--- a/scour/scour.py
+++ b/scour/scour.py
@@ -45,23 +45,19 @@
# - if a <g> has only one element in it, collapse the <g> (ensure transform, etc are carried down)
-from __future__ import division # use "true" division instead of integer division in Python 2 (see PEP 238)
-from __future__ import print_function # use print() as a function in Python 2 (see PEP 3105)
-from __future__ import absolute_import # use absolute imports by default in Python 2 (see PEP 328)
-
import math
import optparse
import os
import re
import sys
import time
+import urllib.parse
+import urllib.request
import xml.dom.minidom
from xml.dom import Node, NotFoundErr
from collections import namedtuple, defaultdict
from decimal import Context, Decimal, InvalidOperation, getcontext
-import six
-from six.moves import range, urllib
from scour.svg_regex import svg_parser
from scour.svg_transform import svg_transform_parser
@@ -1446,7 +1442,7 @@
identifiedElements = findElementsWithId(doc.documentElement)
# make sure to reset the ref'ed ids for when we are running this in testscour
- for rid, nodes in six.iteritems(findReferencedElements(doc.documentElement)):
+ for rid, nodes in findReferencedElements(doc.documentElement).items():
# Make sure that there's actually a defining element for the current ID name.
# (Cyn: I've seen documents with #id references but no element with that ID!)
if len(nodes) == 1 and rid in identifiedElements:
@@ -1552,7 +1548,7 @@
key = computeGradientBucketKey(grad)
grad_buckets[key].append(grad)
- for bucket in six.itervalues(grad_buckets):
+ for bucket in grad_buckets.values():
if len(bucket) < 2:
# The gradient must be unique if it is the only one in
# this bucket.
@@ -3015,7 +3011,7 @@
exponent = length.adjusted() # how far do we have to shift the dot?
length = length.scaleb(-exponent).normalize() # shift the dot and remove potential trailing zeroes
- sci = six.text_type(length) + 'e' + six.text_type(exponent)
+ sci = str(length) + 'e' + str(exponent)
if len(sci) < len(nonsci):
return_value = sci
--- a/scour/svg_transform.py
+++ b/scour/svg_transform.py
@@ -56,14 +56,11 @@
In [12]: svg_transform_parser.parse('translate(30 -30) rotate(36)')
Out[12]: [('translate', [30.0, -30.0]), ('rotate', [36.0])]
"""
-from __future__ import absolute_import
import re
from decimal import Decimal
from functools import partial
-from six.moves import range
-
# Sentinel.
class _EOF(object):
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@
author_email='codedread@gmail.com',
url='https://github.com/scour-project/scour',
platforms=('Any'),
- install_requires=['six>=1.9.0'],
+ install_requires=[],
packages=find_packages(),
zip_safe=True,
entry_points={
--- a/test_scour.py
+++ b/test_scour.py
@@ -20,16 +20,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function # use print() as a function in Python 2 (see PEP 3105)
-from __future__ import absolute_import # use absolute imports by default in Python 2 (see PEP 328)
-
+import io
import os
import sys
import unittest
-import six
-from six.moves import map, range
-
from scour.scour import (make_well_formed, parse_args, scourString, scourXmlFile, start, run,
XML_ENTS_ESCAPE_APOS, XML_ENTS_ESCAPE_QUOT)
from scour.svg_regex import svg_parser
@@ -1162,16 +1157,16 @@
u'ru: Здравствуйте\n' \
u'ur: ہیلو\n' \
u'zh: 您好'
- desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip()
+ desc = str(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip()
self.assertEqual(desc, text,
'Did not handle international UTF8 characters')
- desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[1].firstChild.wholeText).strip()
+ desc = str(doc.getElementsByTagNameNS(SVGNS, 'desc')[1].firstChild.wholeText).strip()
self.assertEqual(desc, u'“”‘’–—…‐‒°©®™•½¼¾⅓⅔†‡µ¢£€«»♠♣♥♦¿�',
'Did not handle common UTF8 characters')
- desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[2].firstChild.wholeText).strip()
+ desc = str(doc.getElementsByTagNameNS(SVGNS, 'desc')[2].firstChild.wholeText).strip()
self.assertEqual(desc, u':-×÷±∞π∅≤≥≠≈∧∨∩∪∈∀∃∄∑∏←↑→↓↔↕↖↗↘↙↺↻⇒⇔',
'Did not handle mathematical UTF8 characters')
- desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[3].firstChild.wholeText).strip()
+ desc = str(doc.getElementsByTagNameNS(SVGNS, 'desc')[3].firstChild.wholeText).strip()
self.assertEqual(desc, u'⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎',
'Did not handle superscript/subscript UTF8 characters')
@@ -1180,7 +1175,7 @@
def runTest(self):
doc = scourXmlFile('unittests/encoding-iso-8859-15.svg')
- desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip()
+ desc = str(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip()
self.assertEqual(desc, u'áèîäöüß€ŠšŽžŒœŸ', 'Did not handle ISO 8859-15 encoded characters')
@@ -2581,7 +2576,7 @@
# TODO: can we create file objects that behave *exactly* like the original?
# this is a mess since we have to ensure compatibility across Python 2 and 3 and it seems impossible
# to replicate all the details of 'stdin', 'stdout' and 'stderr'
- class InOutBuffer(six.StringIO, object):
+ class InOutBuffer(io.StringIO, object):
def write(self, string):
try:
return super(InOutBuffer, self).write(string)
|