Package: resolva
resolvaSimple and fast path template resolver.Inspired by and derived from Lucidity.What is resolva ?resolvais a python library that extracts data from a string by matching configurated patterns."/mnt/prods/hamlet/shots/sq010"=>"/mnt/prods/{prod}/shots/{seq}"=>{"prod": "hamlet", "seq": "sq010"}Typical usage:for a path or string input,loops through a series of configured patterns,once a matching pattern found,extracts data and returns a dictionaryInstead of bare regex, the pattern uses a simpler "format" style syntax.resolvacan also format the data back to a string.Path resolvingTemplate based path resolving is a typical need in CG pipeline tools.Examples include:Shotgrid Toolkit (SGTK)- Leading commercial CG and VFX Project Management and pipeline toolkitCGWire's kitsu file trees- Kitsu is an Open Source collaboration platform for Animation and VFX studios.Lucidity- Inspired by SGTK templating, in turn inspiration and base ofresolvaspil- Usesresolvaat its coreUsage ExampleConfiguration:fromresolvaimportResolvertemplate={"maya_file":"/mnt/prods/{prod}/shots/{seq}/{shot}_{version:(v\d\d\d)}.{ext:(ma|mb)}","hou_file":"/mnt/prods/{prod}/shots/{seq}/{shot}_{version:(v\d\d\d)}.{ext:(hip|hipnc)}"}Resolver("id",template)# create the Resolver in an instance cacheUsage:fromresolvaimportResolverr=Resolver.get("id")# read the Resolver from the instance cacheinput="/mnt/prods/hamlet/shots/sq010/sh010_v012.ma"label,data=r.resolve_first(input)# result:print(f'Detected type "{label}" and extracted "{data}"')Output:Detected type "maya_file" and extracted 
{"prod": "hamlet", "seq": "sq010", "shot": "sh010", "version": "v012", "ext": "ma"}Featuressimple template formatExample:/{shot}/{version}/{name}.{extension:(ma|mb)}handles duplicate placeholdersvery simple APIresolve with one, first, or all patternsformat with one, first, or all patternsformat including reverse resolve checkhigh speed using cachesinstance cache (keep regex compilations in memory)lru_caches (speed up immutable resolves)Why not Lucidity ?resolvais a simplified version ofLucidity, a filesystem templating library.resolvais now used at the core ofspil.A large amount of strings and paths need to be resolved at high speed.The end goal is to build a rust path template resolver.Rust development not started yet - contributions are highly welcomed :)To prepare this in python, we reduced the Lucidity library to its essence (around 100 lines of code).On top of these essential features, we built a simple Resolver class with an instance cache (to keep regex compiles in memory), and a lru cache, to memoize resolves that have no reason to change.The result is a fast and very simple toolset.resolvakeeps essential Lucidity's features:simple template formathandles duplicate placeholderspattern anchoring (start:^,end:$)resolvalacks some Lucidity features, that were left out:individual template APInested data structurestemplate discoverytemplates referencing templatespython 2 supportIf you need one of these, go for the original :)Installationresolvaworks in Python >=3.7.It is available on pypi and can be installed usingpip install resolva,or from githubpip install git+https://github.com/MichaelHaussmann/resolva.gitresolvais open source, License: MIT.TODO:docstrings (+doctests)pytests calling the existing testsUsage documentation, dev documentation + API documentation (readthedocs or github?)black, refurb, etc.pip installable and python bound rust implementationAcknowledgementsresolvais inspired by, and derived fromLucidity.Lucidityhttps://gitlab.com/4degrees/lucidity/https://lucidity.readthedocs.iocopyright: Copyright (c) 2013 Martin Pengelly-Phillipslicence: Apache License, Version 2.0resolvahttps://github.com/MichaelHaussmann/resolva(c) 2024 Michael Haussmannlicence: MIT