Cross-platform file handling utilities.
Project description
File Handling
Cross-platform file handling utilities.
Hierarchy
filehandling
|---- path
| |---- temp_dir
| |---- abs_cwd
| |---- abs_dir
| '---- join_path
'---- file
|---- read
|---- write
'---- Writer
Example
python
from filehandling import *
# absolute current working directory
print(abs_cwd(), flush=True)
# specify an inspect stack depth
print(abs_cwd(depth=2), flush=True)
# absolute directory of somefile
print(abs_dir("somefile"), flush=True)
# join path and normalize it
print(join_path(abs_cwd(), "..", "somefile"), flush=True)
# temporary directory of a bundled python application
print(temp_dir(), flush=True)
# read file content with automatic encoding detection
print(read("somefile"), flush=True)
# specify an encoding
print(read("somefile", "ascii"), flush=True)
# write content to file with attempts to use file queue
write("somefile", "ab", "test\n") # fallback to open()
write("somefile", "wb", b"test\n") # fallback to open()
# Writer file queue
writer = Writer(server=True)
ss = SS(functions=dict(write=lambda args: writer.fileq.put(args)))
ss_thread = threading.Thread(target=ss.start)
ss_thread.daemon = True
ss_thread.start()
# direct dispatch with a tuple
writer.fileq.put(("somefile", "ab", "test\n"))
# use file queue
write("somefile", "wb", b"test\n")
shell
rem filehandling.exe <function name> [argument] ...
filehandling.exe abs_cwd
filehandling.exe abs_cwd 2
filehandling.exe abs_dir somefile
filehandling.exe join_path C:\test .. somefile
filehandling.exe write file_path wb test1234
filehandling.exe write file_path ab test1234
rem the followings will fail to execute
filehandling.exe temp_dir
filehandling.exe read file_path
filehandling.exe read file_path ascii
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
omnitools-0.0.1.tar.gz
(2.9 kB
view hashes)
Built Distribution
omnitools-0.0.1-py3-none-any.whl
(15.6 kB
view hashes)
Close
Hashes for omnitools-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f317c2f753e681d4f2f3abb60725f0c7eb229915530eace9abc27ec2f043b3e9 |
|
MD5 | 0257840a1b132d59cc07ead2c071114f |
|
BLAKE2b-256 | 33bfbe2707838190555e3cb425092fe86efc09e8b113b65ec94e29ed928a96f7 |