File: //lib/python3/dist-packages/genshi/template/__pycache__/eval.cpython-312.pyc
�
EMabYQ � � � d Z ddlmZ ddlmZ ddlZddlmZ ddlm Z ddl
mZmZm
Z
ddlmZ dd lmZ dd
lmZmZmZmZmZmZmZ g d�ZdZ G d
� de� Z G d� de� Z G d� de� Z e� Z! G d� de� Z" G d� de� Z# G d� de� Z$ G d� de$� Z% G d� de$� Z&d&d�Z' d'd�Z(d� Z)ejT jW � Z,e,j[ e e#d �� e.g d!�� Z/ G d"� d#e� Z0 G d$� d%e0� Z1y)(z4Support for "safe" evaluation of Python expressions.� )�dedent)�CodeTypeN)�builtins)�Markup)�ASTTransformer�ASTCodeGenerator�parse)�TemplateRuntimeError)�flatten)�ast�
_ast_Constant�get_code_params�build_code_chunk�isstring�
IS_PYTHON2�_ast_Str)�Code�
Expression�Suite�
LenientLookup�StrictLookup� Undefined�UndefinedErrorzrestructuredtext enc �H � e Zd ZdZg d�Z dd�Zd� Zd� Zd� Zd� Z d � Z
d
� Zy)r z=Abstract base class for the `Expression` and `Suite` classes.)�source�coder �_globalsNc �D � t |t j � r|| _ t || j
�� }nrt |t j � s
J d|z � �d| _ | j
dk( rt
j � }||_ nt
j � }|g|_ || _ t || j | j
|||�� | _
|�t }n*t |t j � rt t d�| }|j | _ y)a Create the code object, either from a string, or from an AST node.
:param source: either a string containing the source code, or an AST
node
:param filename: the (preferably absolute) name of the file containing
the code
:param lineno: the number of the line on which the code was found
:param lookup: the lookup class that defines how variables are looked
up in the context; can be either "strict" (the default),
"lenient", or a custom lookup class
:param xform: the AST transformer that should be applied to the code;
if `None`, the appropriate transformation is chosen
depending on the mode
)�modez'Expected string or AST node, but got %r�?�eval)r �filename�lineno�xformN)�lenient�strict)�
isinstance�six�string_typesr �_parser �_ast�ASTr �body�Moduler �_compiler r r �globalsr )�selfr r"