OwlCyberSecurity - MANAGER
Edit File: _iotools.cpython-38.pyc
U �p�]� � @ sZ d Z ddlmZmZmZ dZddlZddlZddl m mZ ddl mZmZmZmZ ejd dkr�ddlmZmZmZmZmZmZ eZn$ddlmZmZmZmZmZmZmZ d(d d �Zdd� Zd d� Zd)dd�Zdd� Z d*dd�Z!G dd� de�Z"G dd� de�Z#dd� Z$G dd� de%�Z&G dd � d e&�Z'G d!d"� d"e(�Z)G d#d$� d$e�Z*d+d&d'�Z+dS ),zBA collection of functions designed to help I/O with ascii files. � )�division�absolute_import�print_functionzrestructuredtext enN)�asbytes� asunicode�bytes� basestring� )�bool�int�float�complex�object�str)r r r r r �unicoder c C s. t | �tkr*|dkr | �d�} n | �|�} | S )an Decode bytes from binary input streams. Defaults to decoding from 'latin1'. That differs from the behavior of np.compat.asunicode that decodes from 'ascii'. Parameters ---------- line : str or bytes Line to be decoded. Returns ------- decoded_line : unicode Unicode in Python 2, a str (unicode) in Python 3. N�latin1)�typer �decode)�line�encoding� r �4/usr/lib/python3/dist-packages/numpy/lib/_iotools.py�_decode_line s r c C s, z| d W n t tfk r& Y dS X dS )z2 Check whether obj behaves like a string. � FT�� TypeError� ValueError��objr r r �_is_string_like. s r c C s, z| d W n t tfk r& Y dS X dS )z8 Check whether obj behaves like a bytes object. � FTr r r r r �_is_bytes_like9 s r! �rFc C s� t | �rV| �d�r(ddl}|�| |�}n(| �d�rFddl}|�| �}n t| |�}d}nt| d�rj| }d}ntd��|r~||fS |S ) a� Returns the filehandle corresponding to a string or a file. If the string ends in '.gz', the file is automatically unzipped. Parameters ---------- fname : string, filehandle Name of the file whose filehandle must be returned. flag : string, optional Flag indicating the status of the file ('r' for read, 'w' for write). return_opened : boolean, optional Whether to return the opening status of the file. z.gzr Nz.bz2T�seekFz%fname must be a string or file handle) r �endswith�gzip�open�bz2ZBZ2File�file�hasattrr )�fname�flagZ return_openedr% Zfhdr'