Skip to content

Commit b7e7d56

Browse files
committed
Proper naming + a build script
1 parent f908116 commit b7e7d56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+200
-522
lines changed

README.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# swagger-client
1+
# leetcode
22
Leetcode API implementation.
33

44

@@ -32,7 +32,6 @@ You can find examples of usage in `example.py`
3232

3333
[1] https://github.com/skygragon/leetcode-cli
3434

35-
3635
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
3736

3837
- API version: 1.0.1-1
@@ -55,7 +54,7 @@ pip install git+https://github.com/prius/python-leetcode.git
5554

5655
Then import the package:
5756
```python
58-
import swagger_client
57+
import leetcode
5958
```
6059

6160
### Setuptools
@@ -69,7 +68,7 @@ python setup.py install --user
6968

7069
Then import the package:
7170
```python
72-
import swagger_client
71+
import leetcode
7372
```
7473

7574
## Getting Started
@@ -79,33 +78,33 @@ Please follow the [installation procedure](#installation--usage) and then run th
7978
```python
8079
from __future__ import print_function
8180
import time
82-
import swagger_client
83-
from swagger_client.rest import ApiException
81+
import leetcode
82+
from leetcode.rest import ApiException
8483
from pprint import pprint
8584

8685
# Configure API key authorization: cookieCSRF
87-
configuration = swagger_client.Configuration()
86+
configuration = leetcode.Configuration()
8887
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
8988
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
9089
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
9190
# Configure API key authorization: cookieSession
92-
configuration = swagger_client.Configuration()
91+
configuration = leetcode.Configuration()
9392
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
9493
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
9594
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
9695
# Configure API key authorization: headerCSRF
97-
configuration = swagger_client.Configuration()
96+
configuration = leetcode.Configuration()
9897
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
9998
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
10099
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
101100
# Configure API key authorization: referer
102-
configuration = swagger_client.Configuration()
101+
configuration = leetcode.Configuration()
103102
configuration.api_key['Referer'] = 'YOUR_API_KEY'
104103
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
105104
# configuration.api_key_prefix['Referer'] = 'Bearer'
106105

107106
# create an instance of the API class
108-
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
107+
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
109108
topic = 'topic_example' # str |
110109

111110
try:
@@ -115,29 +114,29 @@ except ApiException as e:
115114
print("Exception when calling DefaultApi->api_problems_topic_get: %s\n" % e)
116115

117116
# Configure API key authorization: cookieCSRF
118-
configuration = swagger_client.Configuration()
117+
configuration = leetcode.Configuration()
119118
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
120119
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
121120
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
122121
# Configure API key authorization: cookieSession
123-
configuration = swagger_client.Configuration()
122+
configuration = leetcode.Configuration()
124123
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
125124
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
126125
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
127126
# Configure API key authorization: headerCSRF
128-
configuration = swagger_client.Configuration()
127+
configuration = leetcode.Configuration()
129128
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
130129
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
131130
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
132131
# Configure API key authorization: referer
133-
configuration = swagger_client.Configuration()
132+
configuration = leetcode.Configuration()
134133
configuration.api_key['Referer'] = 'YOUR_API_KEY'
135134
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
136135
# configuration.api_key_prefix['Referer'] = 'Bearer'
137136

138137
# create an instance of the API class
139-
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
140-
body = swagger_client.GraphqlQuery() # GraphqlQuery | GraphQL query (optional)
138+
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
139+
body = leetcode.GraphqlQuery() # GraphqlQuery | GraphQL query (optional)
141140

142141
try:
143142
api_response = api_instance.graphql_post(body=body)
@@ -146,30 +145,30 @@ except ApiException as e:
146145
print("Exception when calling DefaultApi->graphql_post: %s\n" % e)
147146

148147
# Configure API key authorization: cookieCSRF
149-
configuration = swagger_client.Configuration()
148+
configuration = leetcode.Configuration()
150149
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
151150
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
152151
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
153152
# Configure API key authorization: cookieSession
154-
configuration = swagger_client.Configuration()
153+
configuration = leetcode.Configuration()
155154
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
156155
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
157156
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
158157
# Configure API key authorization: headerCSRF
159-
configuration = swagger_client.Configuration()
158+
configuration = leetcode.Configuration()
160159
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
161160
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
162161
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
163162
# Configure API key authorization: referer
164-
configuration = swagger_client.Configuration()
163+
configuration = leetcode.Configuration()
165164
configuration.api_key['Referer'] = 'YOUR_API_KEY'
166165
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
167166
# configuration.api_key_prefix['Referer'] = 'Bearer'
168167

169168
# create an instance of the API class
170-
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
169+
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
171170
problem = 'problem_example' # str |
172-
body = swagger_client.TestSubmission() # TestSubmission | Solution to test (optional)
171+
body = leetcode.TestSubmission() # TestSubmission | Solution to test (optional)
173172

174173
try:
175174
api_response = api_instance.problems_problem_interpret_solution_post(problem, body=body)
@@ -178,30 +177,30 @@ except ApiException as e:
178177
print("Exception when calling DefaultApi->problems_problem_interpret_solution_post: %s\n" % e)
179178

180179
# Configure API key authorization: cookieCSRF
181-
configuration = swagger_client.Configuration()
180+
configuration = leetcode.Configuration()
182181
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
183182
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
184183
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
185184
# Configure API key authorization: cookieSession
186-
configuration = swagger_client.Configuration()
185+
configuration = leetcode.Configuration()
187186
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
188187
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
189188
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
190189
# Configure API key authorization: headerCSRF
191-
configuration = swagger_client.Configuration()
190+
configuration = leetcode.Configuration()
192191
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
193192
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
194193
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
195194
# Configure API key authorization: referer
196-
configuration = swagger_client.Configuration()
195+
configuration = leetcode.Configuration()
197196
configuration.api_key['Referer'] = 'YOUR_API_KEY'
198197
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
199198
# configuration.api_key_prefix['Referer'] = 'Bearer'
200199

201200
# create an instance of the API class
202-
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
201+
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
203202
problem = 'problem_example' # str |
204-
body = swagger_client.Submission() # Submission | Solution to test (optional)
203+
body = leetcode.Submission() # Submission | Solution to test (optional)
205204

206205
try:
207206
api_response = api_instance.problems_problem_submit_post(problem, body=body)
@@ -210,29 +209,29 @@ except ApiException as e:
210209
print("Exception when calling DefaultApi->problems_problem_submit_post: %s\n" % e)
211210

212211
# Configure API key authorization: cookieCSRF
213-
configuration = swagger_client.Configuration()
212+
configuration = leetcode.Configuration()
214213
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
215214
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
216215
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
217216
# Configure API key authorization: cookieSession
218-
configuration = swagger_client.Configuration()
217+
configuration = leetcode.Configuration()
219218
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
220219
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
221220
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
222221
# Configure API key authorization: headerCSRF
223-
configuration = swagger_client.Configuration()
222+
configuration = leetcode.Configuration()
224223
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
225224
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
226225
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
227226
# Configure API key authorization: referer
228-
configuration = swagger_client.Configuration()
227+
configuration = leetcode.Configuration()
229228
configuration.api_key['Referer'] = 'YOUR_API_KEY'
230229
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
231230
# configuration.api_key_prefix['Referer'] = 'Bearer'
232231

233232
# create an instance of the API class
234-
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
235-
id = swagger_client.Id() # Id | Either submission id (int) or interpretation id (string)
233+
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
234+
id = leetcode.Id() # Id | Either submission id (int) or interpretation id (string)
236235

237236
try:
238237
api_response = api_instance.submissions_detail_id_check_get(id)

build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cur_dir=$(pwd)
2+
tmp_dir=$(mktemp -d)
3+
4+
cd $tmp_dir
5+
mkdir test
6+
7+
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.27/swagger-codegen-cli-3.0.27.jar -O swagger-codegen-cli.jar
8+
9+
10+
cd $cur_dir
11+
12+
java -jar $tmp_dir/swagger-codegen-cli.jar generate --help
13+
_JAVA_OPTIONS="--add-opens=java.base/java.util=ALL-UNNAMED" java -jar $tmp_dir/swagger-codegen-cli.jar generate -l python -i swagger.yml -DpackageName=leetcode --git-user-id=prius --git-repo-id=python-leetcode
14+
15+
16+
rm -rf $tmp_dir
17+
18+
patch -p1 < fix_cookies.patch
19+
patch -p1 < fix_gitignore.patch

0 commit comments

Comments
 (0)