Skip to content
Myr

various docstring changes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 5236d8c · Browse files · 5 files+25 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+25 added−18 removed

  • other:+25 added−18 removed

5 files+25 added−18 removed

modified:jinja2/compiler.py+4 added-4 removed
422 unmodified lines
423 vars = ', '.join(sorted(overriden_closure_vars))424 raise TemplateAssertionError('It\'s not possible to set and '425 'access variables derived from '426 'an outer scope! (affects: %s' %427 vars, node.lineno, self.filename)427 vars, node.lineno, self.name)428429 # remove variables from a closure from the frame's undeclared430 # identifiers.431 func_frame.identifiers.undeclared -= (
30 unmodified lines
462 for block in node.find_all(nodes.Block):463 if block.name in self.blocks:464 raise TemplateAssertionError('block %r defined twice' %465 block.name, block.lineno,466 self.filename)466 self.name)467 self.blocks[block.name] = block468469 # generate the root render function.470 self.writeline('def root(globals, environment=environment'
73 unmodified lines
544 """Calls the extender."""545 if not frame.toplevel:546 raise TemplateAssertionError('cannot use extend from a non '547 'top-level scope', node.lineno,548 self.filename)548 self.name)549550 # if the number of extends statements in general is zero so551 # far, we don't have to add a check if something extended552 # the template before this one.
16 unmodified lines
569 self.outdent()570571 self.writeline('parent_root = environment.get_template(', node, 1)572 self.visit(node.template, frame)573 self.write(', %r).root_render_func' % self.filename)573 self.write(', %r).root_render_func' % self.name)574575 # if this extends statement was in the root level we can take576 # advantage of that information and simplify the generated code577 # in the top level from this point onwards
480 unmodified lines
modified:jinja2/environment.py+7 added-2 removed
130 unmodified lines
131 return self.lexer.tokeniter(source, name)132133 def compile(self, source, name=None, filename=None, raw=False,134 globals=None):135 """Compile a node or source."""135 """Compile a node or source. The name is the load name of the136 template after it was joined using `join_path` if necessary,137 filename is the estimated filename of the template on the file138 system. If the template came from a database or memory this139 can be omitted.140 """141 if isinstance(source, basestring):142 source = self.parse(source, name)143 if self.optimized:144 node = optimize(source, self, globals or {})145 source = generate(node, self, name, filename)146 if raw:147 return source148 if filename is None:144 filename = '<from_string>'149 filename = '<template>'150 elif isinstance(filename, unicode):151 filename = filename.encode('utf-8')152 return compile(source, filename, 'exec')153
140 unmodified lines
modified:jinja2/exceptions.py+6 added-6 removed
22 unmodified lines
23 IOError.__init__(self, name)24 self.name = name252627class TemplateSyntaxError(SyntaxError, TemplateError):27class TemplateSyntaxError(TemplateError):28 """29 Raised to tell the user that there is a problem with the template.30 """3132 def __init__(self, message, lineno, filename):33 SyntaxError.__init__(self, '%s (line %s)' % (message, lineno))32 def __init__(self, message, lineno, name):33 TEmplateError.__init__(self, '%s (line %s)' % (message, lineno))34 self.message = message35 self.lineno = lineno36 self.filename = filename36 self.name = name373839class TemplateAssertionError(AssertionError, TemplateSyntaxError):4041 def __init__(self, message, lineno, filename):41 def __init__(self, message, lineno, name):42 AssertionError.__init__(self, message)43 TemplateSyntaxError.__init__(self, message, lineno, filename)43 TemplateSyntaxError.__init__(self, message, lineno, name)444546class TemplateRuntimeError(TemplateError):47 """
3 unmodified lines
modified:jinja2/runtime.py+5 added-5 removed
24 unmodified lines
25 update and other methods will not work as they seem (they don't update26 the exported variables for example).27 """2829 def __init__(self, environment, globals, filename, blocks, standalone):29 def __init__(self, environment, globals, name, blocks, standalone):30 dict.__init__(self, globals)31 self.environment = environment32 self.exported = set()33 self.filename = filename33 self.name = name34 self.blocks = dict((k, [v]) for k, v in blocks.iteritems())3536 # if the template is in standalone mode we don't copy the blocks over.37 # this is used for includes for example but otherwise, if the globals
35 unmodified lines
73 def __repr__(self):74 return '<%s %s of %r>' % (75 self.__class__.__name__,76 dict.__repr__(self),77 self.filename77 self.name78 )798081class SuperBlock(object):
20 unmodified lines
102 def __init__(self, environment, context, template):103 template = environment.get_template(template)104 gen = template.root_render_func(context, standalone=True)105 context = gen.next()106 self._filename = template.name106 self._name = template.name107 self._rendered_body = u''.join(gen)108 self._context = context.get_exported()109110 def __getitem__(self, name):
7 unmodified lines
118119 def __repr__(self):120 return '<%s %r>' % (121 self.__class__.__name__,122 self._filename122 self._name123 )124125126class LoopContextBase(object):
193 unmodified lines
modified:jinja2/utils.py+3 added-1 removed
14 unmodified lines
151617def escape(obj, attribute=False):18 """HTML escape an object."""19 if obj is None:20 return u''19 if hasattr(obj, '__html__'):21 elif hasattr(obj, '__html__'):22 return obj.__html__()23 return Markup(unicode(obj)24 .replace('&', '&amp;')25 .replace('>', '&gt;')
173 unmodified lines