19 from __future__
import print_function
25 print(
"Pystache required. Please sudo pip install pystache.", file=sys.stderr)
30 from asterisk_processor
import AsteriskProcessor
31 from optparse
import OptionParser
32 from swagger_model
import ResourceListing
33 from transform
import Transform
35 TOPDIR = os.path.dirname(os.path.abspath(__file__))
39 """Helper to get a file relative to the script's directory 41 @parm file: Relative file path. 43 return os.path.join(TOPDIR, file)
45 WIKI_PREFIX =
'Asterisk 18' 49 'doc/rest-api/%s {{name_title}} REST API.wiki' % WIKI_PREFIX),
51 'res/res_ari_{{c_name}}.c'),
53 'res/ari/resource_{{c_name}}.h'),
55 'res/ari/resource_{{c_name}}.c', overwrite=
False),
58 RESOURCES_TRANSFORMS = [
60 'doc/rest-api/%s REST Data Models.wiki' % WIKI_PREFIX),
63 'res/ari/ari_model_validators.h'),
65 'res/ari/ari_model_validators.c'),
70 parser = OptionParser(usage=
"Usage %prog [resources.json] [destdir]")
72 (options, args) = parser.parse_args(argv)
75 parser.error(
"Wrong number of arguments")
79 renderer = pystache.Renderer(search_dirs=[TOPDIR], missing_tags=
'strict')
83 base_dir = os.path.dirname(source)
85 for api
in resources.apis:
86 api.load_api_declaration(base_dir, processor)
89 for api
in resources.apis:
90 for transform
in API_TRANSFORMS:
91 transform.render(renderer, api, dest_dir)
92 for transform
in RESOURCES_TRANSFORMS:
93 transform.render(renderer, resources, dest_dir)
95 if __name__ ==
"__main__":
96 sys.exit(
main(sys.argv)
or 0)
static int load_file(const char *filename, char **ret)
Read a TEXT file into a string and return the length.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)