mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
add option to rename representations with regex and filename
This commit is contained in:
parent
afd1fbc40b
commit
38c37d9cf5
1 changed files with 40 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
"""
|
||||
Requires:
|
||||
Nothing
|
||||
|
||||
Provides:
|
||||
Instance
|
||||
"""
|
||||
|
||||
import pyblish.api
|
||||
from pprint import pformat
|
||||
import re
|
||||
import os
|
||||
|
||||
class CollecRepresentationNames(pyblish.api.InstancePlugin):
|
||||
"""
|
||||
Sets the representation names for given families based on RegEx filter
|
||||
"""
|
||||
|
||||
label = "Collect Representaion Names"
|
||||
order = pyblish.api.CollectorOrder
|
||||
families = []
|
||||
hosts = ["standalonepublisher"]
|
||||
name_filter = ""
|
||||
|
||||
def process(self, instance):
|
||||
self.log.debug(f"instance.data: {pformat(instance.data['representations'])}")
|
||||
for repre in instance.data['representations']:
|
||||
self.log.debug(repre['files'])
|
||||
if isinstance(repre['files'], list):
|
||||
shortened_name = os.path.splitext(repre['files'][0])[0]
|
||||
new_repre_name = re.search(self.name_filter, shortened_name)
|
||||
else:
|
||||
new_repre_name = re.search(self.name_filter, repre['files'])
|
||||
|
||||
|
||||
self.log.debug(new_repre_name.group())
|
||||
repre['name'] = new_repre_name.group()
|
||||
repre['outputName'] = new_repre_name.group()
|
||||
|
||||
self.log.debug(f"instance.data: {pformat(instance.data['representations'])}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue