Exemplo n.º 1
0
 def inject(self):
     for file in recursive_path_iterate(self.path, "*"):
         with open(file) as file_pointer:
             content = file_pointer.read()
         template = DottedTemplate(content)
         with open(file, "w") as file_pointer:
             file_pointer.write(template.substitute(self.config))
Exemplo n.º 2
0
    def create(self, directory):
        setup_py_template = DottedTemplate(SETUP_PY_TEMPLATE)
        setup_py = setup_py_template.substitute(self.config)

        additional_options = self._get_additional_options()
        setup_py = setup_py.format(additional_options=additional_options)

        with open(os.path.join(directory, PythonSetupPyCreator.FILE_NAME), "w") as setup_py_pointer:
            setup_py_pointer.write(setup_py)
Exemplo n.º 3
0
    def create(self, directory):
        setup_py_template = DottedTemplate(SETUP_PY_TEMPLATE)
        setup_py = setup_py_template.substitute(self.config)

        additional_options = self._get_additional_options()
        setup_py = setup_py.format(additional_options=additional_options)

        with open(os.path.join(directory, PythonSetupPyCreator.FILE_NAME),
                  "w") as setup_py_pointer:
            setup_py_pointer.write(setup_py)
Exemplo n.º 4
0
def test_transform_dictionary():
    my_dict = {"key1": "value", "key1.key2": "value2", "key1.key2.key3": "value3"}
    expected_dict = {"${key1}": "value", "${key1.key2}": "value2", "${key1.key2.key3}": "value3"}

    transformed_dict = DottedTemplate.transform_dictionary(my_dict)

    assert expected_dict == transformed_dict
Exemplo n.º 5
0
def test_transform_dictionary():
    my_dict = {
        "key1": "value",
        "key1.key2": "value2",
        "key1.key2.key3": "value3"
    }
    expected_dict = {
        "${key1}": "value",
        "${key1.key2}": "value2",
        "${key1.key2.key3}": "value3"
    }

    transformed_dict = DottedTemplate.transform_dictionary(my_dict)

    assert expected_dict == transformed_dict
Exemplo n.º 6
0
 def _set_references(config):
     for key, value in config.items():
         if isinstance(value, str):
             value_template = DottedTemplate(value)
             value = value_template.substitute(config)
             config[key] = value
Exemplo n.º 7
0
def test_dotted_template():
    template = DottedTemplate("Hello ${project.name}.")

    result = template.substitute({"project.name": "World"})

    assert "Hello World." == result
Exemplo n.º 8
0
def test_multiple_dots():
    template = DottedTemplate("Hello ${base.project.name}.")

    result = template.substitute({"base.project.name": "World"})

    assert "Hello World." == result
Exemplo n.º 9
0
 def _set_references(config):
     for key, value in config.items():
         if isinstance(value, str):
             value_template = DottedTemplate(value)
             value = value_template.substitute(config)
             config[key] = value
Exemplo n.º 10
0
def test_dotted_template():
    template = DottedTemplate("Hello ${project.name}.")

    result = template.substitute({"project.name": "World"})

    assert "Hello World." == result
Exemplo n.º 11
0
def test_multiple_dots():
    template = DottedTemplate("Hello ${base.project.name}.")

    result = template.substitute({"base.project.name": "World"})

    assert "Hello World." == result
Exemplo n.º 12
0
    def create(self, directory):
        setup_cfg_template = DottedTemplate(SETUP_CFG_TEMPLATE)

        with open(os.path.join(directory, "setup.cfg"),
                  "w") as setup_cfg_pointer:
            setup_cfg_pointer.write(setup_cfg_template.substitute(self.config))