mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-15 18:16:57 +02:00
[core] desc/attribute: Add brackets option for GroupAttribute
Add brackets option for GroupAttribute command line value. Brackets is a two chars string. The GroupAttribute command line value is encapsulated between the two chars. (e.g. '[]')
This commit is contained in:
parent
d7e3003aa5
commit
5a62157cdd
2 changed files with 14 additions and 2 deletions
|
@ -581,9 +581,19 @@ class GroupAttribute(Attribute):
|
||||||
return {name: attr.getPrimitiveValue(exportDefault=exportDefault) for name, attr in self._value.items() if not attr.isDefault}
|
return {name: attr.getPrimitiveValue(exportDefault=exportDefault) for name, attr in self._value.items() if not attr.isDefault}
|
||||||
|
|
||||||
def getValueStr(self):
|
def getValueStr(self):
|
||||||
|
# add brackets if requested
|
||||||
|
strBegin = ''
|
||||||
|
strEnd = ''
|
||||||
|
if self.attributeDesc.brackets is not None:
|
||||||
|
if len(self.attributeDesc.brackets) == 2:
|
||||||
|
strBegin = self.attributeDesc.brackets[0]
|
||||||
|
strEnd = self.attributeDesc.brackets[1]
|
||||||
|
else:
|
||||||
|
raise AttributeError("Incorrect brackets on GroupAttribute: {}".format(self.attributeDesc.brackets))
|
||||||
|
|
||||||
# sort values based on child attributes group description order
|
# sort values based on child attributes group description order
|
||||||
sortedSubValues = [self._value.get(attr.name).getValueStr() for attr in self.attributeDesc.groupDesc]
|
sortedSubValues = [self._value.get(attr.name).getValueStr() for attr in self.attributeDesc.groupDesc]
|
||||||
return self.attributeDesc.joinChar.join(sortedSubValues)
|
return strBegin + self.attributeDesc.joinChar.join(sortedSubValues) + strEnd
|
||||||
|
|
||||||
def updateInternals(self):
|
def updateInternals(self):
|
||||||
super(GroupAttribute, self).updateInternals()
|
super(GroupAttribute, self).updateInternals()
|
||||||
|
|
|
@ -112,12 +112,13 @@ class ListAttribute(Attribute):
|
||||||
|
|
||||||
class GroupAttribute(Attribute):
|
class GroupAttribute(Attribute):
|
||||||
""" A macro Attribute composed of several Attributes """
|
""" A macro Attribute composed of several Attributes """
|
||||||
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' '):
|
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' ', brackets=None):
|
||||||
"""
|
"""
|
||||||
:param groupDesc: the description of the Attributes composing this group
|
:param groupDesc: the description of the Attributes composing this group
|
||||||
"""
|
"""
|
||||||
self._groupDesc = groupDesc
|
self._groupDesc = groupDesc
|
||||||
self._joinChar = joinChar
|
self._joinChar = joinChar
|
||||||
|
self._brackets = brackets
|
||||||
super(GroupAttribute, self).__init__(name=name, label=label, description=description, value={}, uid=(), group=group, advanced=advanced, semantic=semantic, enabled=enabled)
|
super(GroupAttribute, self).__init__(name=name, label=label, description=description, value={}, uid=(), group=group, advanced=advanced, semantic=semantic, enabled=enabled)
|
||||||
|
|
||||||
groupDesc = Property(Variant, lambda self: self._groupDesc, constant=True)
|
groupDesc = Property(Variant, lambda self: self._groupDesc, constant=True)
|
||||||
|
@ -198,6 +199,7 @@ class GroupAttribute(Attribute):
|
||||||
|
|
||||||
uid = Property(Variant, retrieveChildrenUids, constant=True)
|
uid = Property(Variant, retrieveChildrenUids, constant=True)
|
||||||
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
||||||
|
brackets = Property(str, lambda self: self._brackets, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class Param(Attribute):
|
class Param(Attribute):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue