Esempio n. 1
0
def create(args):
    caseFile, caseDirs = find_cases(args.cases)

    for caseDir in caseDirs:
        exp = Expander(caseDir)
        for test in exp.expand('utf-8', caseFile):
            if args.out:
                try:
                    test_file = os.path.join(args.out, test.file_name)
                    test_mtime = os.path.getmtime(test_file)

                    if args.no_clobber:
                        print_error(
                            'Refusing to overwrite file: ' + test.file_name)
                        exit(1)

                    if not args.regenerate:
                        source_files = test.source_file_names
                        if all(test_mtime > os.path.getmtime(f) for f in source_files):
                            continue

                    existing = Test(test_file)
                    existing.load()
                    if not existing.is_generated():
                        print_error(
                            'Refusing to overwrite non-generated file: ' +
                            test.file_name)
                        exit(1)
                except (OSError, IOError):
                    pass

                test.write(args.out, parents=args.parents)
            else:
                print(test.to_string())
Esempio n. 2
0
def create(args):
    caseFile, caseDirs = find_cases(args.cases)

    for caseDir in caseDirs:
        exp = Expander(caseDir)
        for test in exp.expand('utf-8', caseFile):
            if args.out:
                try:
                    existing = Test(test.file_name)
                    existing.load(args.out)

                    if args.no_clobber:
                        print_error(
                            'Refusing to overwrite file: ' + test.file_name)
                        exit(1)

                    if not existing.is_generated():
                        print_error(
                            'Refusing to overwrite non-generated file: ' +
                            test.file_name)
                        exit(1)
                except IOError:
                    pass

                test.write(args.out, parents=args.parents)
            else:
                print(test.to_string())
Esempio n. 3
0
def create(args):
    caseFile, caseDirs = find_cases(args.cases)

    for caseDir in caseDirs:
        exp = Expander(caseDir)
        for test in exp.expand('utf-8', caseFile):
            if args.out:
                try:
                    existing = Test(test.file_name)
                    existing.load(args.out)

                    if args.no_clobber:
                        print_error('Refusing to overwrite file: ' +
                                    test.file_name)
                        exit(1)

                    if not existing.is_generated():
                        print_error(
                            'Refusing to overwrite non-generated file: ' +
                            test.file_name)
                        exit(1)
                except IOError:
                    pass

                test.write(args.out, parents=args.parents)
            else:
                print(test.to_string())
Esempio n. 4
0
def clean(args):
    for (subdir, _, fileNames) in os.walk(args.directory):
        for fileName in map(lambda x: os.path.join(subdir, x), fileNames):
            test = Test(fileName)
            test.load()
            if test.is_generated():
                print('Deleting file "' + fileName + '"...')
                os.remove(fileName)
Esempio n. 5
0
def clean(args):
    for (subdir, _, fileNames) in os.walk(args.directory):
        for fileName in map(lambda x: os.path.join(subdir, x), fileNames):
            test = Test(fileName)
            test.load()
            if test.is_generated():
                print('Deleting file "' + fileName + '"...')
                os.remove(fileName)