1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
25 import reportlab.lib.units
29 for node in node.childNodes:
30 if node.nodeType == node.TEXT_NODE:
35 (re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
36 (re.compile('^(-?[0-9\.]+)\s*cm$'), reportlab.lib.units.cm),
37 (re.compile('^(-?[0-9\.]+)\s*mm$'), reportlab.lib.units.mm),
38 (re.compile('^(-?[0-9\.]+)\s*px$'), 0.7),
39 (re.compile('^(-?[0-9\.]+)\s*$'), 1)
45 res = unit[0].search(size, 0)
47 return int(unit[1]*float(res.group(1))*1.3)
50 def tuple_int_get(node, attr_name, default=None):
51 if not node.hasAttribute(attr_name):
53 res = [int(x) for x in node.getAttribute(attr_name).split(',')]
57 return (str(value)=="1") or (value.lower()=='yes')
59 def attr_get(node, attrs, dict={}):
62 if node.hasAttribute(name):
63 res[name] = unit_get(node.getAttribute(name))
65 if node.hasAttribute(key):
67 res[key] = str(node.getAttribute(key))
68 elif dict[key]=='bool':
69 res[key] = bool_get(node.getAttribute(key))
70 elif dict[key]=='int':
71 res[key] = int(node.getAttribute(key))
74 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: