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

Side by Side Diff: presubmit_support.py

Issue 8508017: Standardize the sys.path fix up and fix a few pylint warnings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Previous patchset was broken Created 9 years, 1 month 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') | pylintrc » ('j') | 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 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.6.1' 9 __version__ = '1.6.1'
10 10
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 tested. 655 tested.
656 656
657 Instance members: 657 Instance members:
658 tags: Dictionnary of KEY=VALUE pairs found in the change description. 658 tags: Dictionnary of KEY=VALUE pairs found in the change description.
659 self.KEY: equivalent to tags['KEY'] 659 self.KEY: equivalent to tags['KEY']
660 """ 660 """
661 661
662 _AFFECTED_FILES = AffectedFile 662 _AFFECTED_FILES = AffectedFile
663 663
664 # Matches key/value (or "tag") lines in changelist descriptions. 664 # Matches key/value (or "tag") lines in changelist descriptions.
665 _TAG_LINE_RE = re.compile( 665 TAG_LINE_RE = re.compile(
666 '^\s*(?P<key>[A-Z][A-Z_0-9]*)\s*=\s*(?P<value>.*?)\s*$') 666 '^\s*(?P<key>[A-Z][A-Z_0-9]*)\s*=\s*(?P<value>.*?)\s*$')
667 scm = '' 667 scm = ''
668 668
669 def __init__( 669 def __init__(
670 self, name, description, local_root, files, issue, patchset, author): 670 self, name, description, local_root, files, issue, patchset, author):
671 if files is None: 671 if files is None:
672 files = [] 672 files = []
673 self._name = name 673 self._name = name
674 self._full_description = description 674 self._full_description = description
675 # Convert root into an absolute path. 675 # Convert root into an absolute path.
676 self._local_root = os.path.abspath(local_root) 676 self._local_root = os.path.abspath(local_root)
677 self.issue = issue 677 self.issue = issue
678 self.patchset = patchset 678 self.patchset = patchset
679 self.author_email = author 679 self.author_email = author
680 680
681 # From the description text, build up a dictionary of key/value pairs 681 # From the description text, build up a dictionary of key/value pairs
682 # plus the description minus all key/value or "tag" lines. 682 # plus the description minus all key/value or "tag" lines.
683 description_without_tags = [] 683 description_without_tags = []
684 self.tags = {} 684 self.tags = {}
685 for line in self._full_description.splitlines(): 685 for line in self._full_description.splitlines():
686 m = self._TAG_LINE_RE.match(line) 686 m = self.TAG_LINE_RE.match(line)
687 if m: 687 if m:
688 self.tags[m.group('key')] = m.group('value') 688 self.tags[m.group('key')] = m.group('value')
689 else: 689 else:
690 description_without_tags.append(line) 690 description_without_tags.append(line)
691 691
692 # Change back to text and remove whitespace at end. 692 # Change back to text and remove whitespace at end.
693 self._description_without_tags = ( 693 self._description_without_tags = (
694 '\n'.join(description_without_tags).rstrip()) 694 '\n'.join(description_without_tags).rstrip())
695 695
696 assert all( 696 assert all(
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 except PresubmitFailure, e: 1258 except PresubmitFailure, e:
1259 print >> sys.stderr, e 1259 print >> sys.stderr, e
1260 print >> sys.stderr, 'Maybe your depot_tools is out of date?' 1260 print >> sys.stderr, 'Maybe your depot_tools is out of date?'
1261 print >> sys.stderr, 'If all fails, contact maruel@' 1261 print >> sys.stderr, 'If all fails, contact maruel@'
1262 return 2 1262 return 2
1263 1263
1264 1264
1265 if __name__ == '__main__': 1265 if __name__ == '__main__':
1266 fix_encoding.fix_encoding() 1266 fix_encoding.fix_encoding()
1267 sys.exit(Main(None)) 1267 sys.exit(Main(None))
OLDNEW
« no previous file with comments | « gcl.py ('k') | pylintrc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698