Exemplo n.º 1
0
def main(filepath, *a, **kw):
    filelist = txlparser.get_file_list(filepath)

    interactive = True
    if os.path.isdir(filepath):
        interactive = False
        kw['unparse'] = True

    def write(msg):
        if not interactive:
            io.output(msg)

    failures = 0
    for fp in filelist:
        success = True
        try:
            process_file(fp, *a, **kw)
        except:
            success = False
            if interactive:
                raise

        lab = "SUCCEEDED"
        if not success:
            failures += 1
            lab = "FAILED"
        localname = io.relpath(fp, relative_to=filepath)
        localname = localname == "." and filepath or localname
        write("%-9.9s  %s\n" % (lab.upper(), localname))
    write("Processed %s files, %s failed\n" % (len(filelist), failures))

    exitcode = failures > 0 and 1 or 0
    return exitcode
Exemplo n.º 2
0
def inject(filepath, skiplist=None):
    filelist = txlparser.get_file_list(filepath)
    count = len(filelist)
    for (i, fp) in enumerate(filelist):
        localname = io.relpath(fp, relative_to=filepath)
        localname = localname == "." and filepath or localname
        if localname in skiplist:
            io.output("Skip file (%s/%s) %s\n" % (i+1, count, localname))
        else:
            io.output("Inject into (%s/%s) %s\n" % (i+1, count, localname))
            inject_into_file(fp, localname)