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

Side by Side Diff: gclient_utils.py

Issue 9214002: Dedupe codereview.settings parsing code. Add more testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 11 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 | « gcl.py ('k') | git_cl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « gcl.py ('k') | git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698