250
  "   ˆl–ß=¿J*e¶¥8 ƒq¶n	õ1hßÃƒh¹ÂÁ      13:32
  "   	ˆl–ß=¿J*hŠ}A
àAq§Å£ÄƒÃÂ     	import os
import tuned.logs
from tuned.utils.commands import commands

log = tuned.logs.get()

class Function(object):
	"""
	Built-in function
	"""
	def __init__(self, name, nargs_max, nargs_min = None):
		self._name = name
		self._nargs_max = nargs_max
		self._nargs_min = nargs_min
		self._cmd = commands()

	# checks arguments
	# nargs_max - maximal number of arguments, there mustn't be more arguments,
	#             if nargs_max is 0, number of arguments is unlimited
	# nargs_min - minimal number of arguments, if not None there must
	#             be the same number of arguments or more
	@classmethod
	def _check_args(cls, args, nargs_max, nargs_min = None):
		if args is None or nargs_max is None:
			return False
		la = len(args)
		return (nargs_max == 0 or nargs_max == la) and (nargs_min is None or nargs_min <= la)

	def execute(self, args):
		if self._check_args(args, self._nargs_max, self._nargs_min):
			return True
		else:
			log.error("invalid number of arguments for builtin function '%s'" % self._name)
		return False
  #   ˆl–Ãa¾”Ê:”ÒÀµq¦TÅ£Å„x?ÄÃ (    # -*- coding: utf-8 -*-
"""
    jinja2.testsuite.api
    ~~~~~~~~~~~~~~~~~~~~

    Tests the public API and related stuff.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
"""
import unittest
import os
import tempfile
import shutil

from jinja2.testsuite import JinjaTestCase
from jinja2._compat import next

from jinja2 import Environment, Undefined, DebugUndefined, \
     StrictUndefined, UndefinedError, meta, \
     is_undefined, Template, DictLoader
from jinja2.utils import Cycler

env = Environment()


class ExtendedAPITestCase(JinjaTestCase):

    def test_item_and_attribute(self):
        from jinja2.sandbox import SandboxedEnvironment

        for env in Environment(), SandboxedEnvironment():
            # the |list is necessary for python3
            tmpl = env.from_string('{{ foo.items()|list }}')
            assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
            tmpl = env.from_string('{{ foo|attr("items")()|list }}')
            assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
            tmpl = env.from_string('{{ foo["items"] }}')
            assert tmpl.render(foo={'items': 42}) == '42'

    def test_finalizer(self):
        def finalize_none_empty(value):
            if value is None:
                value = u''
            return value
        env = Environment(finalize=finalize_none_empty)
        tmpl = env.from_string('{% for item in seq %}|{{ item }}{% endfor %}')
        assert tmpl.render(seq=(None, 1, "foo")) == '||1|foo'
        tmpl = env.from_string('<{{ none }}>')
        assert tmpl.render() == '<>'

    def test_cycler(self):
        items = 1, 2, 3
        c = Cycler(*items)
        for item in items + items:
            assert c.current == item
            assert next(c) == item
        next(c)
        assert c.current == 2
        c.reset()
        assert c.current == 1

    def test_expressions(self):
        expr = env.compile_expression("foo")
        assert expr() is None
        assert expr(foo=42) == 42
        expr2 = env.compile_expression("foo", undefined_to_none=False)
        assert is_undefined(expr2())

        expr = env.compile_expression("42 + foo")
        assert expr(foo=42) == 84

    def test_template_passthrough(self):
        t = Template('Content')
        assert env.get_template(t) is t
        assert env.select_template([t]) is t
        assert env.get_or_select_template([t]) is t
        assert env.get_or_select_template(t) is t

    def test_autoescape_autoselect(self):
        def select_autoescape(name):
            if name is None or '.' not in name:
                return False
            return name.endswith('.html')
        env = Environment(autoescape=select_autoescape,
                          loader=DictLoader({
            'test.txt':     '{{ foo }}',
            'test.html':    '{{ foo }}'
       