Ejemplo n.º 1
0
def main():
    try:
        from optparse import OptionParser
        opts = OptionParser()
        opts.add_option("-t", "--template", dest="template_path",   help="input ODT template file path")
        opts.add_option("-x", "--xml",      dest="xml_path",        help="input XML parameters file path")
        opts.add_option("-o", "--output",   dest="result_path",     help="output ODT result file path")
        opts.add_option("-v", "--version",  action="store_true", dest="version", default=False, help="print current version")
        (options, args) = opts.parse_args()
        if options.version:
            print VERSION
            return
        if options.template_path:
            template_path = options.template_path
        else:
            print 'ERROR: template path not specified. Use --help for command line arguments help.'
            return
        if options.xml_path:
            xml_path = options.xml_path
        else:
            print 'ERROR: xml path not specified. Use --help for command line arguments help.'
            return
        if options.result_path:
            result_path = options.result_path
        else:
            print 'WARNING: result path not specified. Use --help for command line arguments help.'
            result_path = os.path.join(os.path.dirname(xml_path), u'%s_%s.odt' % (basefilename(template_path), basefilename(xml_path)))
            print 'Using "%s" by default.' % (result_path,)
        DoDoc(template_path, xml_path, result_path)
    except Exception, e:
        import traceback
        import DoDoc_error_reporter
        DoDoc_error_reporter.reportError(traceback.format_exc(30))
Ejemplo n.º 2
0
def odt2pdf(input, output):
    try:
        o = Odt2pdf()
        if o.connect():
            if o.open(input):
                o.savePDF(output)
                o.close()
        o.disconnect()
    except Exception, e:
        import traceback
        import DoDoc_error_reporter
        DoDoc_error_reporter.reportError(traceback.format_exc(30))
Ejemplo n.º 3
0
def odg2wmf(input, output):
    result = None
    try:
        o = Odg2wmf()
        if o.connect():
            if o.open(input):
                result = o.saveWMF(output)
                o.close()
        o.disconnect()
    except Exception, e:
        import traceback
        import DoDoc_error_reporter
        DoDoc_error_reporter.reportError(traceback.format_exc(30))
Ejemplo n.º 4
0
def main():
    try:
        import sys
        if len(sys.argv) == 2:
            input = sys.argv[1]
        else:
            print 'countPages prints to stdout amount of pages in passed document.'
            print 'Following document types are accepted: .odt, .odg'
            print 'Usage:'
            print '    python countPages input_filename'
            return
            input = 'Manual_.odt'
        countPages(input)
    except Exception, e:
        import traceback
        import DoDoc_error_reporter
        DoDoc_error_reporter.reportError(traceback.format_exc(30))