Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created September 28, 2023 12:20
Show Gist options
  • Save BigRoy/3c482fe6cb8a1f974b8e7af313d063f3 to your computer and use it in GitHub Desktop.
Save BigRoy/3c482fe6cb8a1f974b8e7af313d063f3 to your computer and use it in GitHub Desktop.
OpenPype / AYON debug loader to list all context data as json
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()
@BigRoy
Copy link
Author

BigRoy commented Sep 28, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment