Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: tools/isolate/trace_inputs.py

Issue 10703140: Redundant docstrings are redundant. Reduce redundancy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Traces an executable and its child processes and extract the files accessed 7 """Traces an executable and its child processes and extract the files accessed
8 by them. 8 by them.
9 9
10 The implementation uses OS-specific API. The native Kernel logger and the ETL 10 The implementation uses OS-specific API. The native Kernel logger and the ETL
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1574
1575 Example: 1575 Example:
1576 With text = '\\001python2.7\\001-c\\001print(\\"hi\\")\\0', the 1576 With text = '\\001python2.7\\001-c\\001print(\\"hi\\")\\0', the
1577 function will return ['python2.7', '-c', 'print("hi")] 1577 function will return ['python2.7', '-c', 'print("hi")]
1578 """ 1578 """
1579 if not text.endswith('\\0'): 1579 if not text.endswith('\\0'):
1580 raise ValueError('String is not null terminated: %r' % text, text) 1580 raise ValueError('String is not null terminated: %r' % text, text)
1581 text = text[:-2] 1581 text = text[:-2]
1582 1582
1583 def unescape(x): 1583 def unescape(x):
1584 """Replaces '\\' with '\' and '\?' (where ? is anything) with ?. 1584 """Replaces '\\' with '\' and '\?' (where ? is anything) with ?."""
1585
1586 Implemented as an automaton.
1587 """
1588 out = [] 1585 out = []
1589 escaped = False 1586 escaped = False
1590 for i in x: 1587 for i in x:
1591 if i == '\\' and not escaped: 1588 if i == '\\' and not escaped:
1592 escaped = True 1589 escaped = True
1593 continue 1590 continue
1594 escaped = False 1591 escaped = False
1595 out.append(i) 1592 out.append(i)
1596 return ''.join(out) 1593 return ''.join(out)
1597 1594
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3076 return command(argv[1:]) 3073 return command(argv[1:])
3077 except TracingFailure, e: 3074 except TracingFailure, e:
3078 sys.stderr.write('\nError: ') 3075 sys.stderr.write('\nError: ')
3079 sys.stderr.write(str(e)) 3076 sys.stderr.write(str(e))
3080 sys.stderr.write('\n') 3077 sys.stderr.write('\n')
3081 return 1 3078 return 1
3082 3079
3083 3080
3084 if __name__ == '__main__': 3081 if __name__ == '__main__':
3085 sys.exit(main(sys.argv[1:])) 3082 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698