U of @sddlmZddlmZddlmZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddlZdd lmZd d lmZeeZed ez\ddlZddlZddlZedejed ddddZed e\ZZ Z!Z"e dkrdZ Wne#e$fk r$dZ YnXdddddddddZ%ed/dddddddZ&d0ddddddZ'dddd d!Z(d1dd#dd$d%d&Z)d2dddddd(d)d*Z*d+dd,d-d.Z+dS)3) annotations)Iterable)contextmanagerN)Iterator)Optional)TextIO)Union)url) sqla_compatalembicZHHHHFquietrzUnion[str, bytes]boolNone)streamtextrreturnc Gsp|rdSt|ddpd}|D]N}t|ts6||d}||}z||Wqtk rhYqlYqXqdS)Nencodingasciireplace)getattr isinstancebytesencodedecodewriteOSError)rrrrtrD/opt/hc_python/lib/python3.8/site-packages/alembic/util/messaging.pywrite_outstream%s   r!strzIterator[None]) status_msgnewlinerrccsRt|d|d|dz dVWn|s6ttjdYnX|sNttjddS)Nz ...T)flushrz FAILED z done )msgr!sysstdout)r#r$rrrr status8s  r))messagerrcCs*t|td||dtddS)NzFAILED: r )logerrorr&r'exit)r*rrrr errHs r/) input_urlrcCst|}tj|ddS)NT)Z hide_password)r Zmake_urlr Zurl_render_as_string)r0urrr obfuscate_url_pwNs r2int)r& stacklevelrcCstj|t|ddS)N)r5)warningswarn UserWarning)r&r5rrr r7Ssr7T)r&r$r%rrcCs|rdStdkr.ttj||rttjdn\d}tj|t||d}t|dkrp|ddD]}ttj|dq\ttj|d|rdnd|rtjdS)N z )initial_indentsubsequent_indentr rr+) TERMWIDTHr!r'r(textwrapwraplenr%)r&r$r%rindentlineslinerrr r&Ws&  r&z#Optional[Union[str, Iterable[str]]])valuercCs>|dkr dSt|tr|St|tr.d|Std|dS)Nr<z, z!Don't know how to comma-format %r)rr"rjoin ValueError)rDrrr format_as_commaqs   rG)FF)F)r3)TFF), __future__rcollections.abcr contextlibrloggingr'r>typingrrrrr6Zsqlalchemy.enginer r<r getLogger__name__r, addHandler NullHandlerZfcntltermiosstructZioctl TIOCGWINSZpackunpack_hr=Z_hpZ_wp ImportErrorrr!r)r/r2r7r&rGrrrr sL