Add casual string representation of named settings and predicates.
Use 'group.setting' format for named predicates, only display the expression for anonymous predicates.
This commit is contained in:
@@ -35,6 +35,9 @@ class Setting(object):
|
|||||||
self.byte_offset = None
|
self.byte_offset = None
|
||||||
self.group = SettingGroup.append(self)
|
self.group = SettingGroup.append(self)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return '{}.{}'.format(self.group.name, self.name)
|
||||||
|
|
||||||
def predicate_context(self):
|
def predicate_context(self):
|
||||||
"""
|
"""
|
||||||
Return the context where this setting can be evaluated as a (leaf)
|
Return the context where this setting can be evaluated as a (leaf)
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ class Predicate(object):
|
|||||||
assert self.context, "Incompatible predicate parts"
|
assert self.context, "Incompatible predicate parts"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = '{}({})'.format(
|
|
||||||
type(self).__name__,
|
|
||||||
' ,'.join(map(str, self.parts)))
|
|
||||||
if self.name:
|
if self.name:
|
||||||
s = '{}={}'.format(self.name, s)
|
return '{}.{}'.format(self.context.name, self.name)
|
||||||
return s
|
else:
|
||||||
|
return '{}({})'.format(
|
||||||
|
type(self).__name__,
|
||||||
|
', '.join(map(str, self.parts)))
|
||||||
|
|
||||||
def predicate_context(self):
|
def predicate_context(self):
|
||||||
return self.context
|
return self.context
|
||||||
|
|||||||
Reference in New Issue
Block a user