o
    ÖtBh‚  ã                   @   sÆ   d dl mZmZmZ d dlZd dlZd dlZd dlZd dlZd dl	Z	ej
d  dkZer-eneZer3eneZer;eefneeefZdZdZdZdZdd	„ Zd
d„ Zddd„Zdd„ Zdd„ Zdd„ ZdS )é    )ÚdivisionÚabsolute_importÚprint_functionNé   z	~/.configÚAPPDATAz~\AppData\Roamingz~/Library/Application Supportc                 C   s(   t | ƒ}zt|ƒW S  ty   tƒ ‚w )zjGet the first element from an iterable or raise a ValueError if
    the iterator generates no values.
    )ÚiterÚnextÚStopIterationÚ
ValueError)ÚsequenceÚit© r   úc/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/confuse/util.pyÚ
iter_first   s   
ÿr   c                 C   s   t | tjtjfƒrt| ƒS | S )zíIf obj is argparse.Namespace or optparse.Values we'll return
      a dict representation of it, else return the original object.

    Redefine this method if using other parsers.

    :param obj: *
    :return:
    :rtype: dict or *
    )Ú
isinstanceÚargparseÚ	NamespaceÚoptparseÚValuesÚvars)Úobjr   r   r   Únamespace_to_dict"   s   
r   Ú Fc                 C   sî   t | ƒ} t| tƒs| S tr|  ¡ n|  ¡ }|rtt|ƒƒ}i }|D ]S}| | }|du r.|s.q!|}t|||ƒ}|rd| 	|¡}	t
|	ƒdkrd|	 ¡ }|	D ]}
|
|v r[t||
 tƒr[||
 }qIi ||
< ||
 }qI||v rp||  |¡ q!|||< q!|S )as  Recursively builds a dictionary from an argparse.Namespace,
    optparse.Values, or dict object.

    Additionally, if `sep` is a non-empty string, the keys will be split
    by `sep` and expanded into a nested dict. Keys with a `None` value
    are dropped by default to avoid unsetting options but can be kept
    by setting `keep_none` to `True`.

    :param obj: Namespace, Values, or dict to iterate over. Other
        values will simply be returned.
    :type obj: argparse.Namespace or optparse.Values or dict or *
    :param sep: Separator to use for splitting properties/keys of `obj`
        for expansion into nested dictionaries.
    :type sep: str
    :param keep_none: Whether to keep keys whose value is `None`.
    :type keep_none: bool
    :return: A new dictionary or the value passed if obj was not a
        dict, Namespace, or Values.
    :rtype: dict or *
    Né   )r   r   ÚdictÚPY3ÚkeysÚiterkeysÚsortedÚlistÚ
build_dictÚsplitÚlenÚpopÚupdate)r   ÚsepÚ	keep_noner   ÚoutputÚkeyÚvalueÚsave_toÚresultr!   Ú	child_keyr   r   r   r    1   s8   

ÿ


r    c                 C   s\   t  | ¡}|du s| dkrdS t|dƒr| | ¡}n
t| ƒ tj|  j}tj	 
tj	 |¡¡S )z—Returns the path to the package containing the named module or
    None if the path could not be identified (e.g., if
    ``name == "__main__"``).
    NÚ__main__Úget_filename)ÚpkgutilÚ
get_loaderÚhasattrr.   Ú
__import__ÚsysÚmodulesÚ__file__ÚosÚpathÚdirnameÚabspath)ÚnameÚloaderÚfilepathr   r   r   Úfind_package_pathx   s   

r=   c                  C   sX   g } dt jv r|  t jd ¡ dt jv r |  t jd  d¡¡ n|  d¡ |  d¡ | S )zxReturns a list of paths taken from the XDG_CONFIG_DIRS
    and XDG_CONFIG_HOME environment varibables if they exist
    ÚXDG_CONFIG_HOMEÚXDG_CONFIG_DIRSú:z/etc/xdgz/etc)r6   ÚenvironÚappendÚextendr!   )Úpathsr   r   r   Úxdg_config_dirsŒ   s   



rE   c                  C   s²   g } t  ¡ dkr|  t¡ |  t¡ |  tƒ ¡ n$t  ¡ dkr2|  t¡ tt	j
v r1|  t	j
t ¡ n|  t¡ |  tƒ ¡ g }| D ]}t	j t	j |¡¡}||vrV| |¡ qA|S )a  Return a platform-specific list of candidates for user
    configuration directories on the system.

    The candidates are in order of priority, from highest to lowest. The
    last element is the "fallback" location to be used when no
    higher-priority config file exists.
    ÚDarwinÚWindows)ÚplatformÚsystemrB   ÚUNIX_DIR_FALLBACKÚMAC_DIRrC   rE   ÚWINDOWS_DIR_FALLBACKÚWINDOWS_DIR_VARr6   rA   r7   r9   Ú
expanduser)rD   Úoutr7   r   r   r   Úconfig_dirs›   s&   



€

€rP   )r   F)Ú
__future__r   r   r   r6   r3   r   r   rH   r/   Úversion_infor   ÚstrÚunicodeÚSTRINGÚ
basestringÚ
BASESTRINGÚintÚfloatÚlongÚNUMERIC_TYPESrJ   rM   rL   rK   r   r   r    r=   rE   rP   r   r   r   r   Ú<module>   s*    
G