Created
September 28, 2023 12:20
-
-
Save BigRoy/3c482fe6cb8a1f974b8e7af313d063f3 to your computer and use it in GitHub Desktop.
OpenPype / AYON debug loader to list all context data as json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from openpype.pipeline import load | |
from openpype.style import load_stylesheet | |
class ShowContextData(load.LoaderPlugin): | |
"""Debug context data of representation""" | |
families = ["*"] | |
representations = ["*"] | |
label = "Show Context Data" | |
order = 9999 | |
icon = "bug" | |
color = "gray" | |
def load(self, context, name, namespace, data): | |
from qtpy import QtWidgets | |
json_str = json.dumps(context, | |
default=str, | |
indent=4, | |
sort_keys=True) | |
# Log it | |
self.log.info(json_str) | |
# Copy to clipboard | |
clipboard = QtWidgets.QApplication.clipboard() | |
assert clipboard, "Must have running QApplication instance" | |
clipboard.setText(json_str) | |
# Show in UI | |
global edit | |
edit = QtWidgets.QPlainTextEdit() | |
edit.setWindowTitle( | |
"Context data for: " | |
"{0[asset][name]} > " | |
"v{0[version][name]:03d} > " | |
"{0[representation][name]}".format(context) | |
) | |
edit.insertPlainText(json_str) | |
edit.resize(800, 500) | |
edit.setStyleSheet(load_stylesheet()) | |
edit.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage in loader
Originally provided this as an example on Ynput Community's #development discord channel.