An algorithm to generate a path from file name which directory structure could store mass files
Project description
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.
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
File details
Details for the file paunch-dir-0.0.4.zip
.
File metadata
- Download URL: paunch-dir-0.0.4.zip
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae35436cd536b5d5d3fbcf0eb32933a8e68bcbf02b132f9a5c31b5861f8ac88a |
|
MD5 | a07ac2398555e3f3d189a2bbdefe1fc8 |
|
BLAKE2b-256 | b6027e4a09da074b5efece686bd9b23e5bf70d7384adf78ba6e26eaaa8def6c9 |