blob: 3e5a55382c3bdcf5ac901535027b022e3257f35d [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
Joe Gregorio6d5e94f2010-08-25 23:49:30 -040026import sys
27
Joe Gregoriob843fa22010-12-13 16:26:07 -050028from anyjson import simplejson
Joe Gregorioe6efd532010-09-20 11:13:50 -040029
30
Joe Gregorio6d5e94f2010-08-25 23:49:30 -040031def main():
32 for filename in sys.argv[1:]:
33 f = file(filename, "r")
34 dis = simplejson.load(f)
35 f.close()
36
Joe Gregorio3b3a1912010-11-04 19:37:05 -040037 api = dis['name']
38 version = dis['version']
39 resources = dis['resources']
Joe Gregorio6d5e94f2010-08-25 23:49:30 -040040 for res_name, res_desc in resources.iteritems():
41 methods = res_desc['methods']
42 for method_name, method_desc in methods.iteritems():
43 methods[method_name] = {}
44 path, basename = os.path.split(filename)
45 newfilename = os.path.join(path, "skel-" + basename)
46 f = file(newfilename, "w")
47 simplejson.dump(dis, f, sort_keys=True, indent=2 * ' ')
48 f.close()
49
50
51if __name__ == '__main__':
52 main()