WIP: Blender Kitsu: Convention Checker #124

Closed
Nick Alberelli wants to merge 8 commits from (deleted):feature/convention-checker-draft into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit efec4a089b - Show all commits

View File

@ -1,11 +1,13 @@
import bpy import bpy
import json
from bpy.ops import op_as_string
class KITSU_OT_test_op(bpy.types.Operator): class KITSU_OT_test_op(bpy.types.Operator):
bl_idname = "kitsu.test_op" bl_idname = "kitsu.test_op"
bl_label = 'test' bl_label = 'test'
text: bpy.props.StringProperty(name='test', default='') text: bpy.props.StringProperty(name='test', default='test')
def execute(self, context): def execute(self, context):
if self.text != "test": if self.text != "test":
@ -20,16 +22,31 @@ class KITSU_OT_convention_checker(bpy.types.Operator):
bl_label = 'Convention Checker' bl_label = 'Convention Checker'
def execute(self, context): def execute(self, context):
# TODO read types out of json File
# TODO check operator exists before execution # TODO check operator exists before execution
# INFO python3 -m json.tool file.json to 'pretty print' json # INFO python3 -m json.tool file.json to 'pretty print' json
json_file = __file__.replace(
"ops.py", "test.json"
) # TODO remove test file and replace with prefs path
with open(json_file, "r") as f:
data = json.load(f)
print(data)
check_ops = []
for item in data:
if item == 'anim':
for op in data[item]:
# TODO Test if op is unavaliable
check_ops.append(op)
for op in check_ops:
try: try:
bpy.ops.kitsu.test_op() exec(op)
except RuntimeError as ex: except RuntimeError as ex:
ex args = ex.args[0].split(':')
self.report({'INFO'}, "CONFIRMED FAILURE") self.report({args[0].upper()}, f"{op}:{args[1]}")
else: else:
self.report({'INFO'}, "CONFIRMED SUCCESS") self.report({'INFO'}, f"{op}: SUCCESS")
return {'FINISHED'} return {'FINISHED'}