summaryrefslogtreecommitdiff
path: root/bin/report/render/rml2html/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/report/render/rml2html/utils.py')
-rw-r--r--bin/report/render/rml2html/utils.py68
1 files changed, 34 insertions, 34 deletions
diff --git a/bin/report/render/rml2html/utils.py b/bin/report/render/rml2html/utils.py
index ad3a74445b8..2cef5ce80b2 100644
--- a/bin/report/render/rml2html/utils.py
+++ b/bin/report/render/rml2html/utils.py
@@ -47,48 +47,48 @@ import reportlab
import reportlab.lib.units
def text_get(node):
- rc = ''
- for node in node.childNodes:
- if node.nodeType == node.TEXT_NODE:
- rc = rc + node.data
- return rc
+ rc = ''
+ for node in node.childNodes:
+ if node.nodeType == node.TEXT_NODE:
+ rc = rc + node.data
+ return rc
units = [
- (re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
- (re.compile('^(-?[0-9\.]+)\s*cm$'), reportlab.lib.units.cm),
- (re.compile('^(-?[0-9\.]+)\s*mm$'), reportlab.lib.units.mm),
- (re.compile('^(-?[0-9\.]+)\s*px$'), 0.7),
- (re.compile('^(-?[0-9\.]+)\s*$'), 1)
+ (re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
+ (re.compile('^(-?[0-9\.]+)\s*cm$'), reportlab.lib.units.cm),
+ (re.compile('^(-?[0-9\.]+)\s*mm$'), reportlab.lib.units.mm),
+ (re.compile('^(-?[0-9\.]+)\s*px$'), 0.7),
+ (re.compile('^(-?[0-9\.]+)\s*$'), 1)
]
def unit_get(size):
- global units
- for unit in units:
- res = unit[0].search(size, 0)
- if res:
- return int(unit[1]*float(res.group(1))*1.3)
- return False
+ global units
+ for unit in units:
+ res = unit[0].search(size, 0)
+ if res:
+ return int(unit[1]*float(res.group(1))*1.3)
+ return False
def tuple_int_get(node, attr_name, default=None):
- if not node.hasAttribute(attr_name):
- return default
- res = [int(x) for x in node.getAttribute(attr_name).split(',')]
- return res
+ if not node.hasAttribute(attr_name):
+ return default
+ res = [int(x) for x in node.getAttribute(attr_name).split(',')]
+ return res
def bool_get(value):
- return (str(value)=="1") or (value.lower()=='yes')
+ return (str(value)=="1") or (value.lower()=='yes')
def attr_get(node, attrs, dict={}):
- res = {}
- for name in attrs:
- if node.hasAttribute(name):
- res[name] = unit_get(node.getAttribute(name))
- for key in dict:
- if node.hasAttribute(key):
- if dict[key]=='str':
- res[key] = str(node.getAttribute(key))
- elif dict[key]=='bool':
- res[key] = bool_get(node.getAttribute(key))
- elif dict[key]=='int':
- res[key] = int(node.getAttribute(key))
- return res
+ res = {}
+ for name in attrs:
+ if node.hasAttribute(name):
+ res[name] = unit_get(node.getAttribute(name))
+ for key in dict:
+ if node.hasAttribute(key):
+ if dict[key]=='str':
+ res[key] = str(node.getAttribute(key))
+ elif dict[key]=='bool':
+ res[key] = bool_get(node.getAttribute(key))
+ elif dict[key]=='int':
+ res[key] = int(node.getAttribute(key))
+ return res