~inkscape.dev/inkscape/doc_rotate

« back to all changes in this revision

Viewing changes to share/extensions/hpgl_output.py

  • Committer: jabiertxof
  • Date: 2017-01-24 17:52:08 UTC
  • Revision ID: info@marker.es-20170124175208-k6beeorqwjh4g8bv
Put namespace as constant

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        self.OptionParser.add_option('--precut',        action='store', type='inkbool', dest='precut',        default='TRUE',  help='Use precut')
46
46
        self.OptionParser.add_option('--flat',          action='store', type='float',   dest='flat',          default=1.2,     help='Curve flatness')
47
47
        self.OptionParser.add_option('--autoAlign',     action='store', type='inkbool', dest='autoAlign',     default='TRUE',  help='Auto align')
 
48
        self.DOCROTATE = "{http://www.inkscape.org/namespaces/inkscape}document_rotation"
48
49
 
49
50
    def effect(self):
50
51
        self.options.debug = False
54
55
        nv = svg.xpath(xpathStr, namespaces=NSS)
55
56
        document_rotate = "0"
56
57
        if nv != []:
57
 
            document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation")
58
 
            nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0")
 
58
            document_rotate = nv[0].get(self.DOCROTATE)
 
59
            nv[0].set(self.DOCROTATE,"0")
59
60
        myHpglEncoder = hpgl_encoder.hpglEncoder(self)
60
61
        try:
61
62
            self.hpgl, debugObject = myHpglEncoder.getHpgl()
65
66
                inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths."))
66
67
                self.hpgl = ''
67
68
                if nv != [] and document_rotate:
68
 
                    nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate)
 
69
                    nv[0].set("inkscape:document_rotation",document_rotate)
69
70
                return
70
71
            else:
71
72
                type, value, traceback = sys.exc_info()
72
73
                if nv != [] and document_rotate:
73
 
                    nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate)
 
74
                    nv[0].set("inkscape:document_rotation",document_rotate)
74
75
                raise ValueError, ("", type, value), traceback
75
76
        # convert raw HPGL to HPGL
76
77
        hpglInit = 'IN'
80
81
            hpglInit += ';VS%d' % self.options.speed
81
82
        self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; '
82
83
        if nv != [] and document_rotate:
83
 
            nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate)
 
84
            nv[0].set("inkscape:document_rotation",document_rotate)
84
85
 
85
86
    def output(self):
86
87
        # print to file