Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Retrieve default descr from bone's name in its Skeleton #1227

Merged
merged 7 commits into from
Aug 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/viur/core/bones/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __init__(
*,
compute: Compute = None,
defaultValue: t.Any = None,
descr: str = "",
descr: t.Optional[str] = None,
getEmptyValueFunc: callable = None,
indexed: bool = True,
isEmptyFunc: callable = None, # fixme: Rename this, see below.
Expand All @@ -228,7 +228,7 @@ def __init__(
self.isClonedInstance = getSystemInitialized()

# Standard definitions
self.descr = descr
self._descr = descr
self.params = params or {}
self.multiple = multiple
self.required = required
Expand Down Expand Up @@ -319,6 +319,18 @@ def __init__(

self.compute = compute

@property
def descr(self):
if self._descr:
return self._descr

if self.skel_cls:
for name, bone in self.skel_cls.__boneMap__.items():
if bone is self:
return name
phorward marked this conversation as resolved.
Show resolved Hide resolved

return ""

def __set_name__(self, owner: "Skeleton", name: str) -> None:
self.skel_cls = owner
self.name = name
Expand Down
Loading