Wed, 13 Jul 2022 15:34:50 +0200
Revisions <no_multi_processing, Variables Viewer, with_python2> closed.
<!DOCTYPE html> <html><head> <title>eric6.Globals.compatibility_fixes</title> <meta charset="UTF-8"> <style> body { background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } h1 { color: white; background: #85774A; } h2 { color: white; background: #85774A; } h3 { color: white; background: #9D936E; } h4 { color: white; background: #9D936E; } a { color: #BA6D36; } </style> </head> <body><a NAME="top" ID="top"></a> <h1>eric6.Globals.compatibility_fixes</h1> <p> Module implementing some workarounds to let eric6 run under Python 2. </p> <h3>Global Attributes</h3> <table> <tr><td>__find_module</td></tr><tr><td>__join</td></tr><tr><td>__load_source</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#File">File</a></td> <td></td> </tr><tr> <td><a href="#PlainStrList">PlainStrList</a></td> <td>Keep track that all added paths to sys.path are str.</td> </tr> </table> <h3>Functions</h3> <table> <tr> <td><a href="#find_moduleAsStr">find_moduleAsStr</a></td> <td>Convert none str parameter of the imp.find_module into str.</td> </tr><tr> <td><a href="#joinAsUnicode">joinAsUnicode</a></td> <td>Convert none unicode parameter of the os.path.join into unicode.</td> </tr><tr> <td><a href="#load_sourceAsStr">load_sourceAsStr</a></td> <td>Convert none str parameter of the imp.load_source into str.</td> </tr><tr> <td><a href="#open">open</a></td> <td>Replacement for the build in open function.</td> </tr> </table> <hr /><hr /> <a NAME="File" ID="File"></a> <h2>File</h2> <h3>Derived from</h3> file <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#File.__init__">File</a></td> <td>Constructor</td> </tr><tr> <td><a href="#File.next">next</a></td> <td>Public method used in an iterator.</td> </tr><tr> <td><a href="#File.read">read</a></td> <td>Public method to read n bytes or all if n=-1 from file.</td> </tr><tr> <td><a href="#File.readline">readline</a></td> <td>Public method to read one line from file.</td> </tr><tr> <td><a href="#File.readlines">readlines</a></td> <td>Public method to read all lines from file.</td> </tr><tr> <td><a href="#File.write">write</a></td> <td>Public method to write given data to file and encode if needed.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="File.__init__" ID="File.__init__"></a> <h4>File (Constructor)</h4> <b>File</b>(<i>filein, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True</i>) <p> Constructor </p><p> It checks for unimplemented parameters. </p><dl> <dt><i>filein</i></dt> <dd> filename or file descriptor (string) </dd><dt><i>mode=</i></dt> <dd> access mode (string) </dd><dt><i>buffering=</i></dt> <dd> size of the read buffer (string) </dd><dt><i>encoding=</i></dt> <dd> character encoding for reading/ writing (string) </dd><dt><i>errors=</i></dt> <dd> behavior for the character encoding ('strict', 'explicit', ...) (string) </dd><dt><i>newline=</i></dt> <dd> controls how universal newlines works (string) </dd><dt><i>closefd=</i></dt> <dd> close underlying file descriptor if given as file parameter (boolean) </dd> </dl><dl> <dt>Raises <b>NotImplementedError</b>:</dt> <dd> for not implemented method parameters </dd> </dl><a NAME="File.next" ID="File.next"></a> <h4>File.next</h4> <b>next</b>(<i></i>) <p> Public method used in an iterator. </p><dl> <dt>Returns:</dt> <dd> decoded data read </dd> </dl><a NAME="File.read" ID="File.read"></a> <h4>File.read</h4> <b>read</b>(<i>n=-1</i>) <p> Public method to read n bytes or all if n=-1 from file. </p><dl> <dt><i>n=</i></dt> <dd> bytecount or all if n=-1 (int) </dd> </dl><dl> <dt>Returns:</dt> <dd> decoded bytes read </dd> </dl><a NAME="File.readline" ID="File.readline"></a> <h4>File.readline</h4> <b>readline</b>(<i>limit=-1</i>) <p> Public method to read one line from file. </p><dl> <dt><i>limit=</i></dt> <dd> maximum bytes to read or all if limit=-1 (int) </dd> </dl><dl> <dt>Returns:</dt> <dd> decoded line read </dd> </dl><a NAME="File.readlines" ID="File.readlines"></a> <h4>File.readlines</h4> <b>readlines</b>(<i>hint=-1</i>) <p> Public method to read all lines from file. </p><dl> <dt><i>hint=</i></dt> <dd> maximum bytes to read or all if hint=-1 (int) </dd> </dl><dl> <dt>Returns:</dt> <dd> decoded lines read </dd> </dl><a NAME="File.write" ID="File.write"></a> <h4>File.write</h4> <b>write</b>(<i>txt</i>) <p> Public method to write given data to file and encode if needed. </p><dl> <dt><i>txt</i></dt> <dd> data to write. (str, bytes) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="PlainStrList" ID="PlainStrList"></a> <h2>PlainStrList</h2> <p> Keep track that all added paths to sys.path are str. </p> <h3>Derived from</h3> list <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#PlainStrList.__init__">PlainStrList</a></td> <td>Constructor</td> </tr><tr> <td><a href="#PlainStrList.__convert">__convert</a></td> <td>Private method to convert unicode to file system encoding.</td> </tr><tr> <td><a href="#PlainStrList.__setitem__">__setitem__</a></td> <td>Special method to overwrite a specific list item.</td> </tr><tr> <td><a href="#PlainStrList.insert">insert</a></td> <td>Public method to insert a specific list item.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="PlainStrList.__init__" ID="PlainStrList.__init__"></a> <h4>PlainStrList (Constructor)</h4> <b>PlainStrList</b>(<i>*args</i>) <p> Constructor </p><dl> <dt><i>args</i></dt> <dd> list of paths to start with (list) </dd> </dl><a NAME="PlainStrList.__convert" ID="PlainStrList.__convert"></a> <h4>PlainStrList.__convert</h4> <b>__convert</b>(<i>element</i>) <p> Private method to convert unicode to file system encoding. </p><dl> <dt><i>element</i></dt> <dd> to convert from unicode to file system encoding (any) </dd> </dl><dl> <dt>Returns:</dt> <dd> converted element </dd> </dl><a NAME="PlainStrList.__setitem__" ID="PlainStrList.__setitem__"></a> <h4>PlainStrList.__setitem__</h4> <b>__setitem__</b>(<i>idx, value</i>) <p> Special method to overwrite a specific list item. </p><dl> <dt><i>idx</i></dt> <dd> index of the item (int) </dd><dt><i>value</i></dt> <dd> the new value (any) </dd> </dl><a NAME="PlainStrList.insert" ID="PlainStrList.insert"></a> <h4>PlainStrList.insert</h4> <b>insert</b>(<i>idx, value</i>) <p> Public method to insert a specific list item. </p><dl> <dt><i>idx</i></dt> <dd> index of the item (int) </dd><dt><i>value</i></dt> <dd> the new value (any) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="find_moduleAsStr" ID="find_moduleAsStr"></a> <h2>find_moduleAsStr</h2> <b>find_moduleAsStr</b>(<i>*args</i>) <p> Convert none str parameter of the imp.find_module into str. </p><dl> <dt><i>args</i></dt> <dd> (str, unicode) </dd> </dl><dl> <dt>Returns:</dt> <dd> list of args converted to str (list) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="joinAsUnicode" ID="joinAsUnicode"></a> <h2>joinAsUnicode</h2> <b>joinAsUnicode</b>(<i>*args</i>) <p> Convert none unicode parameter of the os.path.join into unicode. </p><dl> <dt><i>args</i></dt> <dd> paths which should be joined (str, unicode) </dd> </dl><dl> <dt>Returns:</dt> <dd> unicode str of the path (unicode) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="load_sourceAsStr" ID="load_sourceAsStr"></a> <h2>load_sourceAsStr</h2> <b>load_sourceAsStr</b>(<i>*args</i>) <p> Convert none str parameter of the imp.load_source into str. </p><dl> <dt><i>args</i></dt> <dd> (str, unicode) </dd> </dl><dl> <dt>Returns:</dt> <dd> list of args converted to str (list) </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="open" ID="open"></a> <h2>open</h2> <b>open</b>(<i>filein, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True</i>) <p> Replacement for the build in open function. </p><dl> <dt><i>filein</i></dt> <dd> filename or file descriptor (string) </dd><dt><i>mode=</i></dt> <dd> access mode (string) </dd><dt><i>buffering=</i></dt> <dd> size of the read buffer (string) </dd><dt><i>encoding=</i></dt> <dd> character encoding for reading/ writing (string) </dd><dt><i>errors=</i></dt> <dd> behavior for the character encoding ('strict', 'explicit', ...) (string) </dd><dt><i>newline=</i></dt> <dd> controls how universal newlines works (string) </dd><dt><i>closefd=</i></dt> <dd> close underlying file descriptor if given as file parameter (boolean) </dd> </dl><dl> <dt>Returns:</dt> <dd> Returns the new file object </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>