OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """\ | 6 """\ |
7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups |
8 of files. | 8 of files. |
9 """ | 9 """ |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 FILES_CACHE = {} | 64 FILES_CACHE = {} |
65 | 65 |
66 # Valid extensions for files we want to lint. | 66 # Valid extensions for files we want to lint. |
67 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" | 67 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" |
68 DEFAULT_LINT_IGNORE_REGEX = r"$^" | 68 DEFAULT_LINT_IGNORE_REGEX = r"$^" |
69 | 69 |
70 def CheckHomeForFile(filename): | 70 def CheckHomeForFile(filename): |
71 """Checks the users home dir for the existence of the given file. Returns | 71 """Checks the users home dir for the existence of the given file. Returns |
72 the path to the file if it's there, or None if it is not. | 72 the path to the file if it's there, or None if it is not. |
73 """ | 73 """ |
74 home_vars = ['HOME'] | 74 full_path = os.path.expanduser(os.path.join('~', filename)) |
75 if sys.platform in ('cygwin', 'win32'): | 75 if os.path.exists(full_path): |
76 home_vars.append('USERPROFILE') | 76 return full_path |
77 for home_var in home_vars: | |
78 home = os.getenv(home_var) | |
79 if home != None: | |
80 full_path = os.path.join(home, filename) | |
81 if os.path.exists(full_path): | |
82 return full_path | |
83 return None | 77 return None |
84 | 78 |
85 | 79 |
86 def UnknownFiles(): | 80 def UnknownFiles(): |
87 """Runs svn status and returns unknown files.""" | 81 """Runs svn status and returns unknown files.""" |
88 return [ | 82 return [ |
89 item[1] for item in SVN.CaptureStatus([], GetRepositoryRoot()) | 83 item[1] for item in SVN.CaptureStatus([], GetRepositoryRoot()) |
90 if item[0][0] == '?' | 84 if item[0][0] == '?' |
91 ] | 85 ] |
92 | 86 |
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 return 1 | 1522 return 1 |
1529 | 1523 |
1530 | 1524 |
1531 if __name__ == "__main__": | 1525 if __name__ == "__main__": |
1532 fix_encoding.fix_encoding() | 1526 fix_encoding.fix_encoding() |
1533 try: | 1527 try: |
1534 sys.exit(main(sys.argv[1:])) | 1528 sys.exit(main(sys.argv[1:])) |
1535 except KeyboardInterrupt: | 1529 except KeyboardInterrupt: |
1536 sys.stderr.write('interrupted\n') | 1530 sys.stderr.write('interrupted\n') |
1537 sys.exit(1) | 1531 sys.exit(1) |
OLD | NEW |