Skip to content

Commit

Permalink
Indent include directives during printing
Browse files Browse the repository at this point in the history
  • Loading branch information
sayerhs committed Jan 23, 2024
1 parent d3b3e11 commit 86837b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions caelus/io/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ def __init__(self, directive, value):
#: Value of the directive (e.g., file to be included)
self.value = value

def write_value(self, fh=sys.stdout, indent_str=''):
def write_value(self, fh=sys.stdout, indent_str='', nested=False):
"""Write out the dimensional value"""
fh.write("\n%s %s\n" % (self.directive, self.value))
if not nested:
fh.write("\n%s %s\n" % (self.directive, self.value))
else:
fh.write("%s%s %s\n" % (indent_str, self.directive, self.value))

def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self.directive[1:])
Expand All @@ -170,9 +173,12 @@ def __init__(self, directive, value):
self.directive = directive
self.value = value

def write_value(self, fh=sys.stdout, indent_str=''):
def write_value(self, fh=sys.stdout, indent_str='', nested=False):
"""Write out the dimensional value"""
fh.write("%s %s;\n" % (self.directive, self.value))
if not nested:
fh.write("%s %s;\n" % (self.directive, self.value))
else:
fh.write("%s%s %s;\n" % (indent_str, self.directive, self.value))


class EvalDirective(FoamType):
Expand Down
2 changes: 1 addition & 1 deletion caelus/io/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def write_dict_item(self, key, value, nested=False):
buf = self.buf
indenter = self.indenter
if isinstance(value, self.no_keywd_values):
value.write_value(buf, indenter.indent_str)
value.write_value(buf, indenter.indent_str, nested)
elif isinstance(value, dtypes.BoundaryList):
buf.write("%d" % len(value.value))
self.write_list(value.value)
Expand Down

0 comments on commit 86837b4

Please sign in to comment.