eric6.Globals.compatibility_fixes

Module implementing some workarounds to let eric6 run under Python 2.

Global Attributes

__find_module
__join
__load_source

Classes

File
PlainStrList Keep track that all added paths to sys.path are str.

Functions

find_moduleAsStr Convert none str parameter of the imp.find_module into str.
joinAsUnicode Convert none unicode parameter of the os.path.join into unicode.
load_sourceAsStr Convert none str parameter of the imp.load_source into str.
open Replacement for the build in open function.


File

Derived from

file

Class Attributes

None

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


PlainStrList

Keep track that all added paths to sys.path are str.

Derived from

list

Class Attributes

None

Class Methods

None

Methods

PlainStrList Constructor
__convert Private method to convert unicode to file system encoding.
__setitem__ Special method to overwrite a specific list item.
insert Public method to insert a specific list item.

Static Methods

None

PlainStrList (Constructor)

PlainStrList(*args)

Constructor

args
list of paths to start with (list)

PlainStrList.__convert

__convert(element)

Private method to convert unicode to file system encoding.

element
to convert from unicode to file system encoding (any)
Returns:
converted element

PlainStrList.__setitem__

__setitem__(idx, value)

Special method to overwrite a specific list item.

idx
index of the item (int)
value
the new value (any)

PlainStrList.insert

insert(idx, value)

Public method to insert a specific list item.

idx
index of the item (int)
value
the new value (any)
Up


find_moduleAsStr

find_moduleAsStr(*args)

Convert none str parameter of the imp.find_module into str.

args
(str, unicode)
Returns:
list of args converted to str (list)
Up


joinAsUnicode

joinAsUnicode(*args)

Convert none unicode parameter of the os.path.join into unicode.

args
paths which should be joined (str, unicode)
Returns:
unicode str of the path (unicode)
Up


load_sourceAsStr

load_sourceAsStr(*args)

Convert none str parameter of the imp.load_source into str.

args
(str, unicode)
Returns:
list of args converted to str (list)
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