eric5.Utilities.compatibility_fixes

Module implementing the open behavior of Python3 for use with Eric5.

The Eric5 used features are emulated only. The not emulated features should throw a NotImplementedError exception.

Global Attributes

None

Classes

File

Functions

open Replacement for the build in open function.


File

Derived from

file

Class Attributes

fp

Class Methods

None

Methods

File Constructor
next Public method used in an iterator.
read Public method to read n bytes or all if n=-1 from file.
readline Public method to read one line from file.
readlines Public method to read all lines from file.
write Public method to write given data to file and encode if needed.

Static Methods

None

File (Constructor)

File(filein, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)

Constructor

It checks for unimplemented parameters.

filein
filename or file descriptor (string)
mode=
access mode (string)
buffering=
size of the read buffer (string)
encoding=
character encoding for reading/ writing (string)
errors=
behavior for the character encoding ('strict', 'explicit', ...) (string)
newline=
controls how universal newlines works (string)
closefd=
close underlying file descriptor if given as file parameter (boolean)
Raises NotImplementedError:
for not implemented method parameters

File.next

next()

Public method used in an iterator.

Returns:
decoded data read

File.read

read(n=-1)

Public method to read n bytes or all if n=-1 from file.

n=
bytecount or all if n=-1 (int)
Returns:
decoded bytes read

File.readline

readline(limit=-1)

Public method to read one line from file.

limit=
maximum bytes to read or all if limit=-1 (int)
Returns:
decoded line read

File.readlines

readlines(hint=-1)

Public method to read all lines from file.

hint=
maximum bytes to read or all if hint=-1 (int)
Returns:
decoded lines read

File.write

write(txt)

Public method to write given data to file and encode if needed.

txt
data to write. (str, bytes)
Up


open

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)

Replacement for the build in open function.

file
filename or file descriptor (string)
mode=
access mode (string)
buffering=
size of the read buffer (string)
encoding=
character encoding for reading/ writing (string)
errors=
behavior for the character encoding ('strict', 'explicit', ...) (string)
newline=
controls how universal newlines works (string)
closefd=
close underlying file descriptor if given as file parameter (boolean)
Returns:
Returns the new file object
Up