paunch-dir
An algorithm to generate a path from file name which directory structure could store mass files
You could generated directory structure (from a uuid file name) just like:
├── 02 │ └── 9d │ └── 5b │ └── cb7c89776a923d6050ff9cffcf1333284f.jpg | # Original file name : 029d5bcb7c89776a923d6050ff9cffcf1333284f.jpg ├── 03 │ ├── 2b │ │ └── f9 │ │ └── 7cdb028c51ec56ec53cbe34946525a3e37.jpg │ └── f9 │ └── 4d │ └── 9458a9ee5396911268b0da6b3552f154e8.jpg ...
It’s ineffectively for file system parse large number files in same directory. And there have limit files that could be sotre in a directory depends on different file system format. You will see it’s very slow if you open a directory with hundreds of thousands files in file browser. Separate them into different directory with specific algorithm that could greatly improve efficiency when parse those files.
Usage
from paunchdir import PaunchDir
# Generate path from uuid file name
pdir = PaunchDir(".")
print(pdir.compose('032bf97cdb028c51ec56ec53cbe34946525a3e37.jpg'))
# ==> "./03/2b/f9/7cdb028c51ec56ec53cbe34946525a3e37.jpg"
# Decompose uuid file name from a path
print(pdir.decompose("./03/2b/f9/7cdb028c51ec56ec53cbe34946525a3e37.jpg"))
# ==> "032bf97cdb028c51ec56ec53cbe34946525a3e37.jpg"
# Generate path from uuid file name with one level (Just like what the git
# store it's objects)
pdir = PaunchDir("./objects", levels=1)
print(pdir.compose('032bf97cdb028c51ec56ec53cbe34946525a3e37'))
# ==> "./03/2bf97cdb028c51ec56ec53cbe34946525a3e37"
License
This library license under Apache-2.0
Credits
This package was created with Cookiecutter and the PyPackageTemplate project template.
History
0.0.2 (2018-06-21)
First release on PyPI.
Metadata
Release files for paunch-dir 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| paunch-dir-0.0.4.zip | 15.1 kB | Details |
Release files / paunch-dir-0.0.4.zip
| Download URL | paunch-dir-0.0.4.zip |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae35436cd536b5d5d3fbcf0eb32933a8e68bcbf02b132f9a5c31b5861f8ac88a
|
|
BLAKE2b-256 checksum How to use checksums |
b6027e4a09da074b5efece686bd9b23e5bf70d7384adf78ba6e26eaaa8def6c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |