Skip to content

Commit

Permalink
Move open_file_append() outside the if to avoid re-open
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Jul 21, 2020
1 parent ec29076 commit e3ad11a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ def build(dirname, build_readme, include_source, include_readme):
if build_readme:
i = ''.join(filter(str.isdigit, yaml_file.stem))

if include_readme:
with open_file_append(path / readme) as out:
with open_file_append(path / readme) as out:
if include_readme:
with open_file_read(path / f'{yaml_file.stem}.md') as info:
for line in info:
out.write(line.replace('## ', '## {} - '.format(i)))
out.write('\n\n')
else:
with open_file_append(path / readme) as out:
else:
out.write(f'## Example {i}\n')

with open_file_append(path / readme) as out:
if include_source:
with open_file_read(yaml_file) as src:
out.write('```yaml\n')
Expand Down

0 comments on commit e3ad11a

Please sign in to comment.