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 61de74a79d - Show all commits

View File

@ -1,6 +1,8 @@
import bpy import bpy
import json import json
from bpy.ops import op_as_string from bpy.ops import op_as_string
from pathlib import Path
class KITSU_OT_test_op(bpy.types.Operator): class KITSU_OT_test_op(bpy.types.Operator):
@ -17,17 +19,30 @@ class KITSU_OT_test_op(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
def get_config():
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
config_file = addon_prefs.convention_config
return Path(config_file).joinpath('convention_checker.json')
class KITSU_OT_convention_checker(bpy.types.Operator): class KITSU_OT_convention_checker(bpy.types.Operator):
bl_idname = "kitsu.convention_checker" bl_idname = "kitsu.convention_checker"
bl_label = 'Convention Checker' bl_label = 'Convention Checker'
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
config_file = get_config()
if not config_file.exists():
cls.poll_message_set(
"Convention Checker config file not found. Check add-on preferences"
)
return config_file.exists()
def execute(self, context): def execute(self, context):
# 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( config_file = get_config()
"ops.py", "test.json" with open(config_file, "r") as f:
) # TODO remove test file and replace with prefs path
with open(json_file, "r") as f:
data = json.load(f) data = json.load(f)
print(data) print(data)