| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import errno | 7 import errno |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import Queue | 10 import Queue |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 cmd = 'env ' + cmd | 725 cmd = 'env ' + cmd |
| 726 try: | 726 try: |
| 727 # shell=True to allow the shell to handle all forms of quotes in | 727 # shell=True to allow the shell to handle all forms of quotes in |
| 728 # $EDITOR. | 728 # $EDITOR. |
| 729 subprocess2.check_call(cmd, shell=True) | 729 subprocess2.check_call(cmd, shell=True) |
| 730 except subprocess2.CalledProcessError: | 730 except subprocess2.CalledProcessError: |
| 731 return None | 731 return None |
| 732 return FileRead(filename) | 732 return FileRead(filename) |
| 733 finally: | 733 finally: |
| 734 os.remove(filename) | 734 os.remove(filename) |
| 735 |
| 736 |
| 737 def ParseCodereviewSettingsContent(content): |
| 738 """Process a codereview.settings file properly.""" |
| 739 lines = (l for l in content.splitlines() if not l.strip().startswith("#")) |
| 740 try: |
| 741 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) |
| 742 except ValueError: |
| 743 raise Error( |
| 744 'Failed to process settings, please fix. Content:\n\n%s' % content) |
| 745 # TODO(maruel): Post-process |
| 746 return keyvals |
| OLD | NEW |