Skip to content

Commit

Permalink
refactor: Rename variable in parser to sub_pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
junghoon-vans committed Nov 28, 2022
1 parent df9dba8 commit 75c6fb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/utils/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def parser() -> Generator[Parser, None, None]:
yield parser


def test_parse_variables(parser: Parser):
assert parser.variables == {
def test_parse_sub_pairs(parser: Parser):
assert parser.sub_pairs == {
'varst': 'variable to reStructuredText',
'version': '0.2.0',
'release': 'v0.2.0',
Expand Down
2 changes: 1 addition & 1 deletion varst/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ def run(self, argv: Optional[Sequence[str]]) -> None:

rst_file = RstFile(src=self.parser.input_file)
substitution = Substitution(rst_file)
for k, v in self.parser.variables.items():
for k, v in self.parser.sub_pairs.items():
substitution.update(k, v)
rst_file.save(dest=self.parser.output_file)
4 changes: 2 additions & 2 deletions varst/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Parser:

input_file: str = ""
output_file: str = ""
variables: Dict[str, str] = {}
sub_pairs: Dict[str, str] = {}

def __init__(self) -> None:
self._parser.add_argument(
Expand Down Expand Up @@ -53,7 +53,7 @@ def parse(self, argv: Optional[Sequence[str]]) -> None:
self.input_file = self.output_file = arg_dict['input']
if arg_dict['output'] is not None:
self.output_file = arg_dict['output']
self.variables = _parse_kv(arg_dict['name=value'])
self.sub_pairs = _parse_kv(arg_dict['name=value'])


_VARIABLE_PATTERN = re.compile(r"[^=]+=[^=]+")
Expand Down

0 comments on commit 75c6fb5

Please sign in to comment.