コード例 #1
0
def writeCodeTag(args):
    out = openOutput(args)
    if not args.input:
        eprint('Writing %s requires --input' % args.mode)
        return 1

    argsList = [args.input, args.output]
    result = CodeTags.main(argsList, getNewline(args))
    return 0
コード例 #2
0
def RunCodeTagUpdate(file_path):
    import os
    import CodeTags
    print(" ... updating " + file_path)
    args = [file_path, file_path + ".tmp"]
    result = CodeTags.main(args)
    if result != 0:
        print(" ... error: %d" % result)
    else:
        with open(file_path, 'rt') as f:
            before = f.read()
        with open(file_path + ".tmp", 'rt') as f:
            after = f.read()
        if before == after:
            print("  --- no changes found")
        else:
            print("  +++ changes found, updating file")
            with open(file_path, 'wt') as f:
                f.write(after)
        os.remove(file_path + ".tmp")