示例#1
0
文件: kernel.py 项目: ringw/reikna
    def create(cls, func_or_str, render_kwds=None):
        """
        Creates a snippet from the ``Mako`` def:

        * if ``func_or_str`` is a function, then the def has the same signature as ``func_or_str``,
          and the body equal to the string it returns;
        * if ``func_or_str`` is a string, then the def has empty signature.
        """
        signature, code = extract_signature_and_value(func_or_str)
        return cls(template_def(signature, code), render_kwds=render_kwds)
示例#2
0
    def create(cls, func_or_str, render_kwds=None):
        """
        Creates a snippet from the ``Mako`` def:

        * if ``func_or_str`` is a function, then the def has the same signature as ``func_or_str``,
          and the body equal to the string it returns;
        * if ``func_or_str`` is a string, then the def has empty signature.
        """
        signature, code = extract_signature_and_value(func_or_str)
        return cls(template_def(signature, code), render_kwds=render_kwds)
示例#3
0
文件: kernel.py 项目: ringw/reikna
    def create(cls, func_or_str, render_kwds=None):
        """
        Creates a module from the ``Mako`` def:

        * if ``func_or_str`` is a function, then the def has the same signature as ``func_or_str``
          (prefix will be passed as the first positional parameter),
          and the body equal to the string it returns;
        * if ``func_or_str`` is a string, then the def has a single positional argument ``prefix``.
          and the body ``code``.
        """
        signature, code = extract_signature_and_value(func_or_str, default_parameters=["prefix"])
        return cls(template_def(signature, code), render_kwds=render_kwds)
示例#4
0
    def create(cls, func_or_str, render_kwds=None):
        """
        Creates a module from the ``Mako`` def:

        * if ``func_or_str`` is a function, then the def has the same signature as ``func_or_str``
          (prefix will be passed as the first positional parameter),
          and the body equal to the string it returns;
        * if ``func_or_str`` is a string, then the def has a single positional argument ``prefix``.
          and the body ``code``.
        """
        signature, code = extract_signature_and_value(
            func_or_str, default_parameters=['prefix'])
        return cls(template_def(signature, code), render_kwds=render_kwds)