Skip to content

Refactor expander.py #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class Expander:

include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP')

def is_ignored_line(self, line) -> bool:
if self.include_guard.match(line):
return True
if line.strip() == "#pragma once":
return True
if line.strip().startswith('//'):
return True
return False

def __init__(self, lib_paths: List[Path]):
self.lib_paths = lib_paths

Expand Down Expand Up @@ -45,14 +54,16 @@ def expand_acl(self, acl_name: str) -> List[str]:

result = [] # type: List[str]
for line in acl_source.splitlines():
if self.include_guard.match(line):
if self.is_ignored_line(line):
continue

m = self.atcoder_include.match(line)
if m:
result.extend(self.expand_acl(m.group(1)))
continue

result.append(line)

return result

def expand(self, source: str) -> str:
Expand Down