# Add pictures/
    _add_pictures(document, output_doc)


def print_incompatible(filename, type):
    printerr('Cannot merge "%s" in %s document, skipping.' % (filename, type))


if __name__ == '__main__':
    # Options initialisation
    usage = "%prog -o FILE <file1> [<file2> ...]"
    description = "Merge all input files in an unique OpenDocument file"
    parser = OptionParser(usage, version=__version__, description=description)
    # --output
    add_option_output(parser, complement='("-" for stdout)')

    # Parse !
    options, filenames = parser.parse_args()

    # Arguments
    if not filenames:
        parser.print_help()
        exit(1)
    target = options.output
    if target is None:
        printerr('"-o" option mandatory (use "-" to print to stdout)')
        exit(1)
    check_target_file(target)

    output_doc = None
Exemple #2
0
    # --color
    help = ("the name or #rrggbb color of the font color: black, blue, "
            "brown, cyan, green, grey, magenta, orange, pink, red, violet, "
            "white, yellow or none (default)")
    parser.add_option('-c', '--color', default='none', metavar='COLOR',
            help=help)
    # --background
    help = ("the name or #rrggbb color of the background color: black, "
            "blue, brown, cyan, green, grey, magenta, orange, pink, red, "
            "violet, white, yellow (default) or none")
    parser.add_option('-g', '--background', default='yellow',
            metavar='BACKGROUND', help=help)
    # --italic
    parser.add_option('-i', '--italic', dest='italic', action='store_true',
            default=False, help='set the italic font style')
    # --bold
    parser.add_option('-b', '--bold', dest='bold', action='store_true',
            default=False, help='set the bold font weight')
    # --output
    add_option_output(parser)
    # Parse options
    options, args = parser.parse_args()
    if len(args) != 2:
        parser.print_help()
        exit(1)
    odf_file_url, pattern = args
    pattern = unicode(pattern, stdin.encoding)
    document = odf_get_document(odf_file_url)
    highlight(document, pattern, options.color, options.background,
            options.italic, options.bold, target=options.output)
 parser.add_option('-c', '--common', action='store_true', default=False,
         help="show common styles only")
 # --properties
 parser.add_option('-p', '--properties', action='store_true',
         help="show properties of styles")
 # --delete
 help = ("return a copy with all styles (except default) deleted from "
         "<file>")
 parser.add_option('-d', '--delete', action='store_true', help=help)
 # --merge
 help = ('copy styles from FILE to <file>. Any style with the same name '
         'will be replaced.')
 parser.add_option('-m', '--merge-styles-from', dest='merge',
         metavar='FILE', help=help)
 # --output
 add_option_output(parser)
 # Parse options
 options, args = parser.parse_args()
 if len(args) != 1:
     parser.print_help()
     exit(1)
 document = odf_get_document(args[0])
 if options.delete:
     target = options.output
     if target is None:
         printerr("Will not delete in-place: ",
                 'output file needed or "-" for stdout')
         exit(1)
     elif target == "-":
         target = StdoutWriter()
     else:
Exemple #4
0
    for level, text, struct in structure:
        # Create the heading with the corresponding level
        heading = odf_create_heading(level, text=text)
        # Add the heading to the document's body
        body.append(heading)
        make_document(struct, body)



if  __name__ == '__main__':
    # Options initialisation
    usage = '%prog [-o output.odt] <input.mm>'
    description = 'Transform a mind-map file to an OpenDocument Text file.'
    parser = OptionParser(usage, version=__version__, description=description)
    # --output
    add_option_output(parser, complement="(<file>.odt by default)")

    # Parse options
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        exit(1)

    # Get the 2 paths
    inname = args[0]
    outname = options.output
    # Default value for the name of the output file.
    if not outname:
        mm_basename = basename(inname)
        outname = '%s.odt' % splitext(mm_basename)[0]
    # Check if the file already exists
Exemple #5
0
 parser = OptionParser(usage, version=__version__,
         description=description)
 # --meta
 parser.add_option('-m', '--meta', action='store_true', default=False,
         help='dump metadata to stdout')
 # --styles
 parser.add_option('-s', '--styles', action='store_true', default=False,
         help='dump styles to stdout')
 # --no-content
 parser.add_option('-n', '--no-content', action='store_true',
         default=False, help='do not dump content to stdout')
 # --rst
 parser.add_option('-r', '--rst', action='store_true', default=False,
         help='Dump the content file with a reST syntax')
 # --output
 add_option_output(parser, metavar="DIR")
 # Parse !
 options, args = parser.parse_args()
 # Container
 if len(args) != 1:
     parser.print_help()
     exit(1)
 container_url = args[0]
 # Open it!
 document = odf_get_document(container_url)
 doc_type = document.get_type()
 # Test it! XXX for TEXT only
 if doc_type == 'text':
     result = test_document(document)
     if result is not True:
         print 'This file is malformed: %s' % result
Exemple #6
0


def print_incompatible(filename, type):
    printerr('Cannot merge "%s" in %s document, skipping.' % (filename, type))



if  __name__ == '__main__':
    # Options initialisation
    usage = "%prog -o FILE <file1> [<file2> ...]"
    description = "Merge all input files in an unique OpenDocument file"
    parser = OptionParser(usage, version=__version__,
            description=description)
    # --output
    add_option_output(parser, complement='("-" for stdout)')

    # Parse !
    options, filenames = parser.parse_args()

    # Arguments
    if not filenames:
        parser.print_help()
        exit(1)
    target = options.output
    if target is None:
        printerr('"-o" option mandatory (use "-" to print to stdout)')
        exit(1)
    check_target_file(target)

    output_doc = None
Exemple #7
0
                   default=False,
                   help='dump styles to stdout')
 # --no-content
 parser.add_option('-n',
                   '--no-content',
                   action='store_true',
                   default=False,
                   help='do not dump content to stdout')
 # --rst
 parser.add_option('-r',
                   '--rst',
                   action='store_true',
                   default=False,
                   help='Dump the content file with a reST syntax')
 # --output
 add_option_output(parser, metavar="DIR")
 # Parse !
 options, args = parser.parse_args()
 # Container
 if len(args) != 1:
     parser.print_help()
     exit(1)
 container_url = args[0]
 # Open it!
 document = odf_get_document(container_url)
 doc_type = document.get_type()
 # Test it! XXX for TEXT only
 if doc_type == 'text':
     result = test_document(document)
     if result is not True:
         print('This file is malformed: %s' % result)
def make_document(structure, body):
    for level, text, struct in structure:
        # Create the heading with the corresponding level
        heading = odf_create_heading(level, text=text)
        # Add the heading to the document's body
        body.append(heading)
        make_document(struct, body)


if __name__ == '__main__':
    # Options initialisation
    usage = '%prog [-o output.odt] <input.mm>'
    description = 'Transform a mind-map file to an OpenDocument Text file.'
    parser = OptionParser(usage, version=__version__, description=description)
    # --output
    add_option_output(parser, complement="(<file>.odt by default)")

    # Parse options
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        exit(1)

    # Get the 2 paths
    inname = args[0]
    outname = options.output
    # Default value for the name of the output file.
    if not outname:
        mm_basename = basename(inname)
        outname = '%s.odt' % splitext(mm_basename)[0]
    # Check if the file already exists