g(UddlmZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z d d l mZd d lmZd ZiZded<ddZ ddZddZddZed d ddZeddddZy)) annotationsN)Any)Callable)Dict)List)Mapping)Optional)Union)util)compatREVISION_SCRIPT_FILENAMEdict _registrycfd}|S)zA function decorator that will register that function as a write hook. See the documentation linked below for an example. .. seealso:: :ref:`post_write_hooks_custom` c|t<|S)N)r)fnnames I/opt/hc_python/lib/python3.12/site-packages/alembic/script/write_hooks.pydecoratezregister..decorate&s $ )rrs` rregisterrs Orc~ t|}|||S#t$r}tjd|d|d}~wwxYw)a7Invokes the formatter registered for the given name. :param name: The name of a formatter in the registry :param revision: A :class:`.MigrationRevision` instance :param options: A dict containing kwargs passed to the specified formatter. :raises: :class:`alembic.util.CommandError` zNo formatter with name 'z ' registeredN)rKeyErrorr CommandError)rrevisionoptionshookkes r_invoker!-sS' Hg&& &tfL 9  s  <7<cddlm}|j|jdd}|D]v}|s|Dcic]+}|j |dzr|t |dzd||-}}||d< |d}t jd |d 5t|||dddxycc}w#1swYxYw#t$r!}t jd |d ||d}~wwxYw)z&Invoke hooks for a generated revision.)_split_on_space_commahooks.N _hook_nametypezRunning post write hook T)newlineKey z&.type is required for post write hook ) baser$splitget startswithlenr statusr!rr) path hook_configr$namesrkeyoptstype_r s r _run_hooksr8Bs, ! ' ' (D EE # "~~dSj) D A  +c"2 2"  "\ +LE *4(3TtT*!   ##tfB4(K  s)0B$,B5 B))B2 5 C>CCct|vr tdz|z}tj|tj}|Dcgc]}|j t|}}|Scc}w)zParse options from a string into a list. Also substitutes the revision script token with the actual filename of the revision script. If the revision script token doesn't occur in the options string, it is automatically prepended.  )posix)REVISION_SCRIPT_TOKENshlexr-r is_posixreplace)cmdline_options_strr2cmdline_options_listoptions r_parse_cmdline_optionsrC_sq$773c9ras#  3 4&' '''D''*+: * 49# ##-1# ##L &r