~hannes-hochreiner/jessyink/effects-2

« back to all changes in this revision

Viewing changes to inkscapeExtensions/jessyInk_effects.py

  • Committer: Hannes Hochreiner
  • Date: 2008-05-10 02:18:09 UTC
  • mfrom: (8.1.10 effects)
  • Revision ID: hannes@hochreiner.net-20080510021809-t39uge7j5uxgk7ae
Tags: version_0_2
Merging the "effects" branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
# Copyright 2008 Hannes Hochreiner
 
3
# This program is free software: you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation, either version 3 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program.  If not, see http://www.gnu.org/licenses/.
 
15
 
 
16
# Other imports
 
17
from xml.dom.minidom import parse
 
18
from jessyInk_isExtUtils import *
 
19
import xml.dom
 
20
import sys
 
21
import os
 
22
 
 
23
# Process input parameters
 
24
(tempFile, options) = processOptions(sys.argv[1:])
 
25
if tempFile == None:
 
26
        std.stderr.write("Name of the temporary file could not be extracted.\n")
 
27
        exit()
 
28
 
 
29
# Check if we received an id
 
30
if not options.has_key("id") or options["id"].strip() == "":
 
31
        sys.stderr.write("No object id found.\n")
 
32
        exit()
 
33
 
 
34
domDoc = parse(tempFile)
 
35
 
 
36
node = getNodeWithId(domDoc, options["id"].strip())
 
37
 
 
38
if node == None:
 
39
        sys.stderr.write("Node could not be found.\n")
 
40
 
 
41
effectInOrder = None
 
42
if options.has_key("effectInOrder"):
 
43
        effectInOrder = options["effectInOrder"]
 
44
if effectInOrder == None:
 
45
        effectInOrder = "1"
 
46
 
 
47
if options.has_key("effectIn"):
 
48
        if options["effectIn"] == "appear":
 
49
                node.setAttribute("effectIn","name=appear;order=" + effectInOrder)
 
50
        elif options["effectIn"] == "fade":
 
51
                node.setAttribute("effectIn","name=fade;order=" + effectInOrder)
 
52
        elif options["effectIn"] == "pop":
 
53
                node.setAttribute("effectIn","name=pop;order=" + effectInOrder)
 
54
        else:
 
55
                if node.hasAttribute("effectIn"):
 
56
                        node.removeAttribute("effectIn")
 
57
else:
 
58
        if node.hasAttribute("effectIn"):
 
59
                node.removeAttribute("effectIn")
 
60
 
 
61
effectOutOrder = None
 
62
if options.has_key("effectOutOrder"):
 
63
        effectOutOrder = options["effectOutOrder"]
 
64
if effectOutOrder == None:
 
65
        effectOutOrder = "2"
 
66
 
 
67
if options.has_key("effectOut"):
 
68
        if options["effectOut"] == "appear":
 
69
                node.setAttribute("effectOut","name=appear;order=" + effectOutOrder)
 
70
        elif options["effectOut"] == "fade":
 
71
                node.setAttribute("effectOut","name=fade;order=" + effectOutOrder)
 
72
        elif options["effectOut"] == "pop":
 
73
                node.setAttribute("effectOut","name=pop;order=" + effectOutOrder)
 
74
        else:
 
75
                if node.hasAttribute("effectOut"):
 
76
                        node.removeAttribute("effectOut")
 
77
else:
 
78
        if node.hasAttribute("effectOut"):
 
79
                node.removeAttribute("effectOut")
 
80
 
 
81
# Output XML file
 
82
sys.stdout.write(domDoc.toxml())
 
83