Compare commits

..

No commits in common. "blender-five" and "master" have entirely different histories.

7 changed files with 57 additions and 67 deletions

View File

@ -1,19 +1,3 @@
import os
import bpy
from . import operators, properties, ui, functions
from .functions import read_shelves
if "bpy" in locals():
import importlib
_ = importlib.reload(operators)
# _ = importlib.reload(panels)
_ = importlib.reload(functions)
_ = importlib.reload(properties)
bl_info = {
"name": "Custom Shelf",
"author": "Christophe Seux",
@ -28,6 +12,25 @@ bl_info = {
}
if "bpy" in locals():
import importlib
importlib.reload(operators)
importlib.reload(panels)
importlib.reload(functions)
importlib.reload(properties)
from .utils import report
from .functions import read_shelves
from . import operators
from . import properties
from . import ui
from .properties import CustomShelfSettings, CustomShelfProps
import bpy
import os
bl_classes = [
properties.AdditionnalShelves,
properties.CustomShelfProps,
@ -43,18 +46,17 @@ bl_classes = [
]
def draw_menu(self, context: bpy.types.Context):
def draw_menu(self, context):
self.layout.menu("CSHELF_MT_text_editor")
def register():
for bl_class in bl_classes:
print(f"register {bl_class}")
bpy.utils.register_class(bl_class)
bpy.types.Scene.CustomShelf = bpy.props.PointerProperty(type=properties.CustomShelfSettings)
bpy.types.Scene.CustomShelf = bpy.props.PointerProperty(type=CustomShelfSettings)
bpy.types.WindowManager.CustomShelf = bpy.props.PointerProperty(
type=properties.CustomShelfProps
type=CustomShelfProps
)
bpy.types.TEXT_MT_editor_menus.append(draw_menu)
@ -77,7 +79,7 @@ def register():
def unregister():
# unregister panel :
for panel in properties.CustomShelfSettings.panel_list:
for panel in CustomShelfSettings.panel_list:
try:
bpy.utils.unregister_class(panel)
except Exception:

View File

@ -1,11 +1,8 @@
from os import scandir
from posixpath import splitext
from .utils import *
from bpy.props import *
from bpy.types import Panel, Operator
from .properties import CustomShelfSettings, CustomShelfPrefs
from .Types import *
from os.path import join, dirname, exists
SHELF_DIR = join(dirname(__file__), "shelves")
@ -215,7 +212,7 @@ def read_shelves():
tag_filter_items.sort()
tag_filter_items.insert(0, "__clear__")
# prefs["tag_filter_items"] = tag_filter_items
prefs["tag_filter_items"] = tag_filter_items
# bpy.utils.unregister_class(CustomShelfPrefs)
# bpy.utils.register_class(CustomShelfPrefs)

View File

@ -1,8 +1,7 @@
from .utils import *
from .functions import *
from bpy.types import AddonPreferences, Operator, PropertyGroup
from bpy.types import Operator
from bpy.props import *
from bpy.props import CollectionProperty
from .properties import CustomShelfSettings
@ -268,6 +267,7 @@ class CSHELF_OT_add_script(Operator):
folder_row.prop(bl_props, "category_enum", expand=True)
else:
folder_row.prop(self, "new_category", text="")
folder_row.prop(self, "add_category", icon="ADD", text="")

View File

@ -1,6 +1,5 @@
from .utils import *
from bpy.props import *
from os.path import join, dirname
class CustomShelfSettings(bpy.types.PropertyGroup):

View File

@ -9,5 +9,4 @@ dependencies = []
[dependency-groups]
dev = [
"black>=25.11.0",
"fake-bpy-module>=20251003",
]

View File

@ -1,19 +1,12 @@
from pathlib import Path
from typing import Any
import bpy
import os
from os import listdir, mkdir, scandir
from os.path import join, dirname, splitext, isdir, exists, basename
from bpy.types import Operator, Panel, PropertyGroup
from bpy.props import *
import subprocess
import json
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
PointerProperty,
StringProperty,
)
id_type = {
"Action": "actions",
@ -53,34 +46,47 @@ id_type = {
}
def read_json(path: Path):
def report(var, message, type="INFO"):
print([a for a in locals()])
print([a for a in globals()])
if "self" in var:
var["self"].report({type}, message)
else:
print("")
print(type)
print(message)
def read_json(path):
jsonFile = path
if os.path.exists(jsonFile):
try:
with open(jsonFile) as data_file:
return json.load(data_file)
except Exception:
except:
print("the file %s not json readable" % jsonFile)
return
def search_filter(search: str, str: str):
def search_filter(search, str):
return search.lower() in str.lower()
def title(string: str):
def title(string):
return string.replace("_", " ").replace("-", " ").title()
def arg_name(string: str):
def arg_name(string):
return string.replace(" ", "_").replace("-", "_").lower().strip("_")
def open_folder(path: Path):
def open_folder(path):
try:
os.startfile(path)
except Exception:
_ = subprocess.Popen(["xdg-open", path])
except:
subprocess.Popen(["xdg-open", path])
def dic_to_args(dic):
@ -135,7 +141,7 @@ def dic_to_args(dic):
return args
def read_info(script_path: Path):
def read_info(script_path):
import collections
if isinstance(script_path, list):
@ -145,13 +151,13 @@ def read_info(script_path: Path):
lines = f.read().splitlines()
info = {}
for i, line in enumerate(lines):
for i, l in enumerate(lines):
if i >= 10:
return info, lines
if line.startswith("info"):
if l.startswith("info"):
info_start = i
info_str = line
info_str = l
while (
info_str.endswith(",")
@ -196,7 +202,7 @@ def read_info(script_path: Path):
return info, lines
def dic_to_str(dic: dict[str, Any], keys: list[str] | None = None, spaces: int = 4): # pyright: ignore[reportExplicitAny]
def dic_to_str(dic, keys=None, spaces=4):
if not keys:
keys = sorted(dic)

15
uv.lock generated
View File

@ -60,25 +60,12 @@ source = { virtual = "." }
[package.dev-dependencies]
dev = [
{ name = "black" },
{ name = "fake-bpy-module" },
]
[package.metadata]
[package.metadata.requires-dev]
dev = [
{ name = "black", specifier = ">=25.11.0" },
{ name = "fake-bpy-module", specifier = ">=20251003" },
]
[[package]]
name = "fake-bpy-module"
version = "20251003"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/3a/d7/8e34a795715d18497a257929ace8776a94d6c2c744e36b61e75567cbda64/fake_bpy_module-20251003.tar.gz", hash = "sha256:43d7fd082efc34497e238de3ad4d31fb850f2d1a8bb07418ae36eae56c1c7434", size = 973644, upload-time = "2025-10-03T06:19:57.638Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c6/24/d318f51ae1ebe953038984ed26fa0f9cd5466ef83da30c317282645695ec/fake_bpy_module-20251003-py3-none-any.whl", hash = "sha256:424f75fee6f300fc6d8e0d39abb28dbccd8777f611afa47ecdb9a03c00f2f43f", size = 1103011, upload-time = "2025-10-03T06:19:55.524Z" },
]
dev = [{ name = "black", specifier = ">=25.11.0" }]
[[package]]
name = "mypy-extensions"