blob: f8c1d3049d6d965fd27bc16a73f0c9dcbb7a8d6b [file] [log] [blame]
Joe Gregorio6d5e94f2010-08-25 23:49:30 -04001# Copyright (C) 2010 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Generate a skeleton discovery extras document.
16
17For the given API, retrieve the discovery document,
18strip out the guts of each method description
19and put :
20"""
21
22__author__ = 'jcgregorio@google.com (Joe Gregorio)'
23
24import os
25import os.path
26import simplejson
27import sys
28
29def main():
30 for filename in sys.argv[1:]:
31 f = file(filename, "r")
32 dis = simplejson.load(f)
33 f.close()
34
35 data = dis['data']
36 api = data[data.keys()[0]]
37 version = api[api.keys()[0]]
38 resources = version['resources']
39 for res_name, res_desc in resources.iteritems():
40 methods = res_desc['methods']
41 for method_name, method_desc in methods.iteritems():
42 methods[method_name] = {}
43 path, basename = os.path.split(filename)
44 newfilename = os.path.join(path, "skel-" + basename)
45 f = file(newfilename, "w")
46 simplejson.dump(dis, f, sort_keys=True, indent=2 * ' ')
47 f.close()
48
49
50if __name__ == '__main__':
51 main()
52