Remove unneeded six stuff

This commit is contained in:
Nikita Karamov 2023-01-23 06:47:48 +01:00
parent 1cc86cc3c8
commit c3b305cc5d
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD
3 changed files with 26 additions and 28 deletions

View file

@ -57,7 +57,7 @@ from collections import namedtuple, defaultdict
from decimal import Context, Decimal, InvalidOperation, getcontext from decimal import Context, Decimal, InvalidOperation, getcontext
import six import six
from six.moves import range, urllib from six.moves import urllib
from scour.stats import ScourStats from scour.stats import ScourStats
from scour.svg_regex import svg_parser from scour.svg_regex import svg_parser
@ -1433,7 +1433,7 @@ def collapse_singly_referenced_gradients(doc, stats):
identifiedElements = findElementsWithId(doc.documentElement) identifiedElements = findElementsWithId(doc.documentElement)
# make sure to reset the ref'ed ids for when we are running this in testscour # 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. # 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!) # (Cyn: I've seen documents with #id references but no element with that ID!)
if len(nodes) == 1 and rid in identifiedElements: if len(nodes) == 1 and rid in identifiedElements:
@ -1540,7 +1540,7 @@ def detect_duplicate_gradients(*grad_lists):
key = computeGradientBucketKey(grad) key = computeGradientBucketKey(grad)
grad_buckets[key].append(grad) grad_buckets[key].append(grad)
for bucket in six.itervalues(grad_buckets): for bucket in grad_buckets.values():
if len(bucket) < 2: if len(bucket) < 2:
# The gradient must be unique if it is the only one in # The gradient must be unique if it is the only one in
# this bucket. # this bucket.
@ -3005,7 +3005,7 @@ def scourUnitlessLength(length, renderer_workaround=False, is_control_point=Fals
exponent = length.adjusted() # how far do we have to shift the dot? 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 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): if len(sci) < len(nonsci):
return_value = sci return_value = sci

View file

@ -60,7 +60,6 @@ import re
from decimal import Decimal from decimal import Decimal
from functools import partial from functools import partial
from six.moves import range
# Sentinel. # Sentinel.

View file

@ -25,7 +25,6 @@ import sys
import unittest import unittest
import six import six
from six.moves import map, range
from scour.scour import (make_well_formed, parse_args, scourString, scourXmlFile, start, run, from scour.scour import (make_well_formed, parse_args, scourString, scourXmlFile, start, run,
XML_ENTS_ESCAPE_APOS, XML_ENTS_ESCAPE_QUOT) XML_ENTS_ESCAPE_APOS, XML_ENTS_ESCAPE_QUOT)
@ -1146,30 +1145,30 @@ class HandleEncodingUTF8(unittest.TestCase):
def runTest(self): def runTest(self):
doc = scourXmlFile('unittests/encoding-utf8.svg') doc = scourXmlFile('unittests/encoding-utf8.svg')
text = u'Hello in many languages:\n' \ text = 'Hello in many languages:\n' \
u'ar: أهلا\n' \ 'ar: أهلا\n' \
u'bn: হ্যালো\n' \ 'bn: হ্যালো\n' \
u'el: Χαίρετε\n' \ 'el: Χαίρετε\n' \
u'en: Hello\n' \ 'en: Hello\n' \
u'hi: नमस्ते\n' \ 'hi: नमस्ते\n' \
u'iw: שלום\n' \ 'iw: שלום\n' \
u'ja: こんにちは\n' \ 'ja: こんにちは\n' \
u'km: ជំរាបសួរ\n' \ 'km: ជំរាបសួរ\n' \
u'ml: ഹലോ\n' \ 'ml: ഹലോ\n' \
u'ru: Здравствуйте\n' \ 'ru: Здравствуйте\n' \
u'ur: ہیلو\n' \ 'ur: ہیلو\n' \
u'zh: 您好' '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, self.assertEqual(desc, text,
'Did not handle international UTF8 characters') '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'“”—…°©®™•½¼¾⅓⅔†‡µ¢£€«»♠♣♥♦¿<EFBFBD>', self.assertEqual(desc, '“”—…°©®™•½¼¾⅓⅔†‡µ¢£€«»♠♣♥♦¿<EFBFBD>',
'Did not handle common UTF8 characters') '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':-×÷±∞π∅≤≥≠≈∧∨∩∪∈∀∃∄∑∏←↑→↓↔↕↖↗↘↙↺↻⇒⇔', self.assertEqual(desc, ':-×÷±∞π∅≤≥≠≈∧∨∩∪∈∀∃∄∑∏←↑→↓↔↕↖↗↘↙↺↻⇒⇔',
'Did not handle mathematical UTF8 characters') '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'⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎', self.assertEqual(desc, '⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎',
'Did not handle superscript/subscript UTF8 characters') 'Did not handle superscript/subscript UTF8 characters')
@ -1177,8 +1176,8 @@ class HandleEncodingISO_8859_15(unittest.TestCase):
def runTest(self): def runTest(self):
doc = scourXmlFile('unittests/encoding-iso-8859-15.svg') 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') self.assertEqual(desc, 'áèîäöüß€ŠšŽžŒœŸ', 'Did not handle ISO 8859-15 encoded characters')
class HandleSciNoInPathData(unittest.TestCase): class HandleSciNoInPathData(unittest.TestCase):