1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import re
19 import reportlab
20
22 rc = ''
23 for node in node.childNodes:
24 if node.nodeType == node.TEXT_NODE:
25 rc = rc + node.data
26 return rc
27
28 units = [
29 (re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
30 (re.compile('^(-?[0-9\.]+)\s*cm$'), reportlab.lib.units.cm),
31 (re.compile('^(-?[0-9\.]+)\s*mm$'), reportlab.lib.units.mm),
32 (re.compile('^(-?[0-9\.]+)\s*$'), 1)
33 ]
34
36 global units
37 for unit in units:
38 res = unit[0].search(size, 0)
39 if res:
40 return unit[1]*float(res.group(1))
41 return False
42
44 if not node.hasAttribute(attr_name):
45 return default
46 res = [int(x) for x in node.getAttribute(attr_name).split(',')]
47 return res
48
50 return (str(value)=="1") or (value.lower()=='yes')
51
53 res = {}
54 for name in attrs:
55 if node.hasAttribute(name):
56 res[name] = unit_get(node.getAttribute(name))
57 for key in dict:
58 if node.hasAttribute(key):
59 if dict[key]=='str':
60 res[key] = str(node.getAttribute(key))
61 elif dict[key]=='bool':
62 res[key] = bool_get(node.getAttribute(key))
63 elif dict[key]=='int':
64 res[key] = int(node.getAttribute(key))
65 return res
66