A module for managing filesystem structure using templates.
Project description
NamedPath
This is a module which can help you to configure folder structure with named patterns.
No more absolute paths in scripts, no more hard coding.
With namedpath
you can generate paths via names with variables context!
import namedpath
# create list of patterns with inheritance
path_list = dict(
PROJECT='{PROJECT_NAME}',
SHOTS='[PROJECT]/shots',
SHOT='[SHOTS]/{SHOT_NAME}',
LAYOUT='[SHOT]/layout',
LAYOUT_PUBLISH='[LAYOUT]/publish/{SHOT_NAME|lower()}_v{VERSION:04d}/{SHOT_NAME|lower()}.exr',
RENDER='[SHOT]/render',
RENDER_PUBLISH='[RENDER]/{VERSION:04d}/{FILE_NAME}_{FRAME}.{EXT}',
)
# create tree instance
tree = namedpath.NamedPathTree('/mnt/my_projects', path_list)
# define context
context = {
'project_name': 'project1',
'shot_name': 'sh01',
'file_name': 'test_render',
'version': 15,
'ext': 'exr',
'frame': '%04d'
}
# now you can generate the path
print(tree.get_path('RENDER_PUBLISH', context))
# /mnt/my_projects/project1/shots/sh01/render/0015/test_render_%04d.exr
# you can change any patterns and no need change the code after that
path_list['RENDER_PUBLISH'] = '[RENDER]/publish/v{VERSION:05d}/{SHOT_NAME}_rnd_{FRAME}.{EXT}'
tree = namedpath.NamedPathTree('/mnt/my_projects', path_list)
print(tree.get_path('RENDER_PUBLISH', context))
# /home/username/my_projects/project1/shots/sh01/render/publish/v00015/sh01_rnd_%04d.exr
-
Any pattern can be inherited from other pattern
-
Each structure can have a different pattern set, but it will work with the same code
-
Support generic string formatting and string methods call
-
Creating folder structure with context or partial context
# formatting
pat1 = '[PARENT]/{VARIABLE:04d}'
# string methods
pat2 = '[PARENT]/{VARIABLE|strip()|upper()}'
# string methods with arguments
pat3 = '[PARENT]/{VARIABLE|center(10, "_")}'
Project still underdeveloped
TODO:
- set permissions and owner
- transfer tool
Alternatives
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
namedpath-0.1.0.tar.gz
(12.2 kB
view hashes)
Built Distribution
namedpath-0.1.0-py3-none-any.whl
(12.1 kB
view hashes)
Close
Hashes for namedpath-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be0f5fc98a25ccbf19a726f020c98f8af0d6d7e7d631c5abb41b4d6cb4b9e429 |
|
MD5 | e5495d14ec8cf685183c9a0cba85ad6f |
|
BLAKE2b-256 | 3220bde6ab0f1aa16a5056d5b130d5574d73c5889dc33fb0dff59112ead907fd |