Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
fileinput.cpython-314.pyc175 linesDownload Raw Back to __pycache__
1+
2��ie=�	���Rt^RIt^RIt^RIt^RIHt.ROtRsRRRRRRRRR/R	lltR3t	Rt4RtR
tRt
RtRtRt!RR4tRRRR/RltRRltRt]R8Xd5]!4R#R#)a�Helper class to quickly write a loop over all standard input files.6 7Typical use is:8 9    import fileinput10    for line in fileinput.input(encoding="utf-8"):11        process(line)12 13This iterates over the lines of all files listed in sys.argv[1:],14defaulting to sys.stdin if the list is empty.  If a filename is '-' it15is also replaced by sys.stdin and the optional arguments mode and16openhook are ignored.  To specify an alternative list of filenames,17pass it as the argument to input().  A single file name is also allowed.18 19Functions filename(), lineno() return the filename and cumulative line20number of the line that has just been read; filelineno() returns its21line number in the current file; isfirstline() returns true iff the22line just read is the first line of its file; isstdin() returns true23iff the line was read from sys.stdin.  Function nextfile() closes the24current file so that the next iteration will read the first line from25the next file (if any); lines not read from the file will not count26towards the cumulative line count; the filename is not changed until27after the first line of the next file has been read.  Function close()28closes the sequence.29 30Before any lines have been read, filename() returns None and both line31numbers are zero; nextfile() has no effect.  After all lines have been32read, filename() and the line number functions return the values33pertaining to the last line read; nextfile() has no effect.34 35All files are opened in text mode by default, you can override this by36setting the mode parameter to input() or FileInput.__init__().37If an I/O error occurs during opening or reading a file, the OSError38exception is raised.39 40If sys.stdin is used more than once, the second and further use will41return no lines, except perhaps for interactive use, or if it has been42explicitly reset (e.g. using sys.stdin.seek(0)).43 44Empty files are opened and immediately closed; the only time their45presence in the list of filenames is noticeable at all is when the46last file opened is empty.47 48It is possible that the last line of a file doesn't end in a newline49character; otherwise lines are returned including the trailing50newline.51 52Class FileInput is the implementation; its methods filename(),53lineno(), fileline(), isfirstline(), isstdin(), nextfile() and close()54correspond to the functions in the module.  In addition it has a55readline() method which returns the next input line, and a56__getitem__() method which implements the sequence behavior.  The57sequence must be accessed in strictly sequential order; sequence58access and readline() cannot be mixed.59 60Optional in-place filtering: if the keyword argument inplace=True is61passed to input() or to the FileInput constructor, the file is moved62to a backup file and standard output is directed to the input file.63This makes it possible to write a filter that rewrites its input file64in place.  If the keyword argument backup=".<some extension>" is also65given, it specifies the extension for the backup file, and the backup66file remains around; by default, the extension is ".bak" and it is67deleted when the output file is closed.  In-place filtering is68disabled when standard input is read.  XXX The current implementation69does not work for MS-DOS 8+3 filesystems.70N)�GenericAlias�	FileInput�mode�r�openhook�encoding�errorsc71��\'d"\P'd\R4h\WW#VWVR7s\#)z�Return an instance of the FileInput class, which can be iterated.72 73The parameters are passed to the constructor of the FileInput class.74The returned instance, in addition to being an iterator,75keeps global state for the functions of this module,.76zinput() already active)rrrr)�_state�_file�RuntimeErrorr)�files�inplace�backuprrrrs&&&$$$$�Lib\fileinput.py�inputrNs5���v�&�,�,�,��3�4�4�
�u�v�8� (�9�F��M�c�J�\pRsV'dVP4R#R#)zClose the sequence.N)r77�close)�states rrr]s��
�E�
�F��
���
�
rc�X�\'g\R4h\P4#)a�78Close the current file so that the next iteration will read the first79line from the next file (if any); lines not read from the file will80not count towards the cumulative line count. The filename is not81changed until after the first line of the next file has been read.82Before the first line has been read, this function has no effect;83it cannot be used to skip the first file. After the last line of the84last file has been read, this function has no effect.85�no active input())r86r�nextfile�rrrres"���6��.�/�/��?�?��rc�X�\'g\R4h\P4#)zf87Return the name of the file currently being read.88Before the first line has been read, returns None.89r)r90r�filenamerrrrrss"��91�6��.�/�/��?�?��rc�X�\'g\R4h\P4#)z�92Return the cumulative line number of the line that has just been read.93Before the first line has been read, returns 0. After the last line94of the last file has been read, returns the line number of that line.95r)r96r�linenorrrrr|s!���6��.�/�/��=�=�?�rc�X�\'g\R4h\P4#)z�97Return the line number in the current file. Before the first line98has been read, returns 0. After the last line of the last file has99been read, returns the line number of that line within the file.100r)r101r�102filelinenorrrrr�s$���6��.�/�/�����rc�X�\'g\R4h\P4#)z[103Return the file number of the current file. When no file is currently104opened, returns -1.105r)r106r�filenorrrr!r!�s!��107�6��.�/�/��=�=�?�rc�X�\'g\R4h\P4#)zY108Returns true the line just read is the first line of its file,109otherwise returns false.110r)r111r�isfirstlinerrrr#r#�s$��112�6��.�/�/�����rc�X�\'g\R4h\P4#)zQ113Returns true if the last line was read from sys.stdin,114otherwise returns false.115r)r116r�isstdinrrrr%r%�s"��117�6��.�/�/��>�>��rc	�a�]tRt^�toRtRRRRRRRRR/RlltR	tR118tRtRt	R
t119RtRtRt
RtRtRtRtRtRtRt]!]4tRtVtR#)raFileInput([files[, inplace[, backup]]], *, mode=None, openhook=None)120 121Class FileInput is the implementation of the module; its methods122filename(), lineno(), fileline(), isfirstline(), isstdin(), fileno(),123nextfile() and close() correspond to the functions of the same name124in the module.125In addition it has a readline() method which returns the next126input line, and a __getitem__() method which implements the127sequence behavior. The sequence must be accessed in strictly128sequential order; random access and readline() cannot be mixed.129Nrrrrrc�$�\V\4'dV3pMi\V\P4'd\P!V43pM1Vf\130PR,pV'gR131pM\V4pWnW n	W0n132RVnRVnRVn
^Vn^VnRVnRVnRVnW`nWpn\133P*P,'d+RV9d$Vf Vf^RIpVP1R\2^4VR9d\5R4hW@nVP9RR4VnV'd0V'd\5R4h\=V4'g\5R	4hWPnR#)N��NNF�bz"'encoding' argument not specified.rz*FileInput opening mode must be 'r' or 'rb'�wz4FileInput cannot use an opening hook in inplace modez#FileInput openhook must be callable)�-)r�rb) �134isinstance�str�os�PathLike�fspath�sys�argv�tuple�_files�_inplace�_backup�_savestdout�_output�	_filename�_startlineno�_filelinenor�_isstdin�_backupfilename�	_encoding�_errors�flags�warn_default_encoding�warnings�warn�EncodingWarning�135ValueError�_mode�replace�_write_mode�callable�	_openhook)	�selfr
rrrrrrrDs	&&&&$$$$ r�__init__�FileInput.__init__�sF���e�S�!�!��H�E�
��r�{�{�
+�
+��Y�Y�u�%�(�E��}�����������e������
��������������������136���
�#���!����
�I�I�+�+�+��4��H�$4��9I���M�M�>�)�1�
.��{�"��I�J�J��137��<�<��S�1����� �!W�X�X��H�%�%� �!F�G�G�!�rc�&�VP4R#�N�r�rMs&r�__del__�FileInput.__del__�����138�139�rc�N�VP4RVnR# RTni;i)Nr)rr6rSs&rr�FileInput.close�s��	��M�M�O��D�K��"�D�K�s��	$c��V#rQrrSs&r�	__enter__�FileInput.__enter__�����rc�&�VP4R#rQrR)rM�type�value�	tracebacks&&&&r�__exit__�FileInput.__exit__�rVrc��V#rQrrSs&r�__iter__�FileInput.__iter__�r\rc��VP4pV'dV;P^,
unV#VP'g\hVP	4K^�T)�	_readliner=r�
StopIterationr�rM�lines& r�__next__�FileInput.__next__�sB����>�>�#�D��� � �A�%� ����:�:�:�#�#��M�M�Orc�(�VPpRVnV'dV\nVPpRVnV'dVP	4VP140pRVnV=V'd#VP'gVP	4VPpRVn	V'd)VP'g\P!V4RVnR# \dL�i;i \dL'i;i TPpRTn	T'dITP'g7\P!T4RTni \dRTnii;iRTni;i TP141pRTnT=M \dMi;iT'd#TP'gTP	4TPpRTn	T'd;TP'g)\P!T4M \dMi;iRTni TPpRTn	T'dITP'g7\P!T4RTni \dRTnii;iRTni;i;i)NF)r9r3�stdoutr:rrrh�AttributeErrorr>r?r8r0�unlink�OSError)rM�142savestdout�output�file�backupfilenames&    rr�FileInput.nextfiles����%�%�143�����#�C�J��������	&�������:�:�D��D�J�
��N�144
&���
�
�
��J�J�L�!%�!5�!5��'+��$�!�$�,�,�,����>�2�!&��
��"�
��
��#�(�D�(��	"&�!5�!5��'+��$�!�$�,�,�,����>�2�!&��
��#�(�D� %��
�)�� %��
��!�:�:�D��D�J�
��N��!�
��
��145
&���
�
�
��J�J�L�!%�!5�!5��'+��$�!�$�,�,�,����>�2��"�(�D�(�� %��
��
"&�!5�!5��'+��$�!�$�,�,�,����>�2�!&��
��#�(�D� %��
�)�� %��
�s�E1�E1�'C �*D�2D�D�C1� C.�-C.�1C?�>C?�-E.�0E�E.�E#�	E.�"E#�#E.�1J�F	�J�	F�J�F�J�H"�#H"�5H"�,J�2H	�J�	H�J�H�J�"-J�I.�&J�.J�9	J�J�J�Jc��VP4pV'dV;P^,
unV#VP'gV#VP4KZrg)rhr=rrrjs& r�readline�FileInput.readline"sA����>�>�#�D��� � �A�%� ����:�:�:����M�M�Orc�	�VP'gRVP9dR#R#VP^,VnVPR,VnVP4Vn^VnRVnRVn^VnRVP9dVP;'gRpMRpVPR8XdfRVnRVP9d0\\PR	\P4VnM\PVnR146VnEM�VP'Ed�\P!VP4VP ;'gR,Vn\P"!VP4\P&!VPVP4\)VPVPWP*R7Vn\P,!VPP/44P0p\P2\P4,\P6,p\9\R
4'dV\P:,p\P(!VPW24p\P<!W@P>WP*R7Vn \PB!VPV4\PDTn#TP@\n"M�VPH'd~VPf-VPIVPVP4VnMtVPIVPVPVPVP*R7VnM1\)VPVPWP*R7VnVPPJVn&VPM4# \$dEL�i;i \$dEL6i;i \$d6\)TPTP>YP*R7Tn ELyi;i)r*r�r(NF�localer,z<stdin>�bufferTz.bak�rr�O_BINARY)'r6rHr;rr<r=rr>r?r@�getattrr3�stdinr7r0r2r8rqrr�rename�openrA�fstatr!�st_mode�O_CREAT�O_WRONLY�O_TRUNC�hasattrr��fdopenrJr:�chmodror9rLryrh)rMr�permr�fds&    rrh�FileInput._readline-s���{�{�{��d�j�j� ������Q�����k�k�"�o��� �K�K�M��������147���
� ����d�j�j� ��~�~�1�1��H��H��>�>�S� �&�D�N��d�j�j� �$�S�Y�Y��#�)�)�D��148� �Y�Y��149� �D�M��}�}�}��I�I�d�n�n�-����1G�1G��H��$���I�I�d�2�2�3��	�	�$�.�.�$�*>�*>�?�!�$�"6�"6��150�151�+3�L�L�J��152���8�8�D�J�J�$5�$5�$7�8�@�@�D�153�:�:����3�b�j�j�@�D��r�:�.�.�����+���������<�B�#%�9�9�R�1A�1A�6>�|�|�$U�D�L���������6�$'�:�:�� �!�\�\��154��>�>�>��~�~�-�%)�^�^�D�N�N�D�J�J�%O��155�%)�^�^� �N�N�D�J�J����X\�Xd�Xd�&4�&f��156�"&�d�n�n�d�j�j�8�\h�\h�!i�D�J����,�,����~�~����M�����*#������P�#'�����8H�8H�19�,�,�$P�D�L�P�s6�= P#�:8Q�,!P5�#P2�1P2�5Q�Q�<R�Rc��VP#rQ)r;rSs&rr�FileInput.filenamevs���~�~�rc�<�VPVP,#rQ)r<r=rSs&rr�FileInput.linenoys��� � �4�#3�#3�3�3rc��VP#rQ�r=rSs&rr�FileInput.filelineno|s�����rc��VP'dVPP4#R# \dRu#i;i)r)�����)rr!rGrSs&rr!�FileInput.filenos@���:�:�:�
��z�z�(�(�*�*��I���
��	�
�s�0�
A�Ac� �VP^8H#)r)r�rSs&rr#�FileInput.isfirstline�s�����1�$�$rc��VP#rQ)r>rSs&rr%�FileInput.isstdin�s���}�}�r)r8r?r@rArr=r;r6r7r>rHrLr:rhr9r<rJ�NFr|)�__name__�157__module__�__qualname__�__firstlineno__�__doc__rNrTrrZrardrlrryrhrrrr!r#r%�classmethodr�__class_getitem__�__static_attributes__�__classdictcell__)�
__classdict__s@rrr�s�����158�-"��-"�$(�-"�37�-"�@D�-"�^������&�<�G �R�4� ��%��$�L�1�rc�8�Vf159RV9dRp\PPV4^,pVR8Xd^RIpVP	W4pM*VR8Xd^RIpVP
W4pM
\	WW#R7#RV9d\P!WbVR7pV#)Nr*r}z.gzz.bz2r)	r0�path�splitext�gzipr��bz2�BZ2File�io�
TextIOWrapper)rrrr�extr��streamr�s&&$$    r�hook_compressedr��s�����C�t�O���160�'�'�161�162�8�163$�Q�164'�C�165�e�|�����8�*��	�������X�,���H�X�E�E��$���!�!�&�F�K���Mrc�aa�VV3RlpV#)c� <�\WSSR7#)r)r�)rrrrs&&��rr�hook_encoded.<locals>.openhook�s����H�X�f�E�Err)rrrsff r�hook_encodedr��s���F��Orc	���^RIpRpRpVP\PR,R4wr4VFwrVVR8XdRpVR8XgKTpK	\WAVR7FlpVRRR	8XdVRRpVRRR1668XdVRRp\	R\4\
4\4\4;'dR;'gR
V3,4Kn	\	R\4\
4\43,4R#)�NFr(zib:z-iTz-b)rr�167�
z%d: %s[%d]%s %s�*r|z168%d: %s[%d]r�)	�getoptr3r4r�printrrrr#)r�rr�opts�args�o�arks        r�_testr��s�����G�
�F����s�x�x��|�U�3�J�D������9��g���9�q�f���d�F�;�����9���T�#�2�Y�d����9���T�#�2�Y�d�
��6�8�X�Z���#.�=�#8�#8�S�#>�#>�B��#F�F�	G�<�169170�,�&�(�H�J�171��=�172=�>r�__main__)rrrrrrr!r#r%rr�r�r�rQ)r�r�r3r0�typesr�__all__r173rrrrrrr!r#r%rr�r�r�r�rrr�<module>r�s���A�F174�����175��
��
�d�
��
� $�
������� ��c2�c2�L���T��&�
?��z��	�G�r
codekingpro/portable-devtools · Team Ai