shotgunsoftware / tk-core

The Flow Production Tracking Pipeline Toolkit Core API
https://developer.shotgridsoftware.com/tk-core/
Other
91 stars 116 forks source link

get_fields from template string is impossible with / #960

Open francoisgfx opened 9 months ago

francoisgfx commented 9 months ago

Hello,

Getting fields from a template string is impossible if it contains some "/".

For example if you look at the config here : https://github.com/ue4plugins/tk-config-unrealbasic/blob/0686e53d9d26027507fc45f03d6e7935a9512a4f/env/includes/unreal/templates.yml#L104

The reason is because get_fields, calls TemplatePathParser, which does a os.path.normpath().

so on Windows a string like /Game/Level/ is going to be converted to \\Game\\Level\\

Is there another way to extract fields from a string ?

Cheers

F.

francoisgfx commented 9 months ago

the issue I see is that TemplatePath are normpath() when doing the split_path(). But TemplateString are not calling the split_path() which seems correct. But get_fields will always try to normpath the input. So if a string contains / it will always fail.

An idea would be to add an arg as get_fields(normpath=True) by default and force it to False when called from TempalteString