%PDF- %PDF-
Direktori : /lib/python3/dist-packages/sos/__pycache__/ |
Current File : //lib/python3/dist-packages/sos/__pycache__/utilities.cpython-312.pyc |
� i��d~H � �� � d dl Z d dlZd dlZd dlmZmZmZ d dlZd dlZd dl Z d dl Z d dlZd dlZd dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ dZ d dlZ ej8 e� dZdZ&d� Z'd0d�Z(d1d�Z)d� Z*d2d�Z+d� Z,d3d�Z-e&dddddddddf d�Z.d3d�Z/d4d�Z0d5d�Z1e jd fd�Z3d� Z4d� Z5d� Z6d� Z7d � Z8e jr d!�d"�Z:d#� Z;g fd$�Z<d%� Z G d&� d'� Z= G d(� d)e j| � Z? G d*� d+e@� ZA G d,� d-� ZB G d.� d/eC� ZDy# e$ r d dlmZ Y ��w xY w# eef$ r> ej@ d � Z!d d l"m#Z# dZ$e!jK d e#e$d d�� z dz � Y ��w xY w)6� N)�Popen�PIPE�STDOUT)�closing)�deque)� parse_version)�parseFT�sos)�fillz�WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module. � �H )�replace_whitespacei, c �� � t | d� 5 }t j | � j |kD r|j | d� |j � cddd� S # 1 sw Y yxY w)z,Returns the last number_of_bytes of filename�rb� N)�open�os�stat�st_size�seek�read)�filename�number_of_bytes�fs �//usr/lib/python3/dist-packages/sos/utilities.py�tailr 2 sT � � �h�� � �� �7�7�8��$�$��6� �F�F�O�#�Q�'��v�v�x�� � �s �AA�A%c � � t | t � r t | |� S t | � S # t $ rI t j d� }|j d| z � t t j � � cY S w xY w)z@Returns a file-like object that can be used as a context managerr zfileobj: %s could not be opened) � isinstance�strr �IOError�logging� getLogger�debugr �io�StringIO)�path_or_file�mode�logs r �fileobjr) : so � ��,��$� *���d�+�+� �|�$�$�� � *��#�#�E�*�C��I�I�7�,�F�G��2�;�;�=�)�)� *�s �) �AA;�:A;c � � t | � }| |k\ rd||z z S | |k\ rd||z z S | |k\ rd||z z S | |k\ rd||z z S d| z S )zCConverts a number of bytes to a shorter, more human friendly formatz%.1fTz%.1fGz%.1fMz%.1fKz%d)�float)�bytes_�K�M�G�T�fns r � convert_bytesr2 G sm � � �v��B� ��{��"�q�&�!�!� �1���"�q�&�!�!� �1���"�q�&�!�!� �1���"�q�&�!�!��f�}�� c �F �� t r@ t j | � �ddg}�j dk( xr t �fd�|D � � S t | d� 5 } |j d� ddd� y# t $ r Y �4w xY w# t $ r Y ddd� y w xY w# 1 sw Y yxY w) az Helper to determine if a given file contains binary content or not. This is especially helpful for `sos clean`, which cannot obfuscate binary data and instead, by default, will remove binary files. :param fname: The full path of the file to check binaryness of :type fname: ``str`` :returns: True if binary, else False :rtype: ``bool`` ztext/zinode/�binaryc 3 �T �K � | ] }�j j |� �� �! y �w�N)� mime_type� startswith)�.0�_mt�_ftups �r � <genexpr>z!file_is_binary.<locals>.<genexpr>h s �� �� �F��E�O�O�.�.�s�3�F�s �%(�tr� NFT) � magic_mod�magic�detect_from_filename�encoding�any� Exceptionr r �UnicodeDecodeError)�fname�_mimes�tfiler<