comparison sat_frontends/tools/xmltools.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
27 """ make the root attribute inline 27 """ make the root attribute inline
28 @param root_node: minidom's Document compatible class 28 @param root_node: minidom's Document compatible class
29 @return: plain XML 29 @return: plain XML
30 """ 30 """
31 root_elt = doc.documentElement 31 root_elt = doc.documentElement
32 if root_elt.hasAttribute('style'): 32 if root_elt.hasAttribute("style"):
33 styles_raw = root_elt.getAttribute('style') 33 styles_raw = root_elt.getAttribute("style")
34 styles = styles_raw.split(';') 34 styles = styles_raw.split(";")
35 new_styles = [] 35 new_styles = []
36 for style in styles: 36 for style in styles:
37 try: 37 try:
38 key, value = style.split(':') 38 key, value = style.split(":")
39 except ValueError: 39 except ValueError:
40 continue 40 continue
41 if key.strip().lower() == 'display': 41 if key.strip().lower() == "display":
42 value = 'inline' 42 value = "inline"
43 new_styles.append('%s: %s' % (key.strip(), value.strip())) 43 new_styles.append("%s: %s" % (key.strip(), value.strip()))
44 root_elt.setAttribute('style', "; ".join(new_styles)) 44 root_elt.setAttribute("style", "; ".join(new_styles))
45 else: 45 else:
46 root_elt.setAttribute('style', 'display: inline') 46 root_elt.setAttribute("style", "display: inline")
47 return root_elt.toxml() 47 return root_elt.toxml()
48