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

Side by Side Diff: third_party/boto/scripts/rebuild_endpoints.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 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 | « third_party/boto/boto/vpc/__init__.py ('k') | third_party/boto/setup.cfg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 from __future__ import print_function
2
3 import json
4 from pyquery import PyQuery as pq
5 import requests
6
7
8 class FetchError(Exception):
9 pass
10
11
12 def fetch_endpoints():
13 # We utilize what the Java SDK publishes as a baseline.
14 resp = requests.get('https://raw2.github.com/aws/aws-sdk-java/master/src/mai n/resources/etc/regions.xml')
15
16 if int(resp.status_code) != 200:
17 raise FetchError("Failed to fetch the endpoints. Got {0}: {1}".format(
18 resp.status,
19 resp.body
20 ))
21
22 return resp.text
23
24 def parse_xml(raw_xml):
25 return pq(raw_xml, parser='xml')
26
27
28 def build_data(doc):
29 data = {}
30
31 # Run through all the regions. These have all the data we need.
32 for region_elem in doc('Regions').find('Region'):
33 region = pq(region_elem, parser='xml')
34 region_name = region.find('Name').text()
35
36 for endp in region.find('Endpoint'):
37 service_name = endp.find('ServiceName').text
38 endpoint = endp.find('Hostname').text
39
40 data.setdefault(service_name, {})
41 data[service_name][region_name] = endpoint
42
43 return data
44
45
46 def main():
47 raw_xml = fetch_endpoints()
48 doc = parse_xml(raw_xml)
49 data = build_data(doc)
50 print(json.dumps(data, indent=4, sort_keys=True))
51
52
53 if __name__ == '__main__':
54 main()
OLDNEW
« no previous file with comments | « third_party/boto/boto/vpc/__init__.py ('k') | third_party/boto/setup.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698