]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/io.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / io.py
CommitLineData
4710c53d 1"""The io module provides the Python interfaces to stream handling. The\r
2builtin open function is defined in this module.\r
3\r
4At the top of the I/O hierarchy is the abstract base class IOBase. It\r
5defines the basic interface to a stream. Note, however, that there is no\r
6separation between reading and writing to streams; implementations are\r
7allowed to throw an IOError if they do not support a given operation.\r
8\r
9Extending IOBase is RawIOBase which deals simply with the reading and\r
10writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide\r
11an interface to OS files.\r
12\r
13BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its\r
14subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer\r
15streams that are readable, writable, and both respectively.\r
16BufferedRandom provides a buffered interface to random access\r
17streams. BytesIO is a simple stream of in-memory bytes.\r
18\r
19Another IOBase subclass, TextIOBase, deals with the encoding and decoding\r
20of streams into text. TextIOWrapper, which extends it, is a buffered text\r
21interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO\r
22is a in-memory stream for text.\r
23\r
24Argument names are not part of the specification, and only the arguments\r
25of open() are intended to be used as keyword arguments.\r
26\r
27data:\r
28\r
29DEFAULT_BUFFER_SIZE\r
30\r
31 An int containing the default buffer size used by the module's buffered\r
32 I/O classes. open() uses the file's blksize (as obtained by os.stat) if\r
33 possible.\r
34"""\r
35# New I/O library conforming to PEP 3116.\r
36\r
37# XXX edge cases when switching between reading/writing\r
38# XXX need to support 1 meaning line-buffered\r
39# XXX whenever an argument is None, use the default value\r
40# XXX read/write ops should check readable/writable\r
41# XXX buffered readinto should work with arbitrary buffer objects\r
42# XXX use incremental encoder for text output, at least for UTF-16 and UTF-8-SIG\r
43# XXX check writable, readable and seekable in appropriate places\r
44\r
45\r
46__author__ = ("Guido van Rossum <guido@python.org>, "\r
47 "Mike Verdone <mike.verdone@gmail.com>, "\r
48 "Mark Russell <mark.russell@zen.co.uk>, "\r
49 "Antoine Pitrou <solipsis@pitrou.net>, "\r
50 "Amaury Forgeot d'Arc <amauryfa@gmail.com>, "\r
51 "Benjamin Peterson <benjamin@python.org>")\r
52\r
53__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",\r
54 "BytesIO", "StringIO", "BufferedIOBase",\r
55 "BufferedReader", "BufferedWriter", "BufferedRWPair",\r
56 "BufferedRandom", "TextIOBase", "TextIOWrapper",\r
57 "UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]\r
58\r
59\r
60import _io\r
61import abc\r
62\r
63from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,\r
64 open, FileIO, BytesIO, StringIO, BufferedReader,\r
65 BufferedWriter, BufferedRWPair, BufferedRandom,\r
66 IncrementalNewlineDecoder, TextIOWrapper)\r
67\r
68OpenWrapper = _io.open # for compatibility with _pyio\r
69\r
70# for seek()\r
71SEEK_SET = 0\r
72SEEK_CUR = 1\r
73SEEK_END = 2\r
74\r
75# Declaring ABCs in C is tricky so we do it here.\r
76# Method descriptions and default implementations are inherited from the C\r
77# version however.\r
78class IOBase(_io._IOBase):\r
79 __metaclass__ = abc.ABCMeta\r
80\r
81class RawIOBase(_io._RawIOBase, IOBase):\r
82 pass\r
83\r
84class BufferedIOBase(_io._BufferedIOBase, IOBase):\r
85 pass\r
86\r
87class TextIOBase(_io._TextIOBase, IOBase):\r
88 pass\r
89\r
90RawIOBase.register(FileIO)\r
91\r
92for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,\r
93 BufferedRWPair):\r
94 BufferedIOBase.register(klass)\r
95\r
96for klass in (StringIO, TextIOWrapper):\r
97 TextIOBase.register(klass)\r
98del klass\r