-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathgenerate_base_client.py
More file actions
executable file
·116 lines (101 loc) · 2.8 KB
/
Copy pathgenerate_base_client.py
File metadata and controls
executable file
·116 lines (101 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import glob
import os
import subprocess
import sys
cmdline_desc = """\
Runs Stone to generate Python types and client for the Dropbox client.
"""
_cmdline_parser = argparse.ArgumentParser(description=cmdline_desc)
_cmdline_parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="Print debugging statements.",
)
_cmdline_parser.add_argument(
"spec",
nargs="*",
type=str,
help="Path to API specifications. Each must have a .stone extension.",
)
def main():
"""The entry point for the program."""
args = _cmdline_parser.parse_args()
verbose = args.verbose
if args.spec:
specs = args.spec
else:
# If no specs were specified, default to the spec submodule.
specs = glob.glob("spec/*.stone") # Arbitrary sorting
specs.sort()
specs = [os.path.join(os.getcwd(), s) for s in specs]
dropbox_pkg_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "dropbox"))
if verbose:
print("Dropbox package path: %s" % dropbox_pkg_path)
if verbose:
print("Generating Python types")
subprocess.check_output(
(
["python", "-m", "stone.cli", "python_types", dropbox_pkg_path]
+ specs
+ ["-a", "host", "-a", "style", "-a", "auth"]
+ [
"--",
"-r",
"dropbox.dropbox_client.Dropbox.{ns}_{route}",
"-p",
"dropbox",
]
)
)
if verbose:
print("Generating Python client")
o = subprocess.check_output(
(
["python", "-m", "stone.cli", "python_client", dropbox_pkg_path]
+ specs
+ ["-a", "host", "-a", "style", "-a", "auth", "-a", "scope"]
+ [
"--",
"-w",
"user,app,noauth",
"-m",
"base",
"-c",
"DropboxBase",
"-t",
"dropbox",
"-a",
"scope",
]
)
)
if o:
print("Output:", o)
o = subprocess.check_output(
(
["python", "-m", "stone.cli", "python_client", dropbox_pkg_path]
+ specs
+ ["-a", "host", "-a", "style", "-a", "auth", "-a", "scope"]
+ [
"--",
"-w",
"team",
"-m",
"base_team",
"-c",
"DropboxTeamBase",
"-t",
"dropbox",
"-a",
"scope",
]
)
)
if o:
print("Output:", o)
if __name__ == "__main__":
main()