62 lines
2.4 KiB
Python
Executable File
62 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright (C) 2008-14 Dr. Ralf Schlatterbeck Open Source Consulting.
|
|
# Reichergasse 131, A-3411 Weidling.
|
|
# Web: http://www.runtux.com Email: office@runtux.com
|
|
# All rights reserved
|
|
# ****************************************************************************
|
|
#
|
|
# This library is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU Library General Public License as
|
|
# published by the Free Software Foundation; either version 2 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Library General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Library General Public
|
|
# License along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
# ****************************************************************************
|
|
|
|
import sys
|
|
from optparse import OptionParser
|
|
from StringIO import StringIO
|
|
from ooopy.OOoPy import OOoPy
|
|
from ooopy.Transformer import Transformer
|
|
import ooopy.Transforms as Transforms
|
|
|
|
if __name__ == '__main__' :
|
|
usage = '%prog [-o|--output-file <filename>] [file, ...]'
|
|
parser = OptionParser (usage = usage)
|
|
parser.add_option \
|
|
( "-o", "--output-file"
|
|
, dest = "output_file"
|
|
, help = "Output file (defaults to stdout)"
|
|
, default = None
|
|
)
|
|
(options, args) = parser.parse_args ()
|
|
if len (args) < 1 :
|
|
infiles = [StringIO (sys.stdin.read ())]
|
|
else :
|
|
infiles = args
|
|
outfile = options.output_file
|
|
if outfile is None :
|
|
outfile = StringIO ()
|
|
o = OOoPy (infile = infiles [0], outfile = outfile)
|
|
if len (infiles) > 1 :
|
|
t = Transformer \
|
|
( o.mimetype
|
|
, Transforms.get_meta (o.mimetype)
|
|
, Transforms.Concatenate (* (infiles [1:]))
|
|
, Transforms.renumber_all (o.mimetype)
|
|
, Transforms.set_meta (o.mimetype)
|
|
, Transforms.Fix_OOo_Tag ()
|
|
, Transforms.Manifest_Append ()
|
|
)
|
|
t.transform (o)
|
|
o.close ()
|
|
if options.output_file is None :
|
|
sys.stdout.write (outfile.getvalue ())
|