Compare commits

...

4 Commits

Author SHA1 Message Date
c873214fcc restore 2025-12-03 17:19:22 +01:00
483c35d1bf comment 2025-12-03 16:58:25 +01:00
880dc72057 fix imports 2025-12-03 16:53:18 +01:00
e26cc4f09f temp save 2025-12-01 17:26:08 +01:00
7 changed files with 67 additions and 57 deletions

View File

@ -1,3 +1,19 @@
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 = { bl_info = {
"name": "Custom Shelf", "name": "Custom Shelf",
"author": "Christophe Seux", "author": "Christophe Seux",
@ -12,25 +28,6 @@ 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 = [ bl_classes = [
properties.AdditionnalShelves, properties.AdditionnalShelves,
properties.CustomShelfProps, properties.CustomShelfProps,
@ -46,17 +43,18 @@ bl_classes = [
] ]
def draw_menu(self, context): def draw_menu(self, context: bpy.types.Context):
self.layout.menu("CSHELF_MT_text_editor") self.layout.menu("CSHELF_MT_text_editor")
def register(): def register():
for bl_class in bl_classes: for bl_class in bl_classes:
print(f"register {bl_class}")
bpy.utils.register_class(bl_class) bpy.utils.register_class(bl_class)
bpy.types.Scene.CustomShelf = bpy.props.PointerProperty(type=CustomShelfSettings) bpy.types.Scene.CustomShelf = bpy.props.PointerProperty(type=properties.CustomShelfSettings)
bpy.types.WindowManager.CustomShelf = bpy.props.PointerProperty( bpy.types.WindowManager.CustomShelf = bpy.props.PointerProperty(
type=CustomShelfProps type=properties.CustomShelfProps
) )
bpy.types.TEXT_MT_editor_menus.append(draw_menu) bpy.types.TEXT_MT_editor_menus.append(draw_menu)
@ -79,7 +77,7 @@ def register():
def unregister(): def unregister():
# unregister panel : # unregister panel :
for panel in CustomShelfSettings.panel_list: for panel in properties.CustomShelfSettings.panel_list:
try: try:
bpy.utils.unregister_class(panel) bpy.utils.unregister_class(panel)
except Exception: except Exception:

View File

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

View File

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

View File

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

View File

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

View File

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

15
uv.lock generated
View File

@ -60,12 +60,25 @@ source = { virtual = "." }
[package.dev-dependencies] [package.dev-dependencies]
dev = [ dev = [
{ name = "black" }, { name = "black" },
{ name = "fake-bpy-module" },
] ]
[package.metadata] [package.metadata]
[package.metadata.requires-dev] [package.metadata.requires-dev]
dev = [{ name = "black", specifier = ">=25.11.0" }] 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" },
]
[[package]] [[package]]
name = "mypy-extensions" name = "mypy-extensions"