Example #1
0
class ClassSourceTemplate():
    file_template = FileTemplate(File.read(cpp_tools_resources_directory/"class_source.template"))

    @classmethod
    def instantiate_with(cls, project_name):
        return cls.file_template.instantiate_with(cls.create_replacement_rules(project_name))

    @staticmethod
    def create_replacement_rules(project_name):
        return {"project_name_": str(project_name)}
class ClassTests():
    def __init__(self, template_, license_header_):
        self.template = FileTemplate(template_)
        self.license_header = license_header_.instantiate_for_cpp()

    def instantiate_with(self, class_name):
        return self.license_header + self.template.instantiate_with(
            self.create_replacement_rules(class_name))

    @staticmethod
    def create_replacement_rules(class_name):
        return {"class_name_": str(class_name)}
class LicenseHeaderTemplate():
    file_template = FileTemplate(
        File.read(cpp_tools_resources_directory / "license_header.template"))

    @classmethod
    def instantiate_with(cls, project_name, author):
        return cls.file_template.instantiate_with(
            cls.create_replacement_rules(project_name, author))

    @staticmethod
    def create_replacement_rules(project_name, author):
        return {"project_name_": project_name, "author_": author}
Example #4
0
class LicenseHeader():
    def __init__(self, template_):
        self.template = FileTemplate(template_)

    def instantiate(self):
        return self.template.instantiate_with(self.create_replacement_rules())

    def instantiate_for_cmakelists(self):
        instance = ""
        for line in self.instantiate().splitlines():
            instance += ("# " + line + "\n")
        return instance + "\n"

    def instantiate_for_cpp(self):
        instance = self.instantiate()
        if instance[-1] == "\n": instance = instance[:-1]
        return "/* " + instance + " */\n\n"

    @staticmethod
    def create_replacement_rules():
        return {"year_": str(datetime.now().year)}
 def __init__(self, template_, license_header_):
     self.template = FileTemplate(template_)
     self.license_header = license_header_.instantiate_for_cpp()
 def test_instantiate_with(self):
     self.assert_equals(
         self.instance,
         FileTemplate(self.template).instantiate_with(
             self.replacement_rules))
Example #7
0
 def __init__(self, template_):
     self.template = FileTemplate(template_)
 def instantiate_with(cls,
                      project_name,
                      template_path=cpp_tools_resources_directory /
                      template_file_name):
     return FileTemplate(File.read(template_path)).instantiate_with(
         cls.create_replacement_rules(project_name))