Пример #1
0
def initialize():
    from fortpy.msg import set_verbosity
    set_verbosity(args["verbose"])
    
    comparer = FileComparer(template_folder=args["templates"])
    result = comparer.compare(args["source"], args["target"], args["xmltemplate"], args["mode"])

    if args["save"]:
        from os import path
        fullpath = path.abspath(path.expanduser(args["save"]))
        with open(fullpath, "w") as f:
            f.write(print_compare_result(result, args["verbose"]))
    else:
        print((print_compare_result(result, args["verbose"])))

    return result
Пример #2
0
class OutputConverter(object):
    """Converts plain-text output files between versions."""
    def __init__(self, template_dir):
        self.comparer = FileComparer(os.path.expanduser(template_dir))

    def convert(self, path, version, target):
        """Converts the specified source file to a new version number."""
        source = self.comparer.get_representation(path)
        lines = [ '# <fortpy version="{}"></fortpy>\n'.format(version) ]

        for line in self.comparer.template.contents[version].preamble:
            lines.append(line.write(source.preamble, source.version, source.stored) + "\n")

        for line in self.comparer.template.contents[version].body:
            for valueset in source.body:
                lines.append(line.write(valueset, source.version, source.stored) + "\n")

        with open(os.path.expanduser(target), 'w') as f:
            f.writelines(lines)
Пример #3
0
class OutputConverter(object):
    """Converts plain-text output files between versions."""
    def __init__(self, template_dir):
        self.comparer = FileComparer(os.path.expanduser(template_dir))

    def convert(self, path, version, target):
        """Converts the specified source file to a new version number."""
        source = self.comparer.get_representation(path)
        lines = ['# <fortpy version="{}"></fortpy>\n'.format(version)]

        for line in self.comparer.template.contents[version].preamble:
            lines.append(
                line.write(source.preamble, source.version, source.stored) +
                "\n")

        for line in self.comparer.template.contents[version].body:
            for valueset in source.body:
                lines.append(
                    line.write(valueset, source.version, source.stored) + "\n")

        with open(os.path.expanduser(target), 'w') as f:
            f.writelines(lines)
Пример #4
0
 def __init__(self, template_dir):
     self.comparer = FileComparer(os.path.expanduser(template_dir))
Пример #5
0
 def __init__(self, template_dir):
     self.comparer = FileComparer(os.path.expanduser(template_dir))