File: //usr/lib/python3/dist-packages/genshi/template/__pycache__/eval.cpython-310.pyc
o
!�bYQ � @ s� d Z ddlmZ ddlmZ ddlZddlmZ ddlm Z ddl
mZmZm
Z
ddlmZ dd lmZ dd
lmZmZmZmZmZmZmZ g d�ZdZG d
d� de�ZG dd� de�ZG dd� de�Z e� Z!G dd� de�Z"G dd� de�Z#G dd� de�Z$G dd� de$�Z%G dd� de$�Z&d+dd�Z' d,d!d"�Z(d#d$� Z)ej*�+� Z,e,�-e e#d%�� e.g d&��Z/G d'd(� d(e�Z0G d)d*� d*e0�Z1dS )-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 @ sV e Zd ZdZg d�Z ddd�Zdd � Zd
d� Zdd
� Zdd� Z dd� Z
dd� ZdS )r z=Abstract base class for the `Expression` and `Suite` classes.)�source�coder �_globalsN����strictc C s� t |tj�r|| _t|| jd�}n$t |tj�sJ d| ��d| _| jdkr-t�� }||_ nt�
� }|g|_ || _t|| j| j|||d�| _
|du rLt}n
t |tj�rYttd�| }|j| _dS )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)�lenientr )�
isinstance�six�string_typesr �_parser �_ast�ASTr �body�Moduler �_compiler r r �globalsr )�selfr r! r"