Server : Apache System : Linux cs317.bluehost.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : andertr9 ( 1047) PHP Version : 8.2.18 Disable Function : NONE Directory : /lib64/python3.6/__pycache__/ |
Upload File : |
3 \!X � @ sb d Z ddlZddlZddlZddlZddlZddlZyddlmZ W n e k rd ddlmZ Y nX ejd5kr~ddl mZ ndZddlZddlmZmZmZmZ ddd hZeed �r�ejej� ejej� d6ZeZd8dd�ZG dd� d�ZG dd� d�Zy ejZW n( e k �r. G dd� de!e"�ZY nX G dd� dej#d�Z$ej$j%e$� G dd� de$�Z&ej&j%e&� ddl'm(Z( e&j%e(� G dd� de$�Z)ej)j%e)� G dd � d e)�Z*G d!d"� d"e)�Z+G d#d$� d$e*�Z,G d%d&� d&e*�Z-G d'd(� d(e)�Z.G d)d*� d*e-e,�Z/G d+d,� d,e&�Z(G d-d.� d.e$�Z0ej0j%e0� G d/d0� d0ej1�Z2G d1d2� d2e0�Z3G d3d4� d4e3�Z4dS )9z) Python implementation of the io module. � N)� allocate_lock�win32�cygwin)�setmode)�__all__�SEEK_SET�SEEK_CUR�SEEK_END� � � SEEK_HOLE� i �rTc C s~ t | t�stj| �} t | tttf�s0td| ��t |t�sFtd| ��t |t�s\td| ��|dk r|t |t� r|td| ��|dk r�t |t� r�td| ��t|�}|td� s�t|�t|�kr�t d| ��d|k} d |k} d |k}d|k}d|k} d |k}d|k}d|k�rH| �s&|�s&|�s&| �r.t d��ddl }|jdtd� d} |�r\|�r\t d��| | | | dk�rzt d��| �p�| �p�|�p�|�s�t d��|�r�|dk �r�t d��|�r�|dk �r�t d��|�r�|dk �r�t d��t | | �r�d�p�d| �r d �pd |�rd �pd |�r d�p"d | �r0d�p2d ||d�}|}�yd}|dk�sh|dk �rp|j� �rpd"}d}|dk �r�t}ytj|j� �j}W n ttfk �r� Y nX |dk�r�|}|dk �r�t d��|dk�r�|�r�|S t d ��| �r�t||�}n<| �s|�s|�rt||�}n| �r,t||�}nt d!| ��|}|�rF|S t|||||�}|}||_|S |j� � Y nX dS )#a� Open file and return a stream. Raise OSError upon failure. file is either a text or byte string giving the name (and the path if the file isn't in the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed, unless closefd is set to False.) mode is an optional string that specifies the mode in which the file is opened. It defaults to 'r' which means open for reading in text mode. Other common values are 'w' for writing (truncating the file if it already exists), 'x' for exclusive creation of a new file, and 'a' for appending (which on some Unix systems, means that all writes append to the end of the file regardless of the current seek position). In text mode, if encoding is not specified the encoding used is platform dependent. (For reading and writing raw bytes use binary mode and leave encoding unspecified.) The available modes are: ========= =============================================================== Character Meaning --------- --------------------------------------------------------------- 'r' open for reading (default) 'w' open for writing, truncating the file first 'x' create a new file and open it for writing 'a' open for writing, appending to the end of the file if it exists 'b' binary mode 't' text mode (default) '+' open a disk file for updating (reading and writing) 'U' universal newline mode (deprecated) ========= =============================================================== The default mode is 'rt' (open for reading text). For binary random access, the mode 'w+b' opens and truncates the file to 0 bytes, while 'r+b' opens the file without truncation. The 'x' mode implies 'w' and raises an `FileExistsError` if the file already exists. Python distinguishes between files opened in binary and text modes, even when the underlying operating system doesn't. Files opened in binary mode (appending 'b' to the mode argument) return contents as bytes objects without any decoding. In text mode (the default, or when 't' is appended to the mode argument), the contents of the file are returned as strings, the bytes having been first decoded using a platform-dependent encoding or using the specified encoding if given. 'U' mode is deprecated and will raise an exception in future versions of Python. It has no effect in Python 3. Use newline to control universal newlines mode. buffering is an optional integer used to set the buffering policy. Pass 0 to switch buffering off (only allowed in binary mode), 1 to select line buffering (only usable in text mode), and an integer > 1 to indicate the size of a fixed-size chunk buffer. When no buffering argument is given, the default buffering policy works as follows: * Binary files are buffered in fixed-size chunks; the size of the buffer is chosen using a heuristic trying to determine the underlying device's "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. On many systems, the buffer will typically be 4096 or 8192 bytes long. * "Interactive" text files (files for which isatty() returns True) use line buffering. Other text files use the policy described above for binary files. encoding is the str name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent, but any encoding supported by Python can be passed. See the codecs module for the list of supported encodings. errors is an optional string that specifies how encoding errors are to be handled---this argument should not be used in binary mode. Pass 'strict' to raise a ValueError exception if there is an encoding error (the default of None has the same effect), or pass 'ignore' to ignore errors. (Note that ignoring encoding errors can lead to data loss.) See the documentation for codecs.register for a list of the permitted encoding error strings. newline is a string controlling how universal newlines works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works as follows: * On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newline mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated. * On output, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string. closedfd is a bool. If closefd is False, the underlying file descriptor will be kept open when the file is closed. This does not work when a file name is given and must be True in that case. The newly created file is non-inheritable. A custom opener can be used by passing a callable as *opener*. The underlying file descriptor for the file object is then obtained by calling *opener* with (*file*, *flags*). *opener* must return an open file descriptor (passing os.open as *opener* results in functionality similar to passing None). open() returns a file object whose type depends on the mode, and through which the standard file operations such as reading and writing are performed. When open() is used to open a file in a text mode ('w', 'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open a file in a binary mode, the returned class varies: in read binary mode, it returns a BufferedReader; in write binary and append binary modes, it returns a BufferedWriter, and in read/write mode, it returns a BufferedRandom. It is also possible to use a string or bytearray as a file for both reading and writing. For strings StringIO can be used like a file opened in a text mode, and for bytes a BytesIO can be used like a file opened in a binary mode. zinvalid file: %rzinvalid mode: %rzinvalid buffering: %rNzinvalid encoding: %rzinvalid errors: %rzaxrwb+tU�xr �w�a�+�t�b�Uz4mode U cannot be combined with 'x', 'w', 'a', or '+'r z'U' mode is deprecatedr Tz'can't have text and binary mode at oncer z)can't have read/write/append mode at oncez/must have exactly one of read/write/append modez-binary mode doesn't take an encoding argumentz+binary mode doesn't take an errors argumentz+binary mode doesn't take a newline argument� )�openerFzinvalid buffering sizezcan't have unbuffered text I/Ozunknown mode: %r���)� isinstance�int�os�fspath�str�bytes� TypeError�set�len� ValueError�warnings�warn�DeprecationWarning�FileIO�isatty�DEFAULT_BUFFER_SIZE�fstat�fileno� st_blksize�OSError�AttributeError�BufferedRandom�BufferedWriter�BufferedReader� TextIOWrapper�mode�close)�filer2 � buffering�encoding�errors�newline�closefdr ZmodesZcreatingZreadingZwritingZ appendingZupdating�textZbinaryr# �raw�result�line_bufferingZbs�buffer� r? �/usr/lib64/python3.6/_pyio.py�open( s� { > rA c @ s e Zd ZdZdd� ZdS )� DocDescriptorz%Helper for builtins.open.__doc__ c C s dt j S )Nz\open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True) )rA �__doc__)�self�obj�typr? r? r@ �__get__� s zDocDescriptor.__get__N)�__name__� __module__�__qualname__rC rG r? r? r? r@ rB � s rB c @ s e Zd ZdZe� Zdd� ZdS )�OpenWrapperz�Wrapper for builtins.open Trick so that open won't become a bound method when stored as a class variable (as dbm.dumb does). See initstdio() in Python/pylifecycle.c. c O s t ||�S )N)rA )�cls�args�kwargsr? r? r@ �__new__ s zOpenWrapper.__new__N)rH rI rJ rC rB rO r? r? r? r@ rK s rK c @ s e Zd ZdS )�UnsupportedOperationN)rH rI rJ r? r? r? r@ rP s rP c @ s� e Zd ZdZdd� Zd6dd�Zdd� Zd7d d�Zdd � ZdZ dd� Z dd� Zdd� Zd8dd�Z dd� Zd9dd�Zdd� Zd:dd�Zedd � �Zd;d!d"�Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd=d,d-�Zd.d/� Zd0d1� Zd>d2d3�Zd4d5� Zd S )?�IOBaseag The abstract base class for all I/O classes, acting on streams of bytes. There is no public constructor. This class provides dummy implementations for many methods that derived classes can override selectively; the default implementations represent a file that cannot be read, written or seeked. Even though IOBase does not declare read, readinto, or write because their signatures will vary, implementations and clients should consider those methods part of the interface. Also, implementations may raise UnsupportedOperation when operations they do not support are called. The basic type used for binary data read from or written to a file is bytes. Other bytes-like objects are accepted as method arguments too. In some cases (such as readinto), a writable object is required. Text I/O classes work with str data. Note that calling any method (even inquiries) on a closed stream is undefined. Implementations may raise OSError in this case. IOBase (and its subclasses) support the iterator protocol, meaning that an IOBase object can be iterated over yielding the lines in a stream. IOBase also supports the :keyword:`with` statement. In this example, fp is closed after the suite of the with statement is complete: with open('spam.txt', 'r') as fp: fp.write('Spam and eggs!') c C s t d| jj|f ��dS )z@Internal: raise an OSError exception for unsupported operations.z%s.%s() not supportedN)rP � __class__rH )rD �namer? r? r@ �_unsupported@ s zIOBase._unsupportedr c C s | j d� dS )a$ Change stream position. Change the stream position to byte offset pos. Argument pos is interpreted relative to the position indicated by whence. Values for whence are ints: * 0 -- start of stream (the default); offset should be zero or positive * 1 -- current stream position; offset may be negative * 2 -- end of stream; offset is usually negative Some operating systems / file systems could provide additional values. Return an int indicating the new absolute position. �seekN)rT )rD �pos�whencer? r? r@ rU G s zIOBase.seekc C s | j dd�S )z5Return an int indicating the current stream position.r r )rU )rD r? r? r@ �tellW s zIOBase.tellNc C s | j d� dS )z�Truncate file to size bytes. Size defaults to the current IO position as reported by tell(). Return the new size. �truncateN)rT )rD rV r? r? r@ rY [ s zIOBase.truncatec C s | j � dS )zuFlush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. N)�_checkClosed)rD r? r? r@ �flushe s zIOBase.flushFc C s | j sz| j� W dd| _ X dS )ziFlush and close the IO object. This method has no effect if the file is already closed. NT)�_IOBase__closedr[ )rD r? r? r@ r3 o s zIOBase.closec C s y| j � W n Y nX dS )zDestructor. Calls close().N)r3 )rD r? r? r@ �__del__z s zIOBase.__del__c C s dS )z�Return a bool indicating whether object supports random access. If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek(). Fr? )rD r? r? r@ �seekable� s zIOBase.seekablec C s | j � st|dkrdn|��dS )zEInternal: raise UnsupportedOperation if file is not seekable NzFile or stream is not seekable.)r^ rP )rD �msgr? r? r@ �_checkSeekable� s zIOBase._checkSeekablec C s dS )zvReturn a bool indicating whether object was opened for reading. If False, read() will raise OSError. Fr? )rD r? r? r@ �readable� s zIOBase.readablec C s | j � st|dkrdn|��dS )zEInternal: raise UnsupportedOperation if file is not readable NzFile or stream is not readable.)ra rP )rD r_ r? r? r@ �_checkReadable� s zIOBase._checkReadablec C s dS )z�Return a bool indicating whether object was opened for writing. If False, write() and truncate() will raise OSError. Fr? )rD r? r? r@ �writable� s zIOBase.writablec C s | j � st|dkrdn|��dS )zEInternal: raise UnsupportedOperation if file is not writable NzFile or stream is not writable.)rc rP )rD r_ r? r? r@ �_checkWritable� s zIOBase._checkWritablec C s | j S )z�closed: bool. True iff the file has been closed. For backwards compatibility, this is a property, not a predicate. )r\ )rD r? r? r@ �closed� s z IOBase.closedc C s | j rt|dkrdn|��dS )z7Internal: raise a ValueError if file is closed NzI/O operation on closed file.)re r"