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

Side by Side Diff: google_apis/google_api_keys.py

Issue 10939005: Remove API keys from source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated module path comment. Created 8 years, 3 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 | remoting/webapp/build-webapp.py » ('j') | remoting/webapp/build-webapp.py » ('J')
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) 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 """Python API for retrieving API keys. 6 """Python API for retrieving API keys.
7 7
8 Note that this cannot have the exact same semantics (at the moment) as 8 Note that this cannot have the exact same semantics (at the moment) as
9 the C++ API in google_api_keys.h, since it does not have access to gyp 9 the C++ API in google_api_keys.h, since it does not have access to gyp
10 variables or preprocessor defines. 10 variables or preprocessor defines.
11 11
12 TODO(joi): Give this have the same semantics as the C++ API. 12 TODO(joi): Give this have the same semantics as the C++ API.
13 """ 13 """
14 14
15 import os 15 import os
16 import re 16 import re
17 import sys 17 import sys
18 18
19 19
20 # The token returned when an API key is unset. 20 # The token returned when an API key is unset.
21 DUMMY_TOKEN = 'dummytoken' 21 DUMMY_TOKEN = 'dummytoken'
22 22
23 23
24 def _GetTokenFromOfficialFile(token_name): 24 def _GetTokenFromOfficialFile(token_name):
25 """Parses the token from the official file if it exists, else returns None.""" 25 """Parses the token from the official file if it exists, else returns None."""
26 official_path = os.path.join(sys.path[0], 26 official_path = os.path.join(os.path.dirname(__file__),
Jói 2012/09/18 09:31:40 Thanks, my bad, sys.path[0] is only guaranteed to
27 'internal/google_chrome_api_keys.h') 27 'internal/google_chrome_api_keys.h')
28 if not os.path.isfile(official_path): 28 if not os.path.isfile(official_path):
29 return None 29 return None
30 30
31 line_regexp = '^#define\s*%s\s*"([^"]+)"' % token_name 31 line_regexp = '^#define\s*%s\s*"([^"]+)"' % token_name
32 line_pattern = re.compile(line_regexp) 32 line_pattern = re.compile(line_regexp)
33 def ParseLine(current_line): 33 def ParseLine(current_line):
34 result = line_pattern.match(current_line) 34 result = line_pattern.match(current_line)
35 if result: 35 if result:
36 return result.group(1) 36 return result.group(1)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 84
85 if __name__ == "__main__": 85 if __name__ == "__main__":
86 print 'GOOGLE_API_KEY=%s' % GetAPIKey() 86 print 'GOOGLE_API_KEY=%s' % GetAPIKey()
87 print 'GOOGLE_CLIENT_ID_MAIN=%s' % GetClientID('MAIN') 87 print 'GOOGLE_CLIENT_ID_MAIN=%s' % GetClientID('MAIN')
88 print 'GOOGLE_CLIENT_SECRET_MAIN=%s' % GetClientSecret('MAIN') 88 print 'GOOGLE_CLIENT_SECRET_MAIN=%s' % GetClientSecret('MAIN')
89 print 'GOOGLE_CLIENT_ID_CLOUD_PRINT=%s' % GetClientID('CLOUD_PRINT') 89 print 'GOOGLE_CLIENT_ID_CLOUD_PRINT=%s' % GetClientID('CLOUD_PRINT')
90 print 'GOOGLE_CLIENT_SECRET_CLOUD_PRINT=%s' % GetClientSecret('CLOUD_PRINT') 90 print 'GOOGLE_CLIENT_SECRET_CLOUD_PRINT=%s' % GetClientSecret('CLOUD_PRINT')
91 print 'GOOGLE_CLIENT_ID_REMOTING=%s' % GetClientID('REMOTING') 91 print 'GOOGLE_CLIENT_ID_REMOTING=%s' % GetClientID('REMOTING')
92 print 'GOOGLE_CLIENT_SECRET_REMOTING=%s' % GetClientSecret('REMOTING') 92 print 'GOOGLE_CLIENT_SECRET_REMOTING=%s' % GetClientSecret('REMOTING')
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/build-webapp.py » ('j') | remoting/webapp/build-webapp.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698