a
    �Ï?e  ã                
   @   s´   d Z ddlmZ ddlmZ ddlmZ ddlmZ z
ej	 W n. e
yl Z zed	ƒe‚W Y dZ[n
dZ[0 0 g d
¢Zg d¢Zee Zdd„ Zdd„ Zdd„ ZG dd„ dejƒZdS )ao  A backend module to load and dump YAML data files using rumael.yaml.

- Format to support: YAML, http://yaml.org
- Requirement: ruamel.yaml, https://bitbucket.org/ruamel/yaml
- Development Status :: 4 - Beta
- Limitations:

  - Multi-documents YAML stream load and dump are not supported.

- Special options:

  - All keyword options of yaml.safe_load, yaml.load, yaml.safe_dump and
    yaml.dump should work.

  - Use 'ac_safe' boolean keyword option if you prefer to call yaml.safe_load
    and yaml.safe_dump instead of yaml.load and yaml.dump. Please note that
    this option conflicts with 'ac_dict' option and these options cannot be
    used at the same time.

  - Also, you can give keyword options for ruamel.yaml.YAML.__init__ such like
    typ and pure, and can give some members of ruamel.yaml.YAML instance to
    control the behaviors such like default_flow_style and allow_duplicate_keys
    as keyword options to load and dump functions.

  - See also: https://yaml.readthedocs.io

Changelog:

.. versionchanged:: 0.9.8

   - Split from the common yaml backend and start to support ruamel.yaml
     specific features.
é    Né   )Úfilter_optionsé   )Úbaseé   )Úcommonz"ruamel.yaml may be too old to use!)ÚtypZpureZplug_ins)*Zallow_duplicate_keysZallow_unicodeZblock_seq_indentÚ	canonicalZcomposerÚconstructorZdefault_flow_styleZdefault_styleÚdumpZdump_allZemitterÚencodingZexplicit_endZexplicit_startZget_constructor_parserZ"get_serializer_representer_emitterÚindentZ
line_breakÚloadZload_allÚmapZ
map_indentZofficial_plug_insZ
old_indentÚparserZprefix_colonZpreserve_quotesÚreaderZregister_classZrepresenterÚresolverÚscannerÚseqZsequence_dash_offsetZsequence_indentÚ
serializerÚstreamÚtagsZ0top_level_block_style_scalar_no_indent_error_1_1Ztop_level_colon_alignÚversionÚwidthc                 O   sl   t  d|¡}d|v rd|d< tt|ƒ}tt|ƒ}tjf i |¤Ž}| ¡ D ]\}}t|||ƒ qHt	|| ƒ|Ž S )a7  Call loading functions for yaml data.

    :param fname:
        "load" or "dump", not checked but it should be OK.
        see also :func:`yml_load` and :func:`yml_dump`
    :param args: [stream] for load or [cnf, stream] for dump
    :param options: keyword args may contain "ac_safe" to load/dump safely
    Zac_dictZac_safeÚsafer   )
r   Zfilter_from_optionsr   Ú_YAML_INIT_KWARGSÚ_YAML_INSTANCE_MEMBERSÚryamlÚYAMLÚitemsÚsetattrÚgetattr)ÚfnameÚargsÚoptionsZioptsZooptsZymlÚattrÚval© r'   úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/anyconfig/backend/yaml/ruamel_yaml.pyÚyml_fncF   s    	

r)   c                 K   s$   t d| fi |¤Ž}|du r |ƒ S |S )z3See :func:`anyconfig.backend.yaml.pyyaml.yml_load`.r   N©r)   )r   Ú	containerr$   Úretr'   r'   r(   Úyml_load^   s    r-   c                 K   s   t d| |fi |¤ŽS )z3See :func:`anyconfig.backend.yaml.pyyaml.yml_dump`.r   r*   )Údatar   r$   r'   r'   r(   Úyml_dumpg   s    	r/   c                   @   s0   e Zd ZdZdZeZeZe 	e
¡Ze 	e¡ZdS )ÚParserzParser for YAML files.zruamel.yamlN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z_cidÚ
_YAML_OPTSZ
_load_optsZ
_dump_optsr   Z	to_methodr-   Zload_from_streamr/   Zdump_to_streamr'   r'   r'   r(   r0   s   s   
r0   )r4   Zruamel.yamlZyamlr   Úutilsr   Ú r   r   r   ÚAttributeErrorÚexcÚImportErrorr   r   r5   r)   r-   r/   r0   r'   r'   r'   r(   Ú<module>   s   !
 	