Example #1
0
def main():
    parser = OptionParser(usage="usage: %prog [options] css img")

    parser.add_option("-m",
                      "--minified",
                      action="store_true",
                      dest="minified",
                      help="Minifi the css.")

    parser.add_option("--sha1",
                      action="store_true",
                      dest="sha1",
                      help=("Use sha1 insted the mtime (Most recent content "
                            "modification)"))

    parser.add_option("-v",
                      "--version",
                      action="store_true",
                      dest="version",
                      help="show program's version number and exit")

    (options, args) = parser.parse_args()

    if options.version:
        sys.stdout.write("%s\n" % __version__)
        sys.exit(0)

    if len(args) == 0:
        parser.error("You must provide a css file ")
    elif len(args) == 1:
        parser.error(("You must provide the relative path between "
                      "the css and the images."))

    css_path = os.path.basename(args[0])
    img_rel_path = args[1]

    # Configure the logger
    log = logging.getLogger('csscache')
    handler = logging.StreamHandler(sys.stderr)
    handler.setLevel(logging.ERROR)
    log.addHandler(handler)

    if options.minified:
        cssutils.ser.prefs.useMinified()

    # Create the parser
    parser = cssutils.CSSParser(log=log,
                                raiseExceptions=True,
                                parseComments=not options.minified,
                                validate=False)
    try:
        # Parse the original file
        sheet = parser.parseFile(args[0])
    except Exception, e:
        sys.stderr.write('Error: %s %s\n' % (css_path, e.args[0]))
        sys.exit(1)
Example #2
0
def main():
    usage = "usage: %prog <tree file> <output graphviz .dot file> <output tree file>"
    description = "TEST: convert newick tree to graphviz tree"
    parser = OptionParser(usage=usage, description=description)
    options, args = parser.parse_args()

    if len(args) != 3:
        parser.print_help()
        raise RuntimeError("Wrong number of arguments")

    parser = NXNewick()
    parser.parseFile(args[0])
    NX.drawing.nx_agraph.write_dot(parser.nxTree.nxDg, args[1])
    parser.writeFile(args[2])
    print "PRE"
    for i in parser.nxTree.preOrderTraversal():
        print("%d %s" % (i, parser.nxTree.getName(i)))
    print "POST"
    for i in parser.nxTree.postOrderTraversal():
        print("%d %s" % (i, parser.nxTree.getName(i)))
    print "BFS"
    for i in parser.nxTree.breadthFirstTraversal():
        print("%d %s" % (i, parser.nxTree.getName(i)))
    return 0
Example #3
0
def main():
    usage = "usage: %prog <tree file> <output graphviz .dot file> <output tree file>"
    description = "TEST: convert newick tree to graphviz tree"
    parser = OptionParser(usage=usage, description=description)
    options, args = parser.parse_args()
    
    if len(args) != 3:
        parser.print_help()
        raise RuntimeError("Wrong number of arguments")

    parser = NXNewick()
    parser.parseFile(args[0])
    NX.drawing.nx_agraph.write_dot(parser.nxTree.nxDg, args[1])
    parser.writeFile(args[2])
    print "PRE"
    for i in parser.nxTree.preOrderTraversal():
        print ("%d %s" % (i, parser.nxTree.getName(i)))
    print "POST"
    for i in parser.nxTree.postOrderTraversal():
        print ("%d %s" % (i, parser.nxTree.getName(i)))
    print "BFS"
    for i in parser.nxTree.breadthFirstTraversal():
        print ("%d %s" % (i, parser.nxTree.getName(i)))
    return 0
Example #4
0
def main():
    parser = OptionParser(usage="usage: %prog [options] css img")

    parser.add_option("-m", "--minified", action="store_true", dest="minified",
                      help="Minifi the css.")

    parser.add_option("--sha1", action="store_true", dest="sha1",
                      help=("Use sha1 insted the mtime (Most recent content "
                            "modification)"))

    parser.add_option("-v", "--version", action="store_true", dest="version",
            help="show program's version number and exit")

    (options, args) = parser.parse_args()

    if options.version:
        sys.stdout.write("%s\n" % __version__)
        sys.exit(0)

    if len(args) == 0:
        parser.error("You must provide a css file ")
    elif len(args) == 1:
        parser.error(("You must provide the relative path between "
                      "the css and the images."))

    css_path = os.path.basename(args[0])
    img_rel_path = args[1]

    # Configure the logger
    log = logging.getLogger('csscache')
    handler = logging.StreamHandler(sys.stderr)
    handler.setLevel(logging.ERROR)
    log.addHandler(handler)

    if options.minified:
        cssutils.ser.prefs.useMinified()

    # Create the parser
    parser = cssutils.CSSParser(log=log,
                                raiseExceptions=True,
                                parseComments=not options.minified,
                                validate=False)
    try:
        # Parse the original file
        sheet = parser.parseFile(args[0])
    except Exception, e:
        sys.stderr.write('Error: %s %s\n' % (css_path, e.args[0]))
        sys.exit(1)