octoprint.filemanager.util#
AbstractFileWrapper(filename)
#
DiskFileWrapper(filename, path, move = True)
#
Bases: AbstractFileWrapper
An implementation of :class:.AbstractFileWrapper that wraps an actual file on disk. The save implementations
will either copy the file to the new path (preserving file attributes) or -- if move is True (the default) --
move the file.
Parameters:
-
filename
(
str) –The file's name
-
path
(
str) –The file's absolute path
-
move
(
boolean) –Whether to move the file upon saving (True, default) or copying.
LineProcessorStream(input_stream)
#
While reading from this stream the provided input_stream is read line by line, calling the (overridable) method
:meth:.process_line for each read line.
Sub classes can thus modify the contents of the input_stream in line, while it is being read. Keep in mind that
process_line will receive the line as a byte stream - if underlying code needs to operate on unicode you'll need
to do the decoding yourself.
Parameters:
process_line(line)
#
Called from the read Method of this stream with each line read from self.input_stream.
By returning None the line will not be returned from the read stream, effectively being stripped from the
wrapper input_stream.
Parameters:
-
line
(
bytes) –The line as read from
self.input_streamin byte representation
Returns:
-
–
bytes or None: The processed version of the line (might also be multiple lines), or None if the line is to be stripped from the processed stream.
MultiStream(*streams)
#
StreamWrapper(filename, *streams)
#
Bases: AbstractFileWrapper
A wrapper allowing processing of one or more consecutive streams.
Parameters:
-
*streams
–
One or more
class:
io.IOBasestreams to process one after another to save to storage.
save(path, permissions = None)
#
Will dump the contents of all streams provided during construction into the target file, in the order they were provided.
stream()
#
If more than one stream was provided to the constructor, will return a :class:.MultiStream wrapping all
provided streams in the order they were provided, else the first and only stream is returned directly.