diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 00:42:39 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 00:42:39 +0000 |
commit | caceeb5c89b485c70ae11217d7f9786b0f51a769 (patch) | |
tree | 995f0bceabd67959f73b7e45b703c04681700b49 | |
parent | 2fb592d25aa2b4d6fd251f4416dcac75c4e1e7f2 (diff) | |
download | chromium_src-caceeb5c89b485c70ae11217d7f9786b0f51a769.zip chromium_src-caceeb5c89b485c70ae11217d7f9786b0f51a769.tar.gz chromium_src-caceeb5c89b485c70ae11217d7f9786b0f51a769.tar.bz2 |
Prepend "strace_" to process_quoted_argument to make it clear it's strace-specific.
Do not put it inside Strace.Context.Process class because it's really long and
would make the code harder to read.
Remove the extraneous local variable, it is not necessary.
R=cmp@chromium.org
NOTRY=true
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10779037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147148 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | tools/isolate/trace_inputs.py | 27 | ||||
-rwxr-xr-x | tools/isolate/trace_inputs_test.py | 3 |
2 files changed, 15 insertions, 15 deletions
diff --git a/tools/isolate/trace_inputs.py b/tools/isolate/trace_inputs.py index fa92351..184d22c 100755 --- a/tools/isolate/trace_inputs.py +++ b/tools/isolate/trace_inputs.py @@ -429,7 +429,7 @@ def fix_python_path(cmd): return out -def process_quoted_arguments(text): +def strace_process_quoted_arguments(text): """Extracts quoted arguments on a string and return the arguments as a list. Implemented as an automaton. Supports incomplete strings in the form @@ -453,19 +453,18 @@ def process_quoted_arguments(text): ) = range(8) state = NEED_QUOTE - current_argument = '' out = [] for index, char in enumerate(text): if char == '"': if state == NEED_QUOTE: state = INSIDE_STRING + # A new argument was found. + out.append('') elif state == INSIDE_STRING: # The argument is now closed. - out.append(current_argument) - current_argument = '' state = NEED_COMMA_OR_DOT elif state == ESCAPED: - current_argument += char + out[-1] += char state = INSIDE_STRING else: raise ValueError( @@ -476,9 +475,9 @@ def process_quoted_arguments(text): if state in (NEED_COMMA_OR_DOT, NEED_COMMA): state = NEED_SPACE elif state == INSIDE_STRING: - current_argument += char + out[-1] += char elif state == ESCAPED: - current_argument += char + out[-1] += char state = INSIDE_STRING else: raise ValueError( @@ -489,9 +488,9 @@ def process_quoted_arguments(text): if state == NEED_SPACE: state = NEED_QUOTE elif state == INSIDE_STRING: - current_argument += char + out[-1] += char elif state == ESCAPED: - current_argument += char + out[-1] += char state = INSIDE_STRING else: raise ValueError( @@ -508,9 +507,9 @@ def process_quoted_arguments(text): elif state == NEED_DOT_3: state = NEED_COMMA elif state == INSIDE_STRING: - current_argument += char + out[-1] += char elif state == ESCAPED: - current_argument += char + out[-1] += char state = INSIDE_STRING else: raise ValueError( @@ -519,7 +518,7 @@ def process_quoted_arguments(text): text) elif char == '\\': if state == ESCAPED: - current_argument += char + out[-1] += char state = INSIDE_STRING elif state == INSIDE_STRING: state = ESCAPED @@ -530,7 +529,7 @@ def process_quoted_arguments(text): text) else: if state == INSIDE_STRING: - current_argument += char + out[-1] += char else: raise ValueError( 'Can\'t process char at column %d for: %r' % (index, text), @@ -1249,7 +1248,7 @@ class Strace(ApiBase): filepath = args[0] self._handle_file(filepath, False) self.executable = self.RelativePath(self.get_cwd(), filepath) - self.command = process_quoted_arguments(args[1]) + self.command = strace_process_quoted_arguments(args[1]) def handle_exit_group(self, _args, _result): """Removes cwd.""" diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py index d9c8c15..a73c96f 100755 --- a/tools/isolate/trace_inputs_test.py +++ b/tools/isolate/trace_inputs_test.py @@ -36,7 +36,8 @@ class TraceInputs(unittest.TestCase): ), ) for actual, expected in test_cases: - self.assertEquals(expected, trace_inputs.process_quoted_arguments(actual)) + self.assertEquals( + expected, trace_inputs.strace_process_quoted_arguments(actual)) def test_process_escaped_arguments(self): test_cases = ( |