Ejemplo n.º 1
0
    def update_arguments(template: Template, args: dict, overwrite=False):
        """
        Updates the arguments of the given template with the values of the given dict (args)

        Args:
            template: Template that should be updated
            args(dict): Dict containing the arguments that should be set. key=argument name, value=argument value
            overwrite(bool): If True existing values will be overwritten

        Returns:
            Nothing
        """
        for key, value in args.items():
            if template.has_arg(key):
                # update argument
                if overwrite:
                    template.del_arg(key)
                    template.set_arg(key, value)
                else:
                    pass
            else:
                if value is not None:
                    template.set_arg(key, value, preserve_spacing=False)
Ejemplo n.º 2
0
def test_del_positional_arg():
    t = Template('{{t| a | b | 2 = c | d }}')
    t.del_arg('2')
    assert '{{t| a | d }}' == t.string
Ejemplo n.º 3
0
 def test_del_positional_arg(self):
     t = Template('{{t| a | b | 2 = c | d }}')
     t.del_arg('2')
     self.assertEqual('{{t| a | d }}', t.string)