List files with lucidity templates.
Project description
Lucidity Files
Lucidity Files is a project for listing files and folders using the popular Lucidity templating module.
Made this for another project called Lucidity Browser (Aka Browser) that handles files listing and contextual actions across many folders and templates. This was tested with good results in the production Bad Dinos at Able & Baker studios. Since the focus was on the Browser part, this end up not being a great thing, but it works.
Have not tested this in Mac or Linux, although I plan to do it.
Badges
Installation
Install module with pip
python -m pip install lucidity_files
You can also target a folder like this (a pip thing, not anything i did)
python -m pip install --target=P:\my\path lucidity_files
Usage/Examples
import os
import lucidity_files
# create 'asset' file template -------
# define roots for files (useful for different os or the farm)
roots = {'root': 'C:'}
# define a relative path from the root
pattern = '{root:[\w_.\-:]+}/{project}/{entitytype}/{entity}/{step}/{task}/{entity}_{step}_{task}_{name}_v{version}.{ext}'
lf_template = lucidity_files.TemplateFile.create('assets', pattern, roots=roots)
# lets create a file to be listed
path = r"C:\test\asset\car\mod\hi\car_mod_hi_default_v001.txt"
# we could also use the template to do this!
input_data = {'entity': 'car', 'entitytype': 'asset', 'ext': 'txt', 'name': 'default',
'project': 'test', 'root': 'C:', 'step': 'mod', 'task': 'hi', 'version': '001'}
path2 = lf_template.format(input_data)
print(path == path2)
# will print True
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, 'w'):
pass
# list all assets in project 'test'
paths_found = lf_template.getPaths({'project': 'test'})
# now get each path's data
for path in paths_found:
data = lf_template.parse(path)
print(path)
print('\t', data)
# # will print something like
# C:\test\asset\car\mod\hi\car_mod_hi_default_v001.txt
# {'entity': 'car', 'entitytype': 'asset', 'ext': 'txt', 'name': 'default',
# 'project': 'test', 'root': 'C:', 'step': 'mod', 'task': 'hi', 'version': '001'}
# lets get a partial template to the entity folder
partial_template = lf_template.getPartialTemplateFile('entity')
# list all entity folders. Will use the strict check to make sure that what get listed
# is parsable with the same template (some other folders might match the glob but
# not the specifics of the template, and we want to avoid those)
paths_found = partial_template.getPaths({'project': 'test'}, strict_check=True)
# now get each path's data
for path in paths_found:
print(path)
data = partial_template.parse(path)
print('\t', data)
# # will print something like
# C:\test\asset\car
# {'entity': 'car', 'entitytype': 'asset', 'project': 'test', 'root': 'C:'}
# ...
Documentation
Documentation on Read The Docs
Environment Variables
To run this project, you can add the following environment variables to your .env file
LUCIDITY_TEMPLATE_PATH
Where you store files defining your lucidity templates.
Acknowledgements
- Thanks to Jordi Amposta, Angel Galindo and Marco Sancho for the patience while testing this in production!
- This depends on the Lucidity Project, please check it out!
Authors
License
Used By
This project is used by the following companies:
Roadmap
-
Make module pip installable -> Done!
-
Test on Linux (Ubuntu) -> Done!
Support
For questions, email eduardo@eduardograna.com.
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
Built Distribution
File details
Details for the file lucidity_files-0.1.2.tar.gz
.
File metadata
- Download URL: lucidity_files-0.1.2.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f83b2ed1ac6f392a313beb3a9cc39106a5317e92e0586dd7157da5ae1a99b5b |
|
MD5 | 0f88f50ca51b72a0b81036ee5e53fd22 |
|
BLAKE2b-256 | ea86bf1cf8d92f94fac05d3e7c1b7806116e4356a8741dbfa4d159606c6c7d2a |
File details
Details for the file lucidity_files-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: lucidity_files-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4c4baeb1f640b67d3d8e2a51a77e7f25dbe68eb78dbeeffdcce97ec34ddc651 |
|
MD5 | 2a5615869e0ba5ee925d6868f970afee |
|
BLAKE2b-256 | 190826023a3a0da6c2dbdde4fcb64525801a0c78ea326580822db7d61724be6e |