o
    åÅe0  ã                   @   sT   d dl Z d dlZ d dlZe j ejd  ¡ZdZdd„ Zdd„ Z	ddd„Z
d	d
„ ZdS )é    Néÿÿÿÿc                 C   sl   |  d¡s| d¡dkr|S | du s| dkr'zt ¡ } W n
 ty&   Y dS w |  d¡r0| | S d| |f S )a÷  If 'file_name' starts with '/', returns a copy of 'file_name'.
    Otherwise, returns an absolute path to 'file_name' considering it relative
    to 'dir_', which itself must be absolute.  'dir_' may be None or the empty
    string, in which case the current working directory is used.

    Returns None if 'dir_' is None and getcwd() fails.

    This differs from os.path.abspath() in that it will never change the
    meaning of a file name.

    On Windows an absolute path contains ':' ( i.e: C:\ ) ú/ú:r   NÚ z%s/%s)Ú
startswithÚfindÚosÚgetcwdÚOSErrorÚendswith)Údir_Ú	file_name© r   ú*/usr/lib/python3/dist-packages/ovs/util.pyÚabs_file_name   s   ÿ
r   c                 C   s.   | sdS | dkrt  | ¡S | tkrdS d|  S )zéMany OVS functions return an int which is one of:
    - 0: no error yet
    - >0: errno value
    - EOF: end of file (not necessarily an error; depends on the function
      called)

    Returns the appropriate human-readable string.r   r   zEnd of filez***unknown return value: %s***)r   ÚstrerrorÚEOF)Úretvalr   r   r   Úovs_retval_to_string2   s   	
r   c                 C   sF   dt |f }| r|dt| ƒ 7 }tj d| ¡ |r!| |¡ dS dS )a6  Prints 'message' on stderr and emits an ERROR level log message to
    'vlog' if supplied.  If 'err_no' is nonzero, then it is formatted with
    ovs_retval_to_string() and appended to the message inside parentheses.

    'message' should not end with a new-line, because this function will add
    one itself.z%s: %sz (%s)z%s
N)ÚPROGRAM_NAMEr   ÚsysÚstderrÚwriteÚerr)Úerr_noÚmessageÚvlogÚerr_msgr   r   r   Ú	ovs_errorD   s   ÿr   c                  O   s   t | i |¤Ž t d¡ dS )at  Prints 'message' on stderr and emits an ERROR level log message to
    'vlog' if supplied.  If 'err_no' is nonzero, then it is formatted with
    ovs_retval_to_string() and appended to the message inside parentheses.
    Then, terminates with exit code 1 (indicating a failure).

    'message' should not end with a new-line, because this function will add
    one itself.é   N)r   r   Úexit)ÚargsÚkwargsr   r   r   Ú	ovs_fatalU   s   	r#   )N)r   Úos.pathr   ÚpathÚbasenameÚargvr   r   r   r   r   r#   r   r   r   r   Ú<module>   s   
