
    e                     D    d Z ddlZddlZddlmZ d Zdddedefd	Zd
 Z	y)z+
cookiecutter.replay.

-------------------
    N)make_sure_path_existsc                 x    |j                  d      sdnd}| | }t        j                  j                  | |      S )zGet the name of file.z.json )endswithospathjoin)
replay_dirtemplate_namesuffix	file_names       3lib/python3.12/site-packages/cookiecutter/replay.pyget_file_namer      s9    )227;WF /&*I77<<
I..    r
   zos.PathLike[str]r   contextc                 2   t        |        t        |t              st        d      t        |t              st        d      d|vrt        d      t        | |      }t        |dd      5 }t        j                  ||d	       d
d
d
       y
# 1 sw Y   y
xY w)zWrite json data to file.+Template name is required to be of type strz&Context is required to be of type dictcookiecutter1Context is required to contain a cookiecutter keywutf-8encoding   )indentN)
r   
isinstancestr	TypeErrordict
ValueErrorr   openjsondump)r
   r   r   replay_fileoutfiles        r   r#   r#      s    *%mS)EFFgt$@AAW$LMM
M:K	k3	1 .W		'71-. . .s   +BBc                     t        |t              st        d      t        | |      }t	        |d      5 }t        j                  |      }ddd       dvrt        d      |S # 1 sw Y   xY w)zRead json data from file.r   r   r   Nr   r   )r   r   r   r   r!   r"   loadr    )r
   r   r$   infiler   s        r   r'   r'   '   sn    mS)EFF
M:K	kG	, $))F#$ W$LMMN$ $s   A$$A-)
__doc__r"   r   cookiecutter.utilsr   r   r   r   r#   r'    r   r   <module>r,      s:     	 4/.' . .d .&r   