4 d Z ddlmZ ddlmZ ddlZd Zd Zd Zd Zd Z d Z d Z ej ej e e d Zd Z ej ej ee d Zd Z ej ej ee dS )zpylint_flask module )MANAGER)nodesNc dS )zpregister is expected by pylint for plugins, but we are creating a transform, not registering a checker. N )_s g/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pylint_flask/__init__.pyregisterr s D c n dD ]1}t | | rt ||t | | 2dS )zCopy information from src to dest Every node in the AST has to have line number information. Get the information from the old stmt.)lineno fromlinenotolineno col_offsetparentN)hasattrsetattrgetattr)srcdestattrs r copy_node_infor sL ) 4 43 4D$T 2 23334 4r c d| _ dS )zAMark a node as transformed so we don't process it multiple times.TN)pylint_flask_was_transformednodes r mark_transformedr s (,D%%%r c $ t | dd S )z.Return True if `node` was already transformed.r F)r r s r is_transformedr s 47???r c t j d| }|t d | d }d | }|S )z+Convert a flask.ext.admin into flask_admin.flask\.ext\.(.*)Nz7Module name `{}` doesn't match`flask.ext` style import. flask_{})rematchLookupErrorgroupformat)flask_ext_namer$ from_nameactual_module_names r make_non_magical_flask_importr+ $ sY H(.99E} 6 7 7 7AI#**955r c g }| j D ]3\ }}d | }| ||p|f 4t j }t | | ||_ t | |S )zTranslates a flask.ext from-style import into a non-magical import. Translates: from flask.ext import wtf, bcrypt as fcrypt Into: import flask_wtf as wtf, flask_bcrypt as fcrypt r" )namesr' appendr Importr r )r new_namesnameas_namer* new_nodes r transform_flask_from_importr4 / s I : @ @w'..t44,go>????|~~H4"""HNXOr c 8 t | o | j dk S )z3Predicate for checking if we have the flask module. flask.ext)r modnamer s r is_flask_from_importr8 J s! d###C(CCr c t | j }t j || j | j }t | | t | |S )a" Translates a flask.ext.wtf from-style import into a non-magical import. Translates: from flask.ext.wtf import Form from flask.ext.admin.model import InlineFormAdmin Into: from flask_wtf import Form from flask_admin.model import InlineFormAdmin )r+ r7 r ImportFromr- levelr r )r r* r3 s r transform_flask_from_longr<