a oe@s&dZddlmZddZd ddZdS) zl a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit))is64bitc Cst|ttfr|g}|d}z|dkrptr>||dfWSz||dfWWStyj|dfYWS0n,|dkr||vrddl}||fWSn|dkrddl}z||d|fWWSty||fYWS0n|d kr.z |d}Wntyd}Yn0||j |d|fWS|d krdd |vsL|d sV|d fWS|d |fWS|dkrddl }ddl }||j |d|dfWStd|Wn td|t|fYn0dS)ayallow the programmer to perform limited processing on the server by passing macro names and args :new_key - the key name the macro will create :args[0] - macro name :args[1:] - any arguments :code - the value of the keyword item :kwargs - the connection keyword dictionary. ??key has been removed --> the value to put in for kwargs['name'] = value rrgetuserNZgetnodegetenvZ auto_securityuserzIntegrated Security=SSPIz'User ID=%(user)s; Password=%(password)sZfind_temp_test_pathZ adodbapi_testzUnknown connect string macro=%szError in macro processing %s %s) isinstancestrrPython IndexErrorgetpassrplatformZnodeenvirongetostempfilepathjoinZ gettempdir ValueErrorrepr) macro_nameargskwargsnew_keyr rZdfltrrr@C:\Program Files\Certbot\pkgs\adodbapi\process_connect_string.py macro_calls\        rFc Csz |d}Wnty"d}Yn0t|tr:||n |rF||d<z |d}Wntyhd}Yn0t|tr~||d<n(t|tr||d<nt|tr||z(|d|d<|d |d <|d |d <WntyYn0d|vr@z|d |d<WnBty>z|d |d<Wnty8tdYn0Yn0|rt| D]@}| drR|dd}| |}t |||\}} | ||<qRz2|d} d| vr| ddkr| d|d<WntyYn0|S)zattempts to inject arguments into a connection string using Python "%" operator for strings co: adodbapi connection object args: positional parameters from the .connect() call kvargs: keyword arguments from the .connect() call rNZconnection_stringrtimeoutrrpasswordhostZdatabasedsnz3Must define 'connection_string' for ado connectionsZmacro_Z proxy_host:[)r&])r r dictupdateintr KeyError TypeErrorlistkeys startswithpoprr) rrZ expand_macrosr#Za1kwargrZ macro_coderZrsltsrrrprocessKsl                      r3N)F)__doc__rrrr3rrrrs G