Noop indentation
Same behaviour; just force a level of indentation. Mostly useful to make the next commit more readable. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
a8e4d0efbf
commit
180d7f8ddb
1 changed files with 43 additions and 41 deletions
|
|
@ -561,53 +561,55 @@ def findReferencedElements(node, ids=None):
|
||||||
global referencingProps
|
global referencingProps
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = {}
|
ids = {}
|
||||||
# TODO: input argument ids is clunky here (see below how it is called)
|
|
||||||
# GZ: alternative to passing dict, use **kwargs
|
|
||||||
|
|
||||||
# if this node is a style element, parse its text into CSS
|
if 1: # Indent-only
|
||||||
if node.nodeName == 'style' and node.namespaceURI == NS['SVG']:
|
# TODO: input argument ids is clunky here (see below how it is called)
|
||||||
# one stretch of text, please! (we could use node.normalize(), but
|
# GZ: alternative to passing dict, use **kwargs
|
||||||
# this actually modifies the node, and we don't want to keep
|
|
||||||
# whitespace around if there's any)
|
|
||||||
stylesheet = "".join([child.nodeValue for child in node.childNodes])
|
|
||||||
if stylesheet != '':
|
|
||||||
cssRules = parseCssString(stylesheet)
|
|
||||||
for rule in cssRules:
|
|
||||||
for propname in rule['properties']:
|
|
||||||
propval = rule['properties'][propname]
|
|
||||||
findReferencingProperty(node, propname, propval, ids)
|
|
||||||
return ids
|
|
||||||
|
|
||||||
# else if xlink:href is set, then grab the id
|
# if this node is a style element, parse its text into CSS
|
||||||
href = node.getAttributeNS(NS['XLINK'], 'href')
|
if node.nodeName == 'style' and node.namespaceURI == NS['SVG']:
|
||||||
if href != '' and len(href) > 1 and href[0] == '#':
|
# one stretch of text, please! (we could use node.normalize(), but
|
||||||
# we remove the hash mark from the beginning of the id
|
# this actually modifies the node, and we don't want to keep
|
||||||
id = href[1:]
|
# whitespace around if there's any)
|
||||||
if id in ids:
|
stylesheet = "".join([child.nodeValue for child in node.childNodes])
|
||||||
ids[id].append(node)
|
if stylesheet != '':
|
||||||
else:
|
cssRules = parseCssString(stylesheet)
|
||||||
ids[id] = [node]
|
for rule in cssRules:
|
||||||
|
for propname in rule['properties']:
|
||||||
|
propval = rule['properties'][propname]
|
||||||
|
findReferencingProperty(node, propname, propval, ids)
|
||||||
|
return ids
|
||||||
|
|
||||||
# now get all style properties and the fill, stroke, filter attributes
|
# else if xlink:href is set, then grab the id
|
||||||
styles = node.getAttribute('style').split(';')
|
href = node.getAttributeNS(NS['XLINK'], 'href')
|
||||||
|
if href != '' and len(href) > 1 and href[0] == '#':
|
||||||
|
# we remove the hash mark from the beginning of the id
|
||||||
|
id = href[1:]
|
||||||
|
if id in ids:
|
||||||
|
ids[id].append(node)
|
||||||
|
else:
|
||||||
|
ids[id] = [node]
|
||||||
|
|
||||||
for style in styles:
|
# now get all style properties and the fill, stroke, filter attributes
|
||||||
propval = style.split(':')
|
styles = node.getAttribute('style').split(';')
|
||||||
if len(propval) == 2:
|
|
||||||
prop = propval[0].strip()
|
|
||||||
val = propval[1].strip()
|
|
||||||
findReferencingProperty(node, prop, val, ids)
|
|
||||||
|
|
||||||
for attr in referencingProps:
|
for style in styles:
|
||||||
val = node.getAttribute(attr).strip()
|
propval = style.split(':')
|
||||||
if not val:
|
if len(propval) == 2:
|
||||||
continue
|
prop = propval[0].strip()
|
||||||
findReferencingProperty(node, attr, val, ids)
|
val = propval[1].strip()
|
||||||
|
findReferencingProperty(node, prop, val, ids)
|
||||||
|
|
||||||
if node.hasChildNodes():
|
for attr in referencingProps:
|
||||||
for child in node.childNodes:
|
val = node.getAttribute(attr).strip()
|
||||||
if child.nodeType == Node.ELEMENT_NODE:
|
if not val:
|
||||||
findReferencedElements(child, ids)
|
continue
|
||||||
|
findReferencingProperty(node, attr, val, ids)
|
||||||
|
|
||||||
|
if node.hasChildNodes():
|
||||||
|
for child in node.childNodes:
|
||||||
|
if child.nodeType == Node.ELEMENT_NODE:
|
||||||
|
findReferencedElements(child, ids)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue