Package: lucidity-files
Lucidity FilesLucidity 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 atAble & 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.BadgesInstallationInstall module with pippython-mpipinstalllucidity_filesYou can also target a folder like this (a pip thing, not anything i did)python-mpipinstall--target=P:\my\pathlucidity_filesUsage/Examplesimportosimportlucidity_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 rootpattern='{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 listedpath=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 Trueos.makedirs(os.path.dirname(path),exist_ok=True)withopen(path,'w'):pass# list all assets in project 'test'paths_found=lf_template.getPaths({'project':'test'})# now get each path's dataforpathinpaths_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 folderpartial_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 dataforpathinpaths_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:'}# ...DocumentationDocumentation on Read The DocsEnvironment VariablesTo run this project, you can add the following environment variables to your .env fileLUCIDITY_TEMPLATE_PATHWhere you store files defining your lucidity templates.AcknowledgementsThanks to Jordi Amposta, Angel Galindo and Marco Sancho for the patience while testing this in production!This depends on theLucidity Project, please check it out!AuthorseduardogranaLicenseMITUsed ByThis project is used by the following companies:Able & Baker studiosRoadmapMake module pip installable :)Test on LinuxSupportFor questions, emaileduardo@eduardograna.com.