scour.py: Satisfy the identing rules of PEP8
This commit is contained in:
parent
77aadca98a
commit
fdbf890ba8
1 changed files with 26 additions and 18 deletions
|
|
@ -647,7 +647,7 @@ def removeUnusedDefs(doc, defElem, elemsToRemove=None):
|
||||||
for elem in defElem.childNodes:
|
for elem in defElem.childNodes:
|
||||||
# only look at it if an element and not referenced anywhere else
|
# only look at it if an element and not referenced anywhere else
|
||||||
if elem.nodeType == Node.ELEMENT_NODE and (elem.getAttribute('id') == '' or
|
if elem.nodeType == Node.ELEMENT_NODE and (elem.getAttribute('id') == '' or
|
||||||
elem.getAttribute('id') not in referencedIDs):
|
elem.getAttribute('id') not in referencedIDs):
|
||||||
# we only inspect the children of a group in a defs if the group
|
# we only inspect the children of a group in a defs if the group
|
||||||
# is not referenced anywhere else
|
# is not referenced anywhere else
|
||||||
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']:
|
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']:
|
||||||
|
|
@ -1103,23 +1103,27 @@ def createGroupsForCommonAttributes(elem):
|
||||||
while curChild >= 0:
|
while curChild >= 0:
|
||||||
childNode = elem.childNodes.item(curChild)
|
childNode = elem.childNodes.item(curChild)
|
||||||
|
|
||||||
if childNode.nodeType == Node.ELEMENT_NODE and childNode.getAttribute(curAttr) != '' and childNode.nodeName in [
|
if (
|
||||||
# only attempt to group elements that the content model allows to be children of a <g>
|
childNode.nodeType == Node.ELEMENT_NODE and
|
||||||
|
childNode.getAttribute(curAttr) != '' and
|
||||||
|
childNode.nodeName in [
|
||||||
|
# only attempt to group elements that the content model allows to be children of a <g>
|
||||||
|
|
||||||
# SVG 1.1 (see https://www.w3.org/TR/SVG/struct.html#GElement)
|
# SVG 1.1 (see https://www.w3.org/TR/SVG/struct.html#GElement)
|
||||||
'animate', 'animateColor', 'animateMotion', 'animateTransform', 'set', # animation elements
|
'animate', 'animateColor', 'animateMotion', 'animateTransform', 'set', # animation elements
|
||||||
'desc', 'metadata', 'title', # descriptive elements
|
'desc', 'metadata', 'title', # descriptive elements
|
||||||
'circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect', # shape elements
|
'circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect', # shape elements
|
||||||
'defs', 'g', 'svg', 'symbol', 'use', # structural elements
|
'defs', 'g', 'svg', 'symbol', 'use', # structural elements
|
||||||
'linearGradient', 'radialGradient', # gradient elements
|
'linearGradient', 'radialGradient', # gradient elements
|
||||||
'a', 'altGlyphDef', 'clipPath', 'color-profile', 'cursor', 'filter',
|
'a', 'altGlyphDef', 'clipPath', 'color-profile', 'cursor', 'filter',
|
||||||
'font', 'font-face', 'foreignObject', 'image', 'marker', 'mask',
|
'font', 'font-face', 'foreignObject', 'image', 'marker', 'mask',
|
||||||
'pattern', 'script', 'style', 'switch', 'text', 'view',
|
'pattern', 'script', 'style', 'switch', 'text', 'view',
|
||||||
|
|
||||||
# SVG 1.2 (see https://www.w3.org/TR/SVGTiny12/elementTable.html)
|
# SVG 1.2 (see https://www.w3.org/TR/SVGTiny12/elementTable.html)
|
||||||
'animation', 'audio', 'discard', 'handler', 'listener',
|
'animation', 'audio', 'discard', 'handler', 'listener',
|
||||||
'prefetch', 'solidColor', 'textArea', 'video'
|
'prefetch', 'solidColor', 'textArea', 'video'
|
||||||
]:
|
]
|
||||||
|
):
|
||||||
# We're in a possible run! Track the value and run length.
|
# We're in a possible run! Track the value and run length.
|
||||||
value = childNode.getAttribute(curAttr)
|
value = childNode.getAttribute(curAttr)
|
||||||
runStart, runEnd = curChild, curChild
|
runStart, runEnd = curChild, curChild
|
||||||
|
|
@ -1303,8 +1307,12 @@ def collapseSinglyReferencedGradients(doc):
|
||||||
# (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 count == 1 and rid in identifiedElements:
|
if count == 1 and rid in identifiedElements:
|
||||||
elem = identifiedElements[rid]
|
elem = identifiedElements[rid]
|
||||||
if elem is not None and elem.nodeType == Node.ELEMENT_NODE and elem.nodeName in ['linearGradient', 'radialGradient'] \
|
if (
|
||||||
and elem.namespaceURI == NS['SVG']:
|
elem is not None and
|
||||||
|
elem.nodeType == Node.ELEMENT_NODE and
|
||||||
|
elem.nodeName in ['linearGradient', 'radialGradient'] and
|
||||||
|
elem.namespaceURI == NS['SVG']
|
||||||
|
):
|
||||||
# found a gradient that is referenced by only 1 other element
|
# found a gradient that is referenced by only 1 other element
|
||||||
refElem = nodes[0]
|
refElem = nodes[0]
|
||||||
if refElem.nodeType == Node.ELEMENT_NODE and refElem.nodeName in ['linearGradient', 'radialGradient'] \
|
if refElem.nodeType == Node.ELEMENT_NODE and refElem.nodeName in ['linearGradient', 'radialGradient'] \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue