code: def load_variables(variables, config):
      
  
      def macro(v, name=''):
          """
          Registers a variable as a macro in the template,
          i.e. in the variables dictionary:
  
              macro(myfunc)
  
          Optionally, you can assign a different name:
  
              macro(myfunc, 'funcname')
  
  
          You can also use it as a decorator:
  
          @macro
          def foo(a):
              return a ** 2
  
          More info:
          https://stackoverflow.com/questions/6036082/call-a-python-function-from-jinja2
          """
  
          name = name or v.__name__
          variables[name] = v
          return v
  
  
  
      # determine the package name, from the filename:
      python_module = config.get('python_module') or DEFAULT_MODULE_NAME
      # get the directory of the yaml file:
      config_file = config['config_file_path']
      yaml_dir = os.path.dirname(config_file)
      # print("Found yaml directory: %s" % yaml_dir)
  
      # that's the directory of the package:
      repackage.add(yaml_dir)
      try:
          module = importlib.import_module(python_module)
          print("Found module '%s'" % python_module)
          # execute the hook, passing the template decorator function
          module.declare_variables(variables, macro)
      except ModuleNotFoundError:
          print("No module found.")
docs: Add the template functions, via the python module
      located in the same directory as the Yaml config file.
  
      The python module must contain the following hook:
  
      declare_variables(variables, macro):
  
          variables['a'] = 5
  
  
          @macro
          def bar(x):
              ....
  
          @macro
          def baz(x):
              ....