Python method to resolve tokens

Hello. Is there a method that can resolve tokens from a selected node … in my case a writenode.
batch hooks will give you info[‘resolvedPath’], but I need to resolve the tokens without rendering anything. I’d initially like to select the write node and be able to print the
media_path + media_path_pattern . thanks

Hey Miles

This is what I use in one of my scripts to convert some of the available tokens in the write node. Hope it helps.

    for write_node in selection:
        media_path = str(write_node.media_path)[1:-1]
        print 'media path:', media_path
        openclip_path = str(write_node.create_clip_path)[1:-1]
        project = str(
        batch_iteration = str(
        batch_name = str([1:-1]
        ext = str(write_node.format_extension)[1:-1]
        name = str([1:-1]
        shot_name = str(write_node.shot_name)[1:-1]

        token_dict = {'<project>': project,
                      '<batch iteration>': batch_iteration,
                      '<batch name>': batch_name,
                      '<ext>': ext,
                      '<name>': name,
                      '<shot name>':shot_name,
                      '<version name>': batch_iteration}

        for token, value in token_dict.items():
            openclip_path = openclip_path.replace(token, value)
        openclip_path = os.path.join(media_path, openclip_path) + '.clip'

Mike V!. Thanks I was doin this for other methods, but the one i’m creating now needs, like the colour space , and couple others you cant puzzle with the data the node has. For now I’m creating a tmp “directory file” per write node, that has all the info that the batch_hooks have. It works, but I feel a little dirty. Happy Sunday mate.