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/cmd2.py | |
parent | d4c807555208426b6a4dca224c8ad066185c6e09 (diff) | |
download | cmd2-git-1148a1227d98e7b461783a009013ba3829eb8f9b.tar.gz |
Made macro argument patterns class members of MacroArg
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index e9957c62..75accb7f 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -48,8 +48,7 @@ from . import utils from . import plugin from .argparse_completer import AutoCompleter, ACArgumentParser, ACTION_ARG_CHOICES from .clipboard import can_clip, get_paste_buffer, write_to_paste_buffer -from .parsing import StatementParser, Statement, Macro, MacroArg, \ - macro_normal_arg_pattern, macro_escaped_arg_pattern, digit_pattern +from .parsing import StatementParser, Statement, Macro, MacroArg # Set up readline from .rl_utils import rl_type, RlType, rl_get_point, rl_set_prompt, vt100_support, rl_make_safe_prompt @@ -2409,7 +2408,7 @@ class Cmd(cmd.Cmd): # Find all normal arguments arg_list = [] - normal_matches = re.finditer(macro_normal_arg_pattern, value) + normal_matches = re.finditer(MacroArg.macro_normal_arg_pattern, value) max_arg_num = 0 num_set = set() @@ -2418,7 +2417,7 @@ class Cmd(cmd.Cmd): cur_match = normal_matches.__next__() # Get the number between the braces - cur_num = int(re.findall(digit_pattern, cur_match.group())[0]) + cur_num = int(re.findall(MacroArg.digit_pattern, cur_match.group())[0]) if cur_num < 1: self.perror("Argument numbers must be greater than 0", traceback_war=False) return @@ -2439,14 +2438,14 @@ class Cmd(cmd.Cmd): return # Find all escaped arguments - escaped_matches = re.finditer(macro_escaped_arg_pattern, value) + escaped_matches = re.finditer(MacroArg.macro_escaped_arg_pattern, value) while True: try: cur_match = escaped_matches.__next__() # Get the number between the braces - cur_num = int(re.findall(digit_pattern, cur_match.group())[0]) + cur_num = int(re.findall(MacroArg.digit_pattern, cur_match.group())[0]) arg_list.append(MacroArg(start_index=cur_match.start(), number=cur_num, is_escaped=True)) except StopIteration: |