minidir: Minimal directory interface and implementation
The minimal interface for directories and files and two implementations: in-memory and real file system versions.
It's a good choice when we want to separate file-access side effects from pure functional part of our code base.
Installation
Already published on Pypi
pip install minidir
Usage
- Interface:
Directory->Path,FileDirectoryis the container where we accessFilebyPath
- Implementation
SystemDirectory: aDirectorybacked by real file system.FakeDirectory: aDirectoryonly exists in-memory.
Some error like NameCollision and NotFound will be raised in corresponding situations.
Example:
import minidir
class SomeClass:
folder: minidir.Directory
def __init__(self, folder: minidir.Directory) -> None:
# inject directory to separate side effect from core logic
pass
def main():
# use actual file system during production
instance = SomeClass(minidir.SystemDirectory("/path/to/root"))
def test_some_class():
# use in-memory implementation during test
instance = SomeClass(minidir.FakeDirectory())
Future Work
- Implementations for network-oriented storage, e.g. WebDAV, S3, Dropbox ...
- Stream based file read / write interface.
Metadata
Release files for minidir 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| minidir-0.1.3.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| minidir-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / minidir-0.1.3.tar.gz
| Download URL | minidir-0.1.3.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
072fb532bdca0d9a85dac111eac74cb8657d74de65a79f023ce0fbcfc3496e8a
|
|
BLAKE2b-256 checksum How to use checksums |
a73810f2ccedbd8cc9b5d7f8f8366944472da640e55f8bccb10eeae39879e324
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / minidir-0.1.3-py3-none-any.whl
| Download URL | minidir-0.1.3-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
558f64b1967f4a674039491b4f719e7f400d0c541026dd156f0d6ea4602c4c20
|
|
BLAKE2b-256 checksum How to use checksums |
c757a5244323c0208e7437ef05093e7a3acc7cbce0747d6ff72ccd9bbd7ec6af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|