diff options
author | steven.bethard <devnull@localhost> | 2010-01-07 17:30:28 +0000 |
---|---|---|
committer | steven.bethard <devnull@localhost> | 2010-01-07 17:30:28 +0000 |
commit | 6f0470065b4aa7c8673ba375b4d99b8809999fb5 (patch) | |
tree | d45ab818ba62dcc8239546401304537d1f70c5ab /argparse.py | |
parent | 595bce353fc65c44168df31a9cd3e29b9059b486 (diff) | |
download | argparse-6f0470065b4aa7c8673ba375b4d99b8809999fb5.tar.gz |
Add convert_arg_line_to_args to allow subclasses to easily override file parsing behavior.
Diffstat (limited to 'argparse.py')
-rw-r--r-- | argparse.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/argparse.py b/argparse.py index 8b96e62..95fdd72 100644 --- a/argparse.py +++ b/argparse.py @@ -1971,7 +1971,10 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): try: args_file = open(arg_string[1:]) try: - arg_strings = args_file.read().splitlines() + arg_strings = [] + for arg_line in args_file.read().splitlines(): + for arg in self.convert_arg_line_to_args(arg_line): + arg_strings.append(arg) arg_strings = self._read_args_from_files(arg_strings) new_arg_strings.extend(arg_strings) finally: @@ -1983,6 +1986,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # return the modified argument list return new_arg_strings + def convert_arg_line_to_args(self, arg_line): + return [arg_line] + def _match_argument(self, action, arg_strings_pattern): # match the pattern for this action to the arg strings nargs_pattern = self._get_nargs_pattern(action) |