WIP: Blender Kitsu: Convention Checker #124
@ -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
|
||||||
try:
|
json_file = __file__.replace(
|
||||||
bpy.ops.kitsu.test_op()
|
"ops.py", "test.json"
|
||||||
except RuntimeError as ex:
|
) # TODO remove test file and replace with prefs path
|
||||||
ex
|
with open(json_file, "r") as f:
|
||||||
self.report({'INFO'}, "CONFIRMED FAILURE")
|
data = json.load(f)
|
||||||
else:
|
print(data)
|
||||||
self.report({'INFO'}, "CONFIRMED SUCCESS")
|
|
||||||
|
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:
|
||||||
|
exec(op)
|
||||||
|
except RuntimeError as ex:
|
||||||
|
args = ex.args[0].split(':')
|
||||||
|
self.report({args[0].upper()}, f"{op}:{args[1]}")
|
||||||
|
else:
|
||||||
|
self.report({'INFO'}, f"{op}: SUCCESS")
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user