WIP: Blender Kitsu: Convention Checker #124
@ -1,11 +1,13 @@
|
||||
import bpy
|
||||
import json
|
||||
from bpy.ops import op_as_string
|
||||
|
||||
|
||||
class KITSU_OT_test_op(bpy.types.Operator):
|
||||
bl_idname = "kitsu.test_op"
|
||||
bl_label = 'test'
|
||||
|
||||
text: bpy.props.StringProperty(name='test', default='')
|
||||
text: bpy.props.StringProperty(name='test', default='test')
|
||||
|
||||
def execute(self, context):
|
||||
if self.text != "test":
|
||||
@ -20,16 +22,31 @@ class KITSU_OT_convention_checker(bpy.types.Operator):
|
||||
bl_label = 'Convention Checker'
|
||||
|
||||
def execute(self, context):
|
||||
# TODO read types out of json File
|
||||
# TODO check operator exists before execution
|
||||
# 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:
|
||||
bpy.ops.kitsu.test_op()
|
||||
exec(op)
|
||||
except RuntimeError as ex:
|
||||
ex
|
||||
self.report({'INFO'}, "CONFIRMED FAILURE")
|
||||
args = ex.args[0].split(':')
|
||||
self.report({args[0].upper()}, f"{op}:{args[1]}")
|
||||
else:
|
||||
self.report({'INFO'}, "CONFIRMED SUCCESS")
|
||||
self.report({'INFO'}, f"{op}: SUCCESS")
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user