U of*'@sHUddlmZddlZddlmZddlZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!eZ"de#d<ededZ$ed ed!efdZ%Gd"d#d#e&Z'Gd$d%d%e'd&Z(d'd'd(d)d*Z)d+d,d-d.Z*ed'd/d/d0d1d2Z+edBd3d4dd0d5d2Z+edCd'd6d/d0d7d2Z+dDd'd6d6d0d8d2Z+d9d9d:d;d<Z,Gd=d>d>Z-d4dd?d@dAZ.dS)E) annotationsN)Iterable)Any)Callable)cast)Dict)List)Mapping)MutableMapping)NoReturn)Optional)overload)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union)asbool) immutabledict)to_list) unique_list)inspect_getfullargspec)memoized_propertyzMapping[Any, Any] EMPTY_DICT_T)bound_C.cs&eZdZddddfdd ZZS)_ModuleClsMetastrCallable[..., Any]None)keyvaluereturncst||||dSN)super __setattr___update_module_proxies)clsr$r% __class__F/opt/hc_python/lib/python3.8/site-packages/alembic/util/langhelpers.pyr)/sz_ModuleClsMeta.__setattr__)__name__ __module__ __qualname__r) __classcell__r.r.r,r/r .sr c@seZdZUdZeddZded<edddd d Z dd d d Z dd ddZ eddddddZ edddddddZ eddddddddZedddddddZdS) ModuleClsProxyzCreate module level proxy functions for the methods on a given class. The functions will have a compatible signature as the methods. cCs tgfSr')setr.r.r.r/CzModuleClsProxy.zaDict[Type[Any], Tuple[Set[str], List[Tuple[MutableMapping[str, Any], MutableMapping[str, Any]]]]]_setupsr!r#)namer&cCs0|j|\}}|D]\}}|||||qdSr')r8_add_proxied_attribute)r+r9 attr_namesmodulesglobals_locals_r.r.r/r*Es z%ModuleClsProxy._update_module_proxiesr&cCsB|j|j\}}|D](\}}||d<|D]}t||||<q(qdSN_proxy)r8r-getattrselfr;r<r=r> attr_namer.r.r/_install_proxyKs  zModuleClsProxy._install_proxycCs:|j|j\}}|D] \}}d|d<|D] }||=q(qdSr@)r8r-rCr.r.r/ _remove_proxyRs  zModuleClsProxy._remove_proxyzMutableMapping[str, Any])r=r>r&cCs.|j|\}}|||f||||dSr')r8append _setup_proxy)r+r=r>r;r<r.r.r/create_module_class_proxyYsz(ModuleClsProxy.create_module_class_proxyzSet[str])r=r>r;r&cCs"t|D]}|||||qdSr')dirr:)r+r=r>r;methnamer.r.r/rIcs zModuleClsProxy._setup_proxy)rLr=r>r;r&cCs>|ds:t||}t|r0||||||<n ||dS)N_) startswithrBcallable_create_method_proxyadd)r+rLr=r>r;methr.r.r/r:ms   z%ModuleClsProxy._add_proxied_attributer")r9r=r>r&c st|}ddddfdd }||d<t|dg}|rt|}|d rf|d d d krf|d d d }} d |jt||f} dd d d d d ddd} | |d<n d }d } d} td|| || |jd} i} t| t d|| t d| |S)Nr! Exceptionr )r9from_r&cstd|jf|dS)NzCan't invoke function '%s', as the proxy object has not yet been established for the Alembic '%s' class. Try placing this code inside a callable.) NameErrorr0)r9rTr+r.r/ _name_errorsz8ModuleClsProxy._create_method_proxy.._name_errorrW_legacy_translationsrrDz *args, **kwz+args, kw = _translate(%r, %r, %r, args, kw)r)fn_namespec translationsargskwr&c Ssi}g}|D]2\}}||kr td|||f||||<q ||t|}|drv|ddt|d } n|d} | D]B} | |krz||dWqtk rtd| YqXq| |||fS)Nz,Argument %r is now named %r for method %s().rz(missing required positional argument: %s) warningswarnpopupdatelistlenrH IndexError TypeErrorextend) rYrZr[r\r]Z return_kwZ return_argsZoldnameZnewnameZpos_onlyargr.r.r/ translates6    z6ModuleClsProxy._create_method_proxy..translateZ _translatea def %(name)s(%(args)s): %(doc)r %(translate)s try: p = _proxy except NameError as ne: _name_error('%(name)s', ne) return _proxy.%(name)s(%(apply_kw)s) e )r9rir\Zapply_kwdoczDict[str, Any]r") rBrrar0tupletextwrapdedent__doc__execr)r+r9r=r>fnrWr[rZZ outer_argsZ inner_argsZ translate_strriZ func_textZlclr.rVr/rP~s@   !  z#ModuleClsProxy._create_method_proxyN)r0r1r2ro collections defaultdictr8__annotations__ classmethodr*rFrGrJrIr:rPr.r.r.r/r44s    r4) metaclassr)r[r&csdddfdd }|S)Nrrqr&cs |_|Sr')rXrqr[r.r/decoratesz$_with_legacy_names..decorater.)r[rzr.ryr/_with_legacy_namessr{r!r?cCstjddS)Ni)uuiduuid4hexr.r.r.r/rev_idsrzTuple[Any, ...])xdefaultr&cCsdSr'r.rrr.r.r/to_tuplesrr#z Optional[_T]cCsdSr'r.rr.r.r/rszOptional[Tuple[Any, ...]]cCsdSr'r.rr.r.r/rscCs8|dkr |St|tr|fSt|tr.t|S|fSdSr') isinstancer!rrlrr.r.r/rs  zTuple[str, ...])tupr&cCs tt|Sr')rlr)rr.r.r/ dedupe_tuplesrc@sdeZdZddddddZddd d d d d Zddd ddddZdddddZddddZdS) DispatcherFboolr#)uselistr&cCsi|_||_dSr') _registryr)rDrr.r.r/__init__ szDispatcher.__init__rrr!zCallable[[_C], _C])target qualifierr&csdddfdd }|S)NrrwcsDjr jfg|n fjks2t|jf<|Sr')rr setdefaultrHAssertionErrorrxrrDrr.r/rzs z)Dispatcher.dispatch_for..decorater.)rDrrrzr.rr/ dispatch_forszDispatcher.dispatch_for)objrr&cCst|tr|g}nt|tr$|j}n t|j}|D]X}|dkrd||f|jkrd||j||fS|df|jkr2||j|dfSq2td|dS)Nrz#no dispatch function for object: %s)rr!type__mro__r _fn_or_list ValueError)rDrrtargetsZspclsr.r.r/dispatchs   zDispatcher.dispatchz3Union[List[Callable[..., Any]], Callable[..., Any]]r") fn_or_listr&cs(|jr ddddfdd }|SSdS)Nrr#)rhr]r&cs*trttstD]}|||qdSr')rrrr)rhr]rqrr.r/go2sz"Dispatcher._fn_or_list..go)r)rDrrr.rr/r-szDispatcher._fn_or_listr?cs<t}jr*|jfddjDn|jj|S)zHReturn a copy of this dispatcher that is independently writable.c3s&|]}|ddj|DfVqdS)cSsg|]}|qSr.r.).0rqr.r.r/ Csz/Dispatcher.branch...N)r)rkrDr.r/ Bsz$Dispatcher.branch..)rrrrb)rDdr.rr/branch<s zDispatcher.branchN)F)r)r)r0r1r2rrrrrr.r.r.r/r s  r)r%r&cCs|dk s t|Sr')r)r%r.r.r/not_noneJs r).)N)N)/ __future__rrrcollections.abcrrmtypingrrrrrr r r r r rrrrrrrr|r_Zsqlalchemy.utilrrrrcompatrrrrtrrrr r4r{rrrrrr.r.r.r/sb                          - ?