prompy.promio package¶
prompy.promio.csvio module¶
prompy.promio.fileio module¶
Promise creators to deal with files.
Read, write, delete, compress, decompress, walk.
Example: |
---|
from prompy.threadio.tpromise import TPromise
from prompy.promio import fileio
filename = 'myfile'
f = fileio.write_file(filename, 'content', prom_type=TPromise)
f.then(lambda _: fileio.read_file(filename).then(lambda data: print(data)))
-
prompy.promio.fileio.
compress_directory
(directory, destination, archive_format='zip', root_dir='.', prom_type=prompy.promise.Promise, **kwargs)[source]¶ Parameters: Return type: Promise
[~PromiseReturnType]Returns:
-
prompy.promio.fileio.
decompress
(filename, destination, archive_format='zip', prom_type=prompy.promise.Promise, **kwargs)[source]¶ Parameters: Return type: Promise
[~PromiseReturnType]Returns:
-
prompy.promio.fileio.
delete_file
(file, prom_type=prompy.promise.Promise, **kwargs)[source]¶ Return type: Promise
[~PromiseReturnType]
-
prompy.promio.fileio.
read_file
(file, mode='r', prom_type=prompy.promise.Promise, **kwargs)[source]¶ Read a file in a promise.
Parameters: - file (
str
) – to open - mode – open mode (‘r’, ‘rb’)
- prom_type – Type of the promise to instantiate.
- kwargs – kwargs of the promise initializer.
Return type: Promise
[~PromiseReturnType]Returns: Promise that will resolve with the content of the file.
- file (
-
prompy.promio.fileio.
walk
(directory, filter_directories=None, filter_filename=None, on_found=None, prom_type=prompy.promise.Promise, **kwargs)[source]¶ Resolve a list of paths that were walked.
Parameters: - directory (
str
) – path to walk. - on_found – called for each path that was found.
- filter_directories (
Optional
[str
]) – a regex filter to exclude directories. - filter_filename (
Optional
[str
]) – a regex filter to exclude filenames. - prom_type – Type of the promise to instantiate.
- kwargs – kwargs of the promise initializer.
Return type: Promise
[]Returns: - directory (
prompy.promio.jsonio module¶
Json related promise creators.
-
prompy.promio.jsonio.
dumps
(data, prom_type=prompy.promise.Promise, **kwargs)[source]¶ Resolve the dumped data.
Parameters: Return type: Promise
[~PromiseReturnType]Returns:
-
prompy.promio.jsonio.
loads
(data, prom_type=prompy.promise.Promise, **kwargs)[source]¶ Resolve the loaded data from a string.
Parameters: - data (
str
) – - prom_type –
- kwargs –
Return type: Promise
[~PromiseReturnType]Returns: - data (