hup.io package¶
Submodules¶
Module contents¶
File I/O.
-
class
FileConnector
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector], *args, **kwds)¶ Bases:
object
File Connector Class.
-
close
() → None¶
-
name
¶ Name of the referenced file object.
-
open
(*args, **kwds) → IO[Any]¶ Open file reference as file object.
-
-
class
FileInfo
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector])¶ Bases:
object
File Info Class.
Parameters: file – File reference to a file object. The reference can ether be given as a String or path-like object, that points to a valid entry in the file system, an instance of the class Connector
or an opened file object in reading or writing mode.-
name
¶ Name of the referenced file object.
-
-
class
FileProxy
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector], mode: str = 'rw')¶ Bases:
hup.base.abc.Proxy
File buffer for referenced files.
Creates a temporary file within the
tempdir
of the system, which acts as a local proxy for a referenced file object.Parameters: - file – File reference to a file object. The reference can
ether be given as a String or path-like object, that points
to a valid entry in the file system, an instance of the class
Connector
or an opened file object in reading or writing mode. - mode – String, which characters specify the mode in which the file stream
is wrapped. If mode contains the character ‘r’, then a
pull()
-request is executed during the initialisation, otherwise any pull-request raises aPullError
. If mode contains the character ‘w’, then apush()
-request is executed when closing the FileProxy instance withclose()
, otherwise any push-request raises aPushError
. The default mode is ‘rw’.
-
close
() → None¶ Execute push request and release bound resources.
-
connect
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector]) → None¶ Connect to given file reference.
-
disconnect
() → None¶ Close connection to referenced file.
-
name
¶ Name of the referenced file object
-
open
(*args, **kwds) → IO[Any]¶ Open file handler to temporary file.
-
path
¶ Path to the temporary file in use.
-
pull
() → None¶ Copy referenced file object to temporary file.
-
push
() → None¶ Copy temporary file to referenced file object.
- file – File reference to a file object. The reference can
ether be given as a String or path-like object, that points
to a valid entry in the file system, an instance of the class
-
openx
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector], *args, **kwds) → Iterator[IO[Any]]¶ Open file reference.
This context manager extends :py:func`open` by allowing the passed file argument to be an arbitrary file reference. If the file argument is a String or path-like object, the given path may contain application variables, like %home% or %user_data_dir%, which are extended before returning a file handler. Afterwards, when exiting the with-statement, the file is closed. If the passes passed file, however, is a file object, the file is not closed, when exiting the with-statement.
Parameters: - file – File reference that points to a valid filename in the
directory structure of the system, a file object or an
instance of the class
Connector
. - mode –
String, which characters specify the mode in which the file stream is opened. The default mode is text reading mode. Supported characters are:
r: Reading mode (default) w: Writing mode t: Text mode b: Binary mode
Yields: file object in reading or writing mode.
- file – File reference that points to a valid filename in the
directory structure of the system, a file object or an
instance of the class
-
tmpfile
(file: Union[IO[Any], os.PathLike, hup.io.abc.Connector]) → Iterator[pathlib.Path]¶ Create a temporary file for a given file reference.
Parameters: file – File reference that points to a valid filename in the directory structure of the system, a file object or an instance of the class Connector
.Yields: path-like object that points to a temporary file.