diff options
author | Oin Maple <mapleoin@copac.rdsnet.ro> | 2009-04-25 11:33:22 +0300 |
---|---|---|
committer | Oin Maple <mapleoin@copac.rdsnet.ro> | 2009-04-25 11:33:22 +0300 |
commit | 7cc49782869031e5b95c8c8882eded703a25b265 (patch) | |
tree | d9bd2d82bca2b05f605240e1d15714928e13037c /fedora_business_cards/generate.py | |
parent | 9a082fb5c2d26d1c8e53a8523fccd0421196a7c9 (diff) | |
download | fedora-business-cards-7cc49782869031e5b95c8c8882eded703a25b265.tar.gz fedora-business-cards-7cc49782869031e5b95c8c8882eded703a25b265.tar.xz fedora-business-cards-7cc49782869031e5b95c8c8882eded703a25b265.zip |
Diffstat (limited to 'fedora_business_cards/generate.py')
-rw-r--r-- | fedora_business_cards/generate.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/fedora_business_cards/generate.py b/fedora_business_cards/generate.py index 91f1e14..cf2b4e1 100644 --- a/fedora_business_cards/generate.py +++ b/fedora_business_cards/generate.py @@ -37,24 +37,43 @@ def find_node(doc_node, tag_name, attribute_name, attribute_value): return element -def gen_front(name, title, lines, template_loc): +def gen_front(name, title, lines, template_loc, width=None, height=None): """ Generates the front of the business card. """ dom = minidom.parse(template_loc) + namenode = find_node(dom, 'text', 'id', 'fullname') namenode.appendChild(dom.createTextNode(name)) titlenode = find_node(dom, 'text', 'id', 'title') titlenode.appendChild(dom.createTextNode(title)) + if width or height: + svg = find_node(dom, 'svg', 'id', 'svg') + svg.setAttribute('width', width) + svg.setAttribute('height', height) + svg.setAttribute('viewBox', '0 0 '+width+' '+height) + whiteness = find_node(dom, 'rect', 'id', 'whiteness') + whiteness.setAttribute('height', height) + blueband = find_node(dom, 'rect', 'id', 'blueband') + blueband.setAttribute('height', height) + blueband.setAttribute('width', width) for i in range(6): node = find_node(dom, 'tspan', 'id', 'line%d' % (i+1)) node.appendChild(dom.createTextNode(lines[i])) return dom.toxml() -def gen_back(template_loc): +def gen_back(template_loc, width=None, height=None): """ Generates the back of the business card. """ dom = minidom.parse(template_loc) + if width or height: + svg = find_node(dom, 'svg', 'id', 'svg') + svg.setAttribute('width', width) + svg.setAttribute('height', height) + svg.setAttribute('viewBox', '0 0 '+width+' '+height) + background = find_node(dom, 'rect', 'id', 'background') + background.setAttribute('width', width) + background.setAttribute('height', height) return dom.toxml() |