types.file¶
Stdin = t.Union[t.Annotated[Stream, Stream.Args(sys.stdin)], io.StringIO]
module-attribute
¶
Read input from command line, or from stdin if -
is passed as the argument
File
¶
Bases: t.IO[str]
, abc.ABC
Obtains a handler to a file. Handles the access to the file, and gurantees that it is closed before exiting.
Example¶
There are constants defined on File
(like File.Read
above) for
all common actions (Read
, Write
, Append
, ReadWrite
, etc...).
View all of them below.
If none of the pre-defiend constants match your needs, you can customize
it with an Annotated
type.
File.Args
's call signature matches that of open
(minus the filename), so
all of the same properties apply
File
is Abstract and cannot be instantiated on it's own
Source code in /home/runner/work/arc/arc/arc/types/file.py
Append = t.Annotated[t.TextIO, Args(mode='a')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "a")
AppendRead = t.Annotated[t.TextIO, Args(mode='a+')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "a+")
BinaryAppend = t.Annotated[t.BinaryIO, Args('ab')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "ab")
BinaryAppendRead = t.Annotated[t.BinaryIO, Args('ab+')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "ab+")
BinaryCreateWrite = t.Annotated[t.BinaryIO, Args('xb')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "xb")
BinaryRead = t.Annotated[t.BinaryIO, Args('rb')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "rb")
BinaryReadWrite = t.Annotated[t.BinaryIO, Args('rb+')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "rb+")
BinaryWrite = t.Annotated[t.BinaryIO, Args('wb')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "wb")
CreateWrite = t.Annotated[t.TextIO, Args(mode='x')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "x")
Read = t.Annotated[t.TextIO, Args(mode='r')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "r")
ReadWrite = t.Annotated[t.TextIO, Args(mode='r+')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "r+")
Write = t.Annotated[t.TextIO, Args(mode='w')]
class-attribute
instance-attribute
¶
Equivalent to open(filename, "w")
StdinFile
¶
Bases: Stream
Read input from a file, or from a stdin if '-' is passed as the argument