HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/syspurpose/__pycache__/utils.cpython-39.opt-1.pyc
a

X�Zh	�@sldZddlZddlZddlZddlZddlZe�e�Ze	e
d�dd�Ze	ee
d�dd�Z
edd	�d
d�ZdS)z,
Utility methods for the syspurpose command
�N)�path�returnc
Csrztj|dd�WnZtyl}zB|jtjkr<WYd}~dS|jtjkrXt�d�|��WYd}~n
d}~00dS)z�
    Attempts to create the path given (less any file)
    :param path: path
    :return: True if changes were made, false otherwise
    i�)�modeNFzCannot create directory {}T)	�os�makedirs�OSError�errno�EEXIST�EACCES�log�error�format)r�e�r�6/usr/lib64/python3.9/site-packages/syspurpose/utils.py�
create_dirs&r)r�contentsrc
Cs�zFtj|ddd��"}t||�|��Wd�n1s:0YWn^ty�}zF|jtjkrpWYd}~dS|jtjkr�t�	d�
|��n�WYd}~n
d}~00dS)z�
    Attempts to create a file, with the given contents
    :param path: The desired path to the file
    :param contents: The contents to write to the file, should json-serializable
    :return: True if the file was newly created, false otherwise
    �wzutf-8)�encodingNFzCannot create file {}T)�io�open�write_to_file_utf8�flushrrr	r
rrr
)rr�frrrr�create_file,s
*r)�datarcCs|�tj|dddd��dS)z�
    Writes out the provided data to the specified file, with user-friendly indentation,
    and in utf-8 encoding
    :param file: The file to write to
    :param data: The data to be written
    :return:
    �FT)�indentZensure_asciiZ	sort_keysN)�write�json�dumps)�filerrrrrCsr)�__doc__rrrrZloggingZ	getLogger�__name__r�str�boolr�dictrrrrrr�<module>s