diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 10:53:11 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 10:53:11 -0400 |
commit | 1148a1227d98e7b461783a009013ba3829eb8f9b (patch) | |
tree | efd31eebe0dade5b01ad30f78b41134a1ec5cf2b /cmd2/parsing.py | |
parent | d4c807555208426b6a4dca224c8ad066185c6e09 (diff) | |
download | cmd2-git-1148a1227d98e7b461783a009013ba3829eb8f9b.tar.gz |
Made macro argument patterns class members of MacroArg
Diffstat (limited to 'cmd2/parsing.py')
-rw-r--r-- | cmd2/parsing.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 498834cf..696904ff 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -12,17 +12,6 @@ import attr from . import constants from . import utils -# Pattern used to find normal argument -# Match strings like: {5}, {{{{{4}, {2}}}}} -macro_normal_arg_pattern = re.compile(r'(?<!\{)\{\d+\}|\{\d+\}(?!\})') - -# Pattern used to find escaped arguments (2 or more braces on each side of digit) -# Match strings like: {{5}}, {{{{{4}}, {{2}}}}}, {{{4}}} -macro_escaped_arg_pattern = re.compile(r'\{{2}\d+\}{2}') - -# Finds a string of digits -digit_pattern = re.compile(r'\d+') - @attr.s(frozen=True) class MacroArg: @@ -40,6 +29,17 @@ class MacroArg: # Tells if this argument is escaped and therefore needs to be unescaped is_escaped = attr.ib(validator=attr.validators.instance_of(bool), type=bool) + # Pattern used to find normal argument + # Match strings like: {5}, {{{{{4}, {2}}}}} + macro_normal_arg_pattern = re.compile(r'(?<!\{)\{\d+\}|\{\d+\}(?!\})') + + # Pattern used to find escaped arguments (2 or more braces on each side of digit) + # Match strings like: {{5}}, {{{{{4}}, {{2}}}}}, {{{4}}} + macro_escaped_arg_pattern = re.compile(r'\{{2}\d+\}{2}') + + # Finds a string of digits + digit_pattern = re.compile(r'\d+') + @attr.s(frozen=True) class Macro: |