Skip to content

Commit

Permalink
ignore empty line and comment line (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Nakamur-a authored Jan 27, 2023
1 parent 3ab7e86 commit 29a8e6d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/scripts/create-parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def write_mappings(mappings, output_path):
with open(output_path, 'w') as fp:
fp.write(json.dumps(mappings))

def is_mapping_line(line: str) -> bool:
is_empty_line = (line.strip() == "")
is_comment_line = (line.strip().startswith("#"))
return not (is_comment_line or is_empty_line)

def create_parameters(output_path, head, base, mapping):
checkout(base) # Checkout base revision to make sure it is available for comparison
checkout(head) # return to head commit
Expand All @@ -81,12 +86,12 @@ def create_parameters(output_path, head, base, mapping):
if os.path.exists(mapping):
with open(mapping) as f:
mappings = [
m.split() for m in f.read().splitlines()
m.split() for m in f.read().splitlines() if is_mapping_line(m)
]
else:
mappings = [
m.split() for m in
mapping.splitlines()
mapping.splitlines() if is_mapping_line(m)
]
mappings = filter(partial(check_mapping, changes), mappings)
mappings = map(convert_mapping, mappings)
Expand Down

0 comments on commit 29a8e6d

Please sign in to comment.