seatable-api 2.8.0__tar.gz → 2.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seatable-api-2.8.2/LICENSE +201 -0
- seatable-api-2.8.2/PKG-INFO +26 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/api_gateway.py +47 -28
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/convert_airtable.py +225 -59
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/main.py +2 -1
- seatable-api-2.8.2/seatable_api.egg-info/PKG-INFO +26 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api.egg-info/SOURCES.txt +1 -1
- {seatable-api-2.8.0 → seatable-api-2.8.2}/setup.py +1 -1
- seatable-api-2.8.0/PKG-INFO +0 -23
- seatable-api-2.8.0/seatable_api/parsetab.py +0 -44
- seatable-api-2.8.0/seatable_api.egg-info/PKG-INFO +0 -23
- {seatable-api-2.8.0 → seatable-api-2.8.2}/README.md +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/__init__.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/column.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/constants.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/context.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/date_utils.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/exception.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/message.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/query.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/socket_io.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api/utils.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api.egg-info/dependency_links.txt +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api.egg-info/requires.txt +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/seatable_api.egg-info/top_level.txt +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/setup.cfg +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/tests/__init__.py +0 -0
- {seatable-api-2.8.0 → seatable-api-2.8.2}/tests/dateutils_test.py +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: seatable-api
|
|
3
|
+
Version: 2.8.2
|
|
4
|
+
Summary: Python client for SeaTable web api
|
|
5
|
+
Home-page: https://github.com/seatable/seatable-api-python
|
|
6
|
+
Author: seatable
|
|
7
|
+
Author-email: support@seafile.com
|
|
8
|
+
License: Apache Licence
|
|
9
|
+
Platform: any
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
# seatable-api-python
|
|
15
|
+
|
|
16
|
+
Python client for SeaTable web api
|
|
17
|
+
|
|
18
|
+
English document: <https://seatable.github.io/seatable-scripts/>
|
|
19
|
+
|
|
20
|
+
Chinese document: <https://seatable.github.io/seatable-scripts-cn/>
|
|
21
|
+
|
|
22
|
+
pypi: <https://pypi.org/project/seatable-api/>
|
|
23
|
+
|
|
24
|
+
github: <https://github.com/seatable/seatable-api-python>
|
|
25
|
+
|
|
26
|
+
|
|
@@ -54,6 +54,9 @@ class APIGateway(object):
|
|
|
54
54
|
def _row_link_server_url(self):
|
|
55
55
|
return self.api_gateway_url + '/api/v2/dtables/' + self.dtable_uuid + '/links/'
|
|
56
56
|
|
|
57
|
+
def _query_links_server_url(self):
|
|
58
|
+
return self.api_gateway_url + '/api/v2/dtables/' + self.dtable_uuid + '/query-links/'
|
|
59
|
+
|
|
57
60
|
def _batch_update_row_link_server_url(self):
|
|
58
61
|
return self._row_link_server_url()
|
|
59
62
|
|
|
@@ -148,7 +151,7 @@ class APIGateway(object):
|
|
|
148
151
|
response = requests.get(view_url, headers=self.headers, timeout=self.timeout)
|
|
149
152
|
return parse_response(response)
|
|
150
153
|
|
|
151
|
-
|
|
154
|
+
|
|
152
155
|
def add_view(self, table_name, view_name):
|
|
153
156
|
url = self._view_server_url()
|
|
154
157
|
view_url = '%(url)s/?table_name=%(table_name)s' % ({
|
|
@@ -161,7 +164,7 @@ class APIGateway(object):
|
|
|
161
164
|
response = requests.post(view_url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
162
165
|
return parse_response(response)
|
|
163
166
|
|
|
164
|
-
|
|
167
|
+
|
|
165
168
|
def rename_view(self, table_name, view_name, new_view_name):
|
|
166
169
|
url = self._view_server_url()
|
|
167
170
|
view_url = '%(url)s/%(view_name)s/?table_name=%(table_name)s' % ({
|
|
@@ -175,7 +178,7 @@ class APIGateway(object):
|
|
|
175
178
|
response = requests.put(view_url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
176
179
|
return parse_response(response)
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
|
|
179
182
|
def delete_view(self, table_name, view_name):
|
|
180
183
|
url = self._view_server_url()
|
|
181
184
|
view_url = '%(url)s/%(view_name)s/?table_name=%(table_name)s' % ({
|
|
@@ -186,7 +189,7 @@ class APIGateway(object):
|
|
|
186
189
|
response = requests.delete(view_url, headers=self.headers, timeout=self.timeout)
|
|
187
190
|
return parse_response(response)
|
|
188
191
|
|
|
189
|
-
|
|
192
|
+
|
|
190
193
|
def list_rows(self, table_name, view_name=None, order_by=None, desc=False, start=None, limit=None):
|
|
191
194
|
"""
|
|
192
195
|
:param table_name: str
|
|
@@ -218,7 +221,7 @@ class APIGateway(object):
|
|
|
218
221
|
data = parse_response(response)
|
|
219
222
|
return data.get('rows')
|
|
220
223
|
|
|
221
|
-
|
|
224
|
+
|
|
222
225
|
def get_row(self, table_name, row_id):
|
|
223
226
|
"""
|
|
224
227
|
:param table_name: str
|
|
@@ -237,7 +240,7 @@ class APIGateway(object):
|
|
|
237
240
|
data = parse_response(response)
|
|
238
241
|
return data
|
|
239
242
|
|
|
240
|
-
|
|
243
|
+
|
|
241
244
|
def append_row(self, table_name, row_data, apply_default=None):
|
|
242
245
|
"""
|
|
243
246
|
:param table_name: str
|
|
@@ -256,7 +259,7 @@ class APIGateway(object):
|
|
|
256
259
|
data = parse_response(response)
|
|
257
260
|
return data.get('first_row')
|
|
258
261
|
|
|
259
|
-
|
|
262
|
+
|
|
260
263
|
def batch_append_rows(self, table_name, rows_data, apply_default=None):
|
|
261
264
|
"""
|
|
262
265
|
:param table_name: str
|
|
@@ -274,7 +277,7 @@ class APIGateway(object):
|
|
|
274
277
|
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
275
278
|
return parse_response(response)
|
|
276
279
|
|
|
277
|
-
|
|
280
|
+
|
|
278
281
|
def insert_row(self, table_name, row_data, anchor_row_id, apply_default=None):
|
|
279
282
|
"""
|
|
280
283
|
:param table_name: str
|
|
@@ -282,7 +285,7 @@ class APIGateway(object):
|
|
|
282
285
|
:param anchor_row_id: str
|
|
283
286
|
"""
|
|
284
287
|
return self.append_row(table_name, row_data, apply_default=apply_default)
|
|
285
|
-
|
|
288
|
+
|
|
286
289
|
|
|
287
290
|
def update_row(self, table_name, row_id, row_data):
|
|
288
291
|
"""
|
|
@@ -301,7 +304,7 @@ class APIGateway(object):
|
|
|
301
304
|
response = requests.put(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
302
305
|
return parse_response(response)
|
|
303
306
|
|
|
304
|
-
|
|
307
|
+
|
|
305
308
|
def batch_update_rows(self, table_name, rows_data):
|
|
306
309
|
"""
|
|
307
310
|
:param table_name: str
|
|
@@ -318,7 +321,7 @@ class APIGateway(object):
|
|
|
318
321
|
response = requests.put(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
319
322
|
return parse_response(response)
|
|
320
323
|
|
|
321
|
-
|
|
324
|
+
|
|
322
325
|
def delete_row(self, table_name, row_id):
|
|
323
326
|
"""
|
|
324
327
|
:param table_name: str
|
|
@@ -334,7 +337,7 @@ class APIGateway(object):
|
|
|
334
337
|
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
335
338
|
return parse_response(response)
|
|
336
339
|
|
|
337
|
-
|
|
340
|
+
|
|
338
341
|
def batch_delete_rows(self, table_name, row_ids):
|
|
339
342
|
"""
|
|
340
343
|
:param table_name: str
|
|
@@ -350,7 +353,7 @@ class APIGateway(object):
|
|
|
350
353
|
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
351
354
|
return parse_response(response)
|
|
352
355
|
|
|
353
|
-
|
|
356
|
+
|
|
354
357
|
def filter_rows(self, table_name, filters, view_name=None, filter_conjunction='And'):
|
|
355
358
|
"""
|
|
356
359
|
:param table_name: str
|
|
@@ -417,7 +420,7 @@ class APIGateway(object):
|
|
|
417
420
|
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
418
421
|
return parse_response(response)
|
|
419
422
|
|
|
420
|
-
|
|
423
|
+
|
|
421
424
|
def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
|
|
422
425
|
"""
|
|
423
426
|
:param link_id: str
|
|
@@ -440,7 +443,7 @@ class APIGateway(object):
|
|
|
440
443
|
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
441
444
|
return parse_response(response)
|
|
442
445
|
|
|
443
|
-
|
|
446
|
+
|
|
444
447
|
def update_link(self, link_id, table_name, other_table_name, row_id, other_rows_ids):
|
|
445
448
|
"""
|
|
446
449
|
:param link_id: str
|
|
@@ -467,7 +470,7 @@ class APIGateway(object):
|
|
|
467
470
|
response = requests.put(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
468
471
|
return parse_response(response)
|
|
469
472
|
|
|
470
|
-
|
|
473
|
+
|
|
471
474
|
def batch_update_links(self, link_id, table_name, other_table_name, row_id_list, other_rows_ids_map):
|
|
472
475
|
"""
|
|
473
476
|
:param link_id: str
|
|
@@ -492,6 +495,22 @@ class APIGateway(object):
|
|
|
492
495
|
return parse_response(response)
|
|
493
496
|
|
|
494
497
|
|
|
498
|
+
def get_linked_records(self, table_id, link_column_key, rows):
|
|
499
|
+
"""
|
|
500
|
+
:param table_id: str
|
|
501
|
+
:param link_column_key: str
|
|
502
|
+
:param rows: list
|
|
503
|
+
"""
|
|
504
|
+
url = self._query_links_server_url()
|
|
505
|
+
json_data = {
|
|
506
|
+
'table_id': table_id,
|
|
507
|
+
'link_column_key': link_column_key,
|
|
508
|
+
'rows': rows,
|
|
509
|
+
}
|
|
510
|
+
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
|
|
511
|
+
return parse_response(response)
|
|
512
|
+
|
|
513
|
+
|
|
495
514
|
def list_columns(self, table_name, view_name=None):
|
|
496
515
|
"""
|
|
497
516
|
:param table_name: str
|
|
@@ -510,7 +529,7 @@ class APIGateway(object):
|
|
|
510
529
|
data = parse_response(response)
|
|
511
530
|
return data.get('columns')
|
|
512
531
|
|
|
513
|
-
|
|
532
|
+
|
|
514
533
|
def get_column_link_id(self, table_name, column_name):
|
|
515
534
|
columns = self.list_columns(table_name)
|
|
516
535
|
for column in columns:
|
|
@@ -518,14 +537,14 @@ class APIGateway(object):
|
|
|
518
537
|
return column.get('data', {}).get('link_id')
|
|
519
538
|
raise ValueError('link type column "%s" does not exist in current table' % column_name)
|
|
520
539
|
|
|
521
|
-
|
|
540
|
+
|
|
522
541
|
def get_column_by_name(self, table_name, column_name):
|
|
523
542
|
columns = self.list_columns(table_name)
|
|
524
543
|
for col in columns:
|
|
525
544
|
if col.get('name') == column_name:
|
|
526
545
|
return col
|
|
527
546
|
|
|
528
|
-
|
|
547
|
+
|
|
529
548
|
def get_columns_by_type(self, table_name, column_type: ColumnTypes):
|
|
530
549
|
if column_type not in ColumnTypes:
|
|
531
550
|
raise ValueError("type %s invalid!" % (column_type,))
|
|
@@ -533,7 +552,7 @@ class APIGateway(object):
|
|
|
533
552
|
cols_results = [col for col in columns if col.get('type') == column_type.value]
|
|
534
553
|
return cols_results
|
|
535
554
|
|
|
536
|
-
|
|
555
|
+
|
|
537
556
|
def insert_column(self, table_name, column_name, column_type, column_key=None, column_data=None):
|
|
538
557
|
"""
|
|
539
558
|
:param table_name: str
|
|
@@ -561,7 +580,7 @@ class APIGateway(object):
|
|
|
561
580
|
data = parse_response(response)
|
|
562
581
|
return data
|
|
563
582
|
|
|
564
|
-
|
|
583
|
+
|
|
565
584
|
def rename_column(self, table_name, column_key, new_column_name):
|
|
566
585
|
"""
|
|
567
586
|
:param table_name: str
|
|
@@ -582,7 +601,7 @@ class APIGateway(object):
|
|
|
582
601
|
data = parse_response(response)
|
|
583
602
|
return data
|
|
584
603
|
|
|
585
|
-
|
|
604
|
+
|
|
586
605
|
def resize_column(self, table_name, column_key, new_column_width):
|
|
587
606
|
"""
|
|
588
607
|
:param table_name: str
|
|
@@ -604,7 +623,7 @@ class APIGateway(object):
|
|
|
604
623
|
data = parse_response(response)
|
|
605
624
|
return data
|
|
606
625
|
|
|
607
|
-
|
|
626
|
+
|
|
608
627
|
def freeze_column(self, table_name, column_key, frozen):
|
|
609
628
|
"""
|
|
610
629
|
:param table_name: str
|
|
@@ -625,7 +644,7 @@ class APIGateway(object):
|
|
|
625
644
|
data = parse_response(response)
|
|
626
645
|
return data
|
|
627
646
|
|
|
628
|
-
|
|
647
|
+
|
|
629
648
|
def move_column(self, table_name, column_key, target_column_key):
|
|
630
649
|
"""
|
|
631
650
|
:param table_name: str
|
|
@@ -646,7 +665,7 @@ class APIGateway(object):
|
|
|
646
665
|
data = parse_response(response)
|
|
647
666
|
return data
|
|
648
667
|
|
|
649
|
-
|
|
668
|
+
|
|
650
669
|
def modify_column_type(self, table_name, column_key, new_column_type):
|
|
651
670
|
"""
|
|
652
671
|
:param table_name: str
|
|
@@ -669,7 +688,7 @@ class APIGateway(object):
|
|
|
669
688
|
data = parse_response(response)
|
|
670
689
|
return data
|
|
671
690
|
|
|
672
|
-
|
|
691
|
+
|
|
673
692
|
def add_column_options(self, table_name, column, options):
|
|
674
693
|
"""
|
|
675
694
|
:param table_name: str
|
|
@@ -688,7 +707,7 @@ class APIGateway(object):
|
|
|
688
707
|
data = parse_response(response)
|
|
689
708
|
return data
|
|
690
709
|
|
|
691
|
-
|
|
710
|
+
|
|
692
711
|
def add_column_cascade_settings(self, table_name, child_column, parent_column, cascade_settings):
|
|
693
712
|
"""
|
|
694
713
|
|
|
@@ -711,7 +730,7 @@ class APIGateway(object):
|
|
|
711
730
|
data = parse_response(response)
|
|
712
731
|
return data
|
|
713
732
|
|
|
714
|
-
|
|
733
|
+
|
|
715
734
|
def delete_column(self, table_name, column_key):
|
|
716
735
|
"""
|
|
717
736
|
:param table_name: str
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
1
3
|
import re
|
|
4
|
+
import sys
|
|
2
5
|
import time
|
|
3
6
|
import random
|
|
4
7
|
import requests
|
|
8
|
+
import urllib
|
|
5
9
|
from datetime import datetime
|
|
6
10
|
|
|
7
11
|
from .constants import ColumnTypes
|
|
@@ -23,6 +27,8 @@ ColumnTypes.BARCODE = 'barcode'
|
|
|
23
27
|
FILE = 'file'
|
|
24
28
|
IMAGE = 'image'
|
|
25
29
|
|
|
30
|
+
logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S', stream=sys.stdout, level=logging.INFO)
|
|
31
|
+
logger = logging.getLogger()
|
|
26
32
|
|
|
27
33
|
class LinksConvertor(object):
|
|
28
34
|
|
|
@@ -42,7 +48,7 @@ class LinksConvertor(object):
|
|
|
42
48
|
row_id_list.append(row_id)
|
|
43
49
|
other_rows_ids_map[row_id] = link
|
|
44
50
|
except Exception as e:
|
|
45
|
-
|
|
51
|
+
logger.exception('Error during link generation')
|
|
46
52
|
links = {
|
|
47
53
|
'link_id': link_data['link_id'],
|
|
48
54
|
'table_id': link_data['table_id'],
|
|
@@ -75,7 +81,7 @@ class FilesConvertor(object):
|
|
|
75
81
|
name=name, content=content, file_type=file_type)
|
|
76
82
|
return file_info
|
|
77
83
|
except Exception as e:
|
|
78
|
-
|
|
84
|
+
logger.exception('Could not upload file')
|
|
79
85
|
return None
|
|
80
86
|
|
|
81
87
|
def batch_upload_files(self, value):
|
|
@@ -215,7 +221,7 @@ class RowsConvertor(object):
|
|
|
215
221
|
else: # DEFAULT
|
|
216
222
|
cell_data = str(value)
|
|
217
223
|
except Exception as e:
|
|
218
|
-
|
|
224
|
+
logger.exception('Could not generate cell data')
|
|
219
225
|
cell_data = str(value)
|
|
220
226
|
return cell_data
|
|
221
227
|
|
|
@@ -226,6 +232,7 @@ class RowsConvertor(object):
|
|
|
226
232
|
for column in columns:
|
|
227
233
|
column_name = column['name']
|
|
228
234
|
column_type = ColumnTypes(column['type'])
|
|
235
|
+
|
|
229
236
|
value = row.get(column_name)
|
|
230
237
|
if value is None:
|
|
231
238
|
continue
|
|
@@ -446,7 +453,8 @@ class AirtableAPI(object):
|
|
|
446
453
|
|
|
447
454
|
def list_rows(self, table_name, offset=''):
|
|
448
455
|
headers = {'Authorization': 'Bearer ' + self.airtable_api_key}
|
|
449
|
-
|
|
456
|
+
# Table names must be encoded since they may contain slashes or other special characters
|
|
457
|
+
url = AIRTABLE_API_URL + self.airtable_base_id + '/' + urllib.parse.quote(table_name, safe='')
|
|
450
458
|
if offset:
|
|
451
459
|
url = url + '?offset=' + offset
|
|
452
460
|
response = requests.get(url, headers=headers, timeout=60)
|
|
@@ -468,29 +476,43 @@ class AirtableAPI(object):
|
|
|
468
476
|
while True:
|
|
469
477
|
rows, offset = self.list_rows(table_name, offset)
|
|
470
478
|
all_rows.extend(rows)
|
|
471
|
-
|
|
472
|
-
'[Info] Got [ %s ] rows in Airtable <%s>' % (len(all_rows), table_name))
|
|
479
|
+
logger.info('Retrieved %d rows from table "%s"', len(all_rows), table_name)
|
|
473
480
|
if not offset:
|
|
474
481
|
break
|
|
475
|
-
time.sleep(0.5)
|
|
482
|
+
# time.sleep(0.5)
|
|
476
483
|
return all_rows
|
|
477
484
|
|
|
485
|
+
def get_schema(self):
|
|
486
|
+
url = f'{AIRTABLE_API_URL}meta/bases/{self.airtable_base_id}/tables'
|
|
487
|
+
headers = {'Authorization': 'Bearer ' + self.airtable_api_key}
|
|
488
|
+
|
|
489
|
+
response = requests.get(url, headers=headers, timeout=60)
|
|
490
|
+
if response.status_code >= 400:
|
|
491
|
+
raise ConnectionError(response.status_code, response.text)
|
|
492
|
+
|
|
493
|
+
return response.json().get('tables', [])
|
|
494
|
+
|
|
478
495
|
|
|
479
496
|
class AirtableConvertor(object):
|
|
480
497
|
|
|
481
|
-
def __init__(self, airtable_api_key, airtable_base_id, base, table_names, first_columns=[], links=[]):
|
|
498
|
+
def __init__(self, airtable_api_key, airtable_base_id, base, table_names, first_columns=[], links=[], excluded_column_types=[], excluded_columns=[]):
|
|
482
499
|
"""
|
|
483
500
|
airtable_api_key: str
|
|
484
501
|
airtable_base_id: str
|
|
485
502
|
base: SeaTable Base
|
|
486
503
|
table_names: list[str], eg: ['table_name1', 'table_name2']
|
|
487
504
|
links: list[tuple], eg: [('table_name', 'column_name', 'other_table_name')]
|
|
505
|
+
excluded_column_types: list[ColumnTypes], e.g. [ColumnTypes.FORMULA, ColumnTypes.LINK_FORMULA]
|
|
506
|
+
excluded_columns: list[tuple[str, str]], e.g. [('Table1', 'Column1'), ('Table2', 'Column5')]
|
|
488
507
|
"""
|
|
489
508
|
self.airtable_api = AirtableAPI(airtable_api_key, airtable_base_id)
|
|
490
509
|
self.base = base
|
|
491
510
|
self.table_names = table_names
|
|
492
511
|
self.first_columns = first_columns
|
|
493
512
|
self.links = links
|
|
513
|
+
self.excluded_column_types = excluded_column_types
|
|
514
|
+
self.excluded_columns = excluded_columns
|
|
515
|
+
self.manually_migrated_columns = []
|
|
494
516
|
self.columns_parser = ColumnsParser()
|
|
495
517
|
self.files_convertor = FilesConvertor(airtable_api_key, base)
|
|
496
518
|
self.rows_convertor = RowsConvertor(self.files_convertor)
|
|
@@ -500,8 +522,13 @@ class AirtableConvertor(object):
|
|
|
500
522
|
|
|
501
523
|
def convert_metadata(self):
|
|
502
524
|
self.get_airtable_row_map(is_demo=True)
|
|
503
|
-
|
|
525
|
+
|
|
526
|
+
schema = self.airtable_api.get_schema()
|
|
527
|
+
self.parse_airtable_schema(schema)
|
|
528
|
+
|
|
504
529
|
self.convert_tables()
|
|
530
|
+
self.add_helper_table()
|
|
531
|
+
|
|
505
532
|
self.convert_columns()
|
|
506
533
|
self.convert_rows(is_demo=True)
|
|
507
534
|
self.convert_links(is_demo=True)
|
|
@@ -509,12 +536,144 @@ class AirtableConvertor(object):
|
|
|
509
536
|
def convert_data(self):
|
|
510
537
|
self.delete_demo_rows()
|
|
511
538
|
self.get_airtable_row_map()
|
|
512
|
-
self.convert_select_columns()
|
|
513
539
|
self.convert_rows()
|
|
514
540
|
self.convert_links()
|
|
515
541
|
|
|
542
|
+
def parse_airtable_schema(self, schema):
|
|
543
|
+
self.airtable_column_map = {}
|
|
544
|
+
|
|
545
|
+
# AirTable -> SeaTable
|
|
546
|
+
COLUMN_MAPPING = {
|
|
547
|
+
# From https://airtable.com/developers/web/api/model/field-type
|
|
548
|
+
# Note: Commented out column types are not supported and must be manually created
|
|
549
|
+
"singleLineText": ColumnTypes.TEXT,
|
|
550
|
+
"email": ColumnTypes.EMAIL,
|
|
551
|
+
"url": ColumnTypes.URL,
|
|
552
|
+
"multilineText": ColumnTypes.LONG_TEXT,
|
|
553
|
+
"number": ColumnTypes.NUMBER,
|
|
554
|
+
"percent": ColumnTypes.NUMBER,
|
|
555
|
+
"currency": ColumnTypes.NUMBER,
|
|
556
|
+
"singleSelect": ColumnTypes.SINGLE_SELECT,
|
|
557
|
+
"multipleSelects": ColumnTypes.MULTIPLE_SELECT,
|
|
558
|
+
"singleCollaborator": ColumnTypes.TEXT,
|
|
559
|
+
"multipleCollaborators": ColumnTypes.TEXT,
|
|
560
|
+
"multipleRecordLinks": ColumnTypes.LINK,
|
|
561
|
+
"date": ColumnTypes.DATE,
|
|
562
|
+
"dateTime": ColumnTypes.DATE,
|
|
563
|
+
# SeaTable does not support phone number columns
|
|
564
|
+
"phoneNumber": ColumnTypes.TEXT,
|
|
565
|
+
"multipleAttachments": ColumnTypes.FILE,
|
|
566
|
+
"checkbox": ColumnTypes.CHECKBOX,
|
|
567
|
+
"formula": ColumnTypes.FORMULA,
|
|
568
|
+
"createdTime": ColumnTypes.DATE,
|
|
569
|
+
#"rollup": '',
|
|
570
|
+
#"count": '',
|
|
571
|
+
#"lookup": '',
|
|
572
|
+
#"multipleLookupValues": '',
|
|
573
|
+
"autoNumber": ColumnTypes.TEXT,
|
|
574
|
+
# SeaTable does not support barcode columns
|
|
575
|
+
"barcode": ColumnTypes.TEXT,
|
|
576
|
+
"rating": ColumnTypes.RATE,
|
|
577
|
+
"richText": ColumnTypes.LONG_TEXT,
|
|
578
|
+
"duration": ColumnTypes.DURATION,
|
|
579
|
+
"lastModifiedTime": ColumnTypes.DATE,
|
|
580
|
+
# "button": ColumnTypes.BUTTON,
|
|
581
|
+
"createdBy": ColumnTypes.TEXT,
|
|
582
|
+
"lastModifiedBy": ColumnTypes.TEXT,
|
|
583
|
+
#"externalSyncSource": '',
|
|
584
|
+
#"aiText": '',
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
for table in schema:
|
|
588
|
+
columns = []
|
|
589
|
+
|
|
590
|
+
for field in table['fields']:
|
|
591
|
+
column_name = field['name']
|
|
592
|
+
column_type = field['type']
|
|
593
|
+
|
|
594
|
+
# TODO: Check if this is necessary
|
|
595
|
+
if column_name == '_id':
|
|
596
|
+
continue
|
|
597
|
+
|
|
598
|
+
seatable_column_type = COLUMN_MAPPING.get(column_type)
|
|
599
|
+
|
|
600
|
+
if seatable_column_type is None:
|
|
601
|
+
logger.warning('Column "%s" (table "%s") is of type "%s"; column must be manually added', column_name, table['name'], column_type)
|
|
602
|
+
self.manually_migrated_columns.append({'Column': column_name, 'Table': table['name'], 'Type': column_type, 'Metadata': json.dumps(field.get('options', ''))})
|
|
603
|
+
# TODO: Remove continue statement
|
|
604
|
+
continue
|
|
605
|
+
|
|
606
|
+
# Handle special cases
|
|
607
|
+
if seatable_column_type == ColumnTypes.DATE:
|
|
608
|
+
column_data = {'format': 'YYYY-MM-DD HH:mm'}
|
|
609
|
+
elif seatable_column_type == ColumnTypes.NUMBER:
|
|
610
|
+
if column_type == 'number':
|
|
611
|
+
column_data = {'format': 'number', 'decimal': 'dot', 'thousands': 'no'}
|
|
612
|
+
elif column_type == 'percent':
|
|
613
|
+
column_data = {'format': 'percent', 'decimal': 'dot', 'thousands': 'no'}
|
|
614
|
+
elif column_type == 'currency':
|
|
615
|
+
column_data = {'format': 'dollar', 'decimal': 'dot', 'thousands': 'no'}
|
|
616
|
+
else:
|
|
617
|
+
column_data = {}
|
|
618
|
+
elif seatable_column_type == ColumnTypes.LINK:
|
|
619
|
+
other_table_name = self.link_map.get(table['name'], {}).get(column_name)
|
|
620
|
+
|
|
621
|
+
if other_table_name is None:
|
|
622
|
+
logger.warning('Column "%s" (table "%s") was not found in link map', column_name, table['name'])
|
|
623
|
+
continue
|
|
624
|
+
|
|
625
|
+
column_data = {'other_table': other_table_name}
|
|
626
|
+
elif seatable_column_type in [ColumnTypes.SINGLE_SELECT, ColumnTypes.MULTIPLE_SELECT]:
|
|
627
|
+
column_data = {
|
|
628
|
+
'options': self.get_select_options(field['options']['choices']),
|
|
629
|
+
}
|
|
630
|
+
elif seatable_column_type == ColumnTypes.DURATION:
|
|
631
|
+
column_data = {
|
|
632
|
+
'format': 'duration',
|
|
633
|
+
# TODO: Read actual format from AirTable schema
|
|
634
|
+
'duration_format': 'h:mm:ss',
|
|
635
|
+
}
|
|
636
|
+
elif seatable_column_type == ColumnTypes.FORMULA:
|
|
637
|
+
column_data = {'formula': '"Formula to be defined"'}
|
|
638
|
+
elif seatable_column_type == ColumnTypes.RATE:
|
|
639
|
+
column_data = {'rate_max_number': field['options']['max']}
|
|
640
|
+
else:
|
|
641
|
+
column_data = {}
|
|
642
|
+
|
|
643
|
+
column = {
|
|
644
|
+
'name': column_name,
|
|
645
|
+
'type': seatable_column_type,
|
|
646
|
+
'data': column_data,
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
columns.append(column)
|
|
650
|
+
|
|
651
|
+
self.airtable_column_map[table['name']] = columns
|
|
652
|
+
|
|
653
|
+
def get_select_options(self, options):
|
|
654
|
+
return [{
|
|
655
|
+
'name': value['name'],
|
|
656
|
+
'id': self.random_num_id(),
|
|
657
|
+
'color': self.random_color(),
|
|
658
|
+
'textColor': TEXT_COLOR,
|
|
659
|
+
} for value in options]
|
|
660
|
+
|
|
661
|
+
def random_num_id(self):
|
|
662
|
+
num_str = '0123456789'
|
|
663
|
+
num = ''
|
|
664
|
+
for i in range(6):
|
|
665
|
+
num += random.choice(num_str)
|
|
666
|
+
return num
|
|
667
|
+
|
|
668
|
+
def random_color(self):
|
|
669
|
+
color_str = '0123456789ABCDEF'
|
|
670
|
+
color = '#'
|
|
671
|
+
for i in range(6):
|
|
672
|
+
color += random.choice(color_str)
|
|
673
|
+
return color
|
|
674
|
+
|
|
516
675
|
def convert_tables(self):
|
|
517
|
-
|
|
676
|
+
logger.info('Start adding tables and columns in SeaTable base')
|
|
518
677
|
self.get_table_map()
|
|
519
678
|
for table_name in self.table_names:
|
|
520
679
|
table = self.table_map.get(table_name)
|
|
@@ -525,6 +684,8 @@ class AirtableConvertor(object):
|
|
|
525
684
|
columns = []
|
|
526
685
|
for column in airtable_columns:
|
|
527
686
|
if column['type'] == ColumnTypes.LINK:
|
|
687
|
+
# Skip link columns for now
|
|
688
|
+
# They will be inserted after all the other columns (in convert_columns())
|
|
528
689
|
continue
|
|
529
690
|
item = {
|
|
530
691
|
'column_name': column['name'],
|
|
@@ -539,13 +700,29 @@ class AirtableConvertor(object):
|
|
|
539
700
|
else:
|
|
540
701
|
columns.append(item)
|
|
541
702
|
self.add_table(table_name, columns)
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
print('[Info] Success\n')
|
|
703
|
+
logger.info('Added table "%s" with %d columns', table_name, len(columns))
|
|
704
|
+
logger.info('Tables and columns added in SeaTable base')
|
|
545
705
|
time.sleep(1)
|
|
546
706
|
|
|
707
|
+
def add_helper_table(self):
|
|
708
|
+
table_name = 'Columns to be migrated manually'
|
|
709
|
+
|
|
710
|
+
# Add column which contains information which columns need to be manually migrated
|
|
711
|
+
columns = [
|
|
712
|
+
{'column_name': 'Column', 'column_type': ColumnTypes.TEXT.value},
|
|
713
|
+
{'column_name': 'Table', 'column_type': ColumnTypes.TEXT.value},
|
|
714
|
+
{'column_name': 'Type', 'column_type': ColumnTypes.TEXT.value},
|
|
715
|
+
{'column_name': 'Metadata', 'column_type': ColumnTypes.LONG_TEXT.value},
|
|
716
|
+
{'column_name': 'Completed', 'column_type': ColumnTypes.CHECKBOX.value},
|
|
717
|
+
]
|
|
718
|
+
|
|
719
|
+
self.add_table(table_name, columns)
|
|
720
|
+
logger.info('Table "%s" added', table_name)
|
|
721
|
+
|
|
722
|
+
self.batch_append_rows(table_name, self.manually_migrated_columns)
|
|
723
|
+
|
|
547
724
|
def convert_columns(self):
|
|
548
|
-
|
|
725
|
+
logger.info('Start adding link columns in SeaTable base')
|
|
549
726
|
self.get_table_map()
|
|
550
727
|
for table_name in self.table_names:
|
|
551
728
|
airtable_columns = self.airtable_column_map[table_name]
|
|
@@ -556,28 +733,37 @@ class AirtableConvertor(object):
|
|
|
556
733
|
if not exists_column:
|
|
557
734
|
self.add_column(
|
|
558
735
|
table_name, column_name, column['type'], column['data'])
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
print('[Info] Success\n')
|
|
736
|
+
logger.info('Added column "%s" to table "%s"', column['name'], table_name)
|
|
737
|
+
logger.info('Link columns added in SeaTable base')
|
|
562
738
|
time.sleep(1)
|
|
563
739
|
|
|
564
740
|
def convert_rows(self, is_demo=False):
|
|
565
|
-
|
|
741
|
+
logger.info('Start appending rows in SeaTable base')
|
|
566
742
|
self.get_table_map()
|
|
567
743
|
for table_name in self.table_names:
|
|
568
744
|
airtable_rows = self.airtable_row_map[table_name]
|
|
569
745
|
if is_demo:
|
|
570
746
|
airtable_rows = airtable_rows[:10]
|
|
571
747
|
columns = self.column_map[table_name]
|
|
748
|
+
|
|
749
|
+
# Remove excluded column types
|
|
750
|
+
columns = [c for c in columns if ColumnTypes(c['type']) not in self.excluded_column_types]
|
|
751
|
+
|
|
752
|
+
# Remove excluded columns
|
|
753
|
+
columns = [
|
|
754
|
+
column for column in columns
|
|
755
|
+
if (table_name, column['name']) not in self.excluded_columns
|
|
756
|
+
]
|
|
757
|
+
|
|
572
758
|
rows = self.rows_convertor.convert(columns, airtable_rows)
|
|
573
759
|
self.batch_append_rows(table_name, rows)
|
|
574
|
-
|
|
760
|
+
logger.info('Rows appended in SeaTable base')
|
|
575
761
|
time.sleep(1)
|
|
576
762
|
|
|
577
763
|
def convert_links(self, is_demo=False):
|
|
578
764
|
if not self.link_map:
|
|
579
765
|
return
|
|
580
|
-
|
|
766
|
+
logger.info('Start adding links between records in SeaTable base')
|
|
581
767
|
self.get_table_map()
|
|
582
768
|
for table_name, column_names in self.link_map.items():
|
|
583
769
|
table = self.table_map[table_name]
|
|
@@ -589,34 +775,17 @@ class AirtableConvertor(object):
|
|
|
589
775
|
links = self.links_convertor.convert(
|
|
590
776
|
column_name, link_data, airtable_rows)
|
|
591
777
|
self.batch_append_links(table_name, links)
|
|
592
|
-
|
|
778
|
+
logger.info('Links added between records in SeaTable base')
|
|
593
779
|
time.sleep(1)
|
|
594
780
|
|
|
595
781
|
def delete_demo_rows(self):
|
|
596
|
-
|
|
782
|
+
logger.info('Start deleting demo rows')
|
|
597
783
|
for table_name in self.table_names:
|
|
598
784
|
rows = self.list_rows(table_name)
|
|
599
785
|
if rows:
|
|
600
786
|
row_ids = [row['_id'] for row in rows]
|
|
601
787
|
self.batch_delete_rows(table_name, row_ids)
|
|
602
|
-
|
|
603
|
-
time.sleep(1)
|
|
604
|
-
|
|
605
|
-
def convert_select_columns(self):
|
|
606
|
-
print('[Info] Convert select columns')
|
|
607
|
-
self.get_table_map()
|
|
608
|
-
for table_name in self.table_names:
|
|
609
|
-
columns = self.table_map[table_name]
|
|
610
|
-
airtable_rows = self.airtable_row_map[table_name]
|
|
611
|
-
select_columns = self.columns_parser.parse_select(
|
|
612
|
-
columns, airtable_rows)
|
|
613
|
-
for column in select_columns:
|
|
614
|
-
column_name = column['name']
|
|
615
|
-
options = column['options']
|
|
616
|
-
self.add_column_options(table_name, column_name, options)
|
|
617
|
-
print(
|
|
618
|
-
'[Info] Added options to column [ %s ] in table <%s>' % (column_name, table_name))
|
|
619
|
-
print('[Info] Success\n')
|
|
788
|
+
logger.info('Demo rows deleted from SeaTable base')
|
|
620
789
|
time.sleep(1)
|
|
621
790
|
|
|
622
791
|
def get_first_column_map(self):
|
|
@@ -639,7 +808,11 @@ class AirtableConvertor(object):
|
|
|
639
808
|
return self.link_map
|
|
640
809
|
|
|
641
810
|
def get_airtable_row_map(self, is_demo=False):
|
|
642
|
-
|
|
811
|
+
if is_demo:
|
|
812
|
+
logger.info('Start retrieving demo data from Airtable')
|
|
813
|
+
else:
|
|
814
|
+
logger.info('Start retrieving data from Airtable')
|
|
815
|
+
|
|
643
816
|
self.airtable_row_map = {}
|
|
644
817
|
for table_name in self.table_names:
|
|
645
818
|
if is_demo:
|
|
@@ -647,17 +820,13 @@ class AirtableConvertor(object):
|
|
|
647
820
|
else:
|
|
648
821
|
rows = self.airtable_api.list_all_rows(table_name)
|
|
649
822
|
self.airtable_row_map[table_name] = rows
|
|
650
|
-
print('[Info] Success\n')
|
|
651
|
-
return self.airtable_row_map
|
|
652
823
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
self.airtable_column_map[table_name] = columns
|
|
660
|
-
return self.airtable_column_map
|
|
824
|
+
if is_demo:
|
|
825
|
+
logger.info('Demo data retrieved from Airtable')
|
|
826
|
+
else:
|
|
827
|
+
logger.info('Data retrieved from Airtable')
|
|
828
|
+
|
|
829
|
+
return self.airtable_row_map
|
|
661
830
|
|
|
662
831
|
def get_table_map(self):
|
|
663
832
|
self.table_map = {}
|
|
@@ -715,8 +884,7 @@ class AirtableConvertor(object):
|
|
|
715
884
|
if not row_split:
|
|
716
885
|
break
|
|
717
886
|
self.base.batch_append_rows(table_name, row_split)
|
|
718
|
-
|
|
719
|
-
'[Info] Appended [ %s ] rows to table <%s>' % (len(row_split), table_name))
|
|
887
|
+
logger.info('Appended %d rows to table "%s"', len(row_split), table_name)
|
|
720
888
|
time.sleep(0.5)
|
|
721
889
|
|
|
722
890
|
def batch_delete_rows(self, table_name, row_ids):
|
|
@@ -727,8 +895,7 @@ class AirtableConvertor(object):
|
|
|
727
895
|
if not row_id_split:
|
|
728
896
|
break
|
|
729
897
|
self.base.batch_delete_rows(table_name, row_id_split)
|
|
730
|
-
|
|
731
|
-
'[Info] Deleted [ %s ] rows in table <%s>' % (len(row_id_split), table_name))
|
|
898
|
+
logger.info('Deleted %d rows from table "%s"', len(row_id_split), table_name)
|
|
732
899
|
time.sleep(0.5)
|
|
733
900
|
|
|
734
901
|
def batch_append_links(self, table_name, links):
|
|
@@ -747,6 +914,5 @@ class AirtableConvertor(object):
|
|
|
747
914
|
row_id: other_rows_ids_map[row_id] for row_id in row_id_split}
|
|
748
915
|
self.base.batch_update_links(
|
|
749
916
|
link_id, table_id, other_table_id, row_id_split, other_rows_ids_map_split)
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
time.sleep(0.5)
|
|
917
|
+
logger.info('Added %d links to table "%s"', len(row_id_split), table_name)
|
|
918
|
+
# time.sleep(0.5)
|
|
@@ -156,7 +156,7 @@ class SeaTableAPI(object):
|
|
|
156
156
|
|
|
157
157
|
def _app_download_link_url(self):
|
|
158
158
|
return self.server_url + '/api/v2.1/dtable/app-download-link/'
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
def _app_custom_download_link_url(self):
|
|
161
161
|
return self.server_url + '/api/v2.1/dtable/custom/app-download-link/'
|
|
162
162
|
|
|
@@ -722,6 +722,7 @@ class SeaTableAPI(object):
|
|
|
722
722
|
return parse_response(response)
|
|
723
723
|
|
|
724
724
|
@check_auth
|
|
725
|
+
@api_gateway_wrapper
|
|
725
726
|
def get_linked_records(self, table_id, link_column_key, rows):
|
|
726
727
|
"""
|
|
727
728
|
:param table_id: str
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: seatable-api
|
|
3
|
+
Version: 2.8.2
|
|
4
|
+
Summary: Python client for SeaTable web api
|
|
5
|
+
Home-page: https://github.com/seatable/seatable-api-python
|
|
6
|
+
Author: seatable
|
|
7
|
+
Author-email: support@seafile.com
|
|
8
|
+
License: Apache Licence
|
|
9
|
+
Platform: any
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
# seatable-api-python
|
|
15
|
+
|
|
16
|
+
Python client for SeaTable web api
|
|
17
|
+
|
|
18
|
+
English document: <https://seatable.github.io/seatable-scripts/>
|
|
19
|
+
|
|
20
|
+
Chinese document: <https://seatable.github.io/seatable-scripts-cn/>
|
|
21
|
+
|
|
22
|
+
pypi: <https://pypi.org/project/seatable-api/>
|
|
23
|
+
|
|
24
|
+
github: <https://github.com/seatable/seatable-api-python>
|
|
25
|
+
|
|
26
|
+
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
LICENSE
|
|
1
2
|
README.md
|
|
2
3
|
setup.py
|
|
3
4
|
seatable_api/__init__.py
|
|
@@ -10,7 +11,6 @@ seatable_api/date_utils.py
|
|
|
10
11
|
seatable_api/exception.py
|
|
11
12
|
seatable_api/main.py
|
|
12
13
|
seatable_api/message.py
|
|
13
|
-
seatable_api/parsetab.py
|
|
14
14
|
seatable_api/query.py
|
|
15
15
|
seatable_api/socket_io.py
|
|
16
16
|
seatable_api/utils.py
|
seatable-api-2.8.0/PKG-INFO
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: seatable-api
|
|
3
|
-
Version: 2.8.0
|
|
4
|
-
Summary: Python client for SeaTable web api
|
|
5
|
-
Home-page: https://github.com/seatable/seatable-api-python
|
|
6
|
-
Author: seatable
|
|
7
|
-
Author-email: support@seafile.com
|
|
8
|
-
License: Apache Licence
|
|
9
|
-
Description: # seatable-api-python
|
|
10
|
-
|
|
11
|
-
Python client for SeaTable web api
|
|
12
|
-
|
|
13
|
-
English document: <https://seatable.github.io/seatable-scripts/>
|
|
14
|
-
|
|
15
|
-
Chinese document: <https://seatable.github.io/seatable-scripts-cn/>
|
|
16
|
-
|
|
17
|
-
pypi: <https://pypi.org/project/seatable-api/>
|
|
18
|
-
|
|
19
|
-
github: <https://github.com/seatable/seatable-api-python>
|
|
20
|
-
|
|
21
|
-
Platform: any
|
|
22
|
-
Classifier: Programming Language :: Python
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# parsetab.py
|
|
3
|
-
# This file is automatically generated. Do not edit.
|
|
4
|
-
# pylint: disable=W,C,R
|
|
5
|
-
_tabversion = '3.10'
|
|
6
|
-
|
|
7
|
-
_lr_method = 'LALR'
|
|
8
|
-
|
|
9
|
-
_lr_signature = 'AND EQUAL GT GTE LIKE LT LTE NOT_EQUAL OR QUOTE_STRING STRINGmerge : filter AND filter\n | filter OR filter\n | merge AND filter\n | merge OR filter\n | filter\n filter : factor EQUAL factor\n | factor NOT_EQUAL factor\n | factor GTE factor\n | factor GT factor\n | factor LTE factor\n | factor LT factor\n | factor LIKE factor\n factor : QUOTE_STRING\n | STRING\n '
|
|
10
|
-
|
|
11
|
-
_lr_action_items = {'QUOTE_STRING':([0,6,7,8,9,10,11,12,13,14,15,16,],[4,4,4,4,4,4,4,4,4,4,4,4,]),'STRING':([0,6,7,8,9,10,11,12,13,14,15,16,],[5,5,5,5,5,5,5,5,5,5,5,5,]),'$end':([1,2,4,5,17,18,19,20,21,22,23,24,25,26,27,],[0,-5,-13,-14,-3,-4,-1,-2,-6,-7,-8,-9,-10,-11,-12,]),'AND':([1,2,4,5,17,18,19,20,21,22,23,24,25,26,27,],[6,8,-13,-14,-3,-4,-1,-2,-6,-7,-8,-9,-10,-11,-12,]),'OR':([1,2,4,5,17,18,19,20,21,22,23,24,25,26,27,],[7,9,-13,-14,-3,-4,-1,-2,-6,-7,-8,-9,-10,-11,-12,]),'EQUAL':([3,4,5,],[10,-13,-14,]),'NOT_EQUAL':([3,4,5,],[11,-13,-14,]),'GTE':([3,4,5,],[12,-13,-14,]),'GT':([3,4,5,],[13,-13,-14,]),'LTE':([3,4,5,],[14,-13,-14,]),'LT':([3,4,5,],[15,-13,-14,]),'LIKE':([3,4,5,],[16,-13,-14,]),}
|
|
12
|
-
|
|
13
|
-
_lr_action = {}
|
|
14
|
-
for _k, _v in _lr_action_items.items():
|
|
15
|
-
for _x,_y in zip(_v[0],_v[1]):
|
|
16
|
-
if not _x in _lr_action: _lr_action[_x] = {}
|
|
17
|
-
_lr_action[_x][_k] = _y
|
|
18
|
-
del _lr_action_items
|
|
19
|
-
|
|
20
|
-
_lr_goto_items = {'merge':([0,],[1,]),'filter':([0,6,7,8,9,],[2,17,18,19,20,]),'factor':([0,6,7,8,9,10,11,12,13,14,15,16,],[3,3,3,3,3,21,22,23,24,25,26,27,]),}
|
|
21
|
-
|
|
22
|
-
_lr_goto = {}
|
|
23
|
-
for _k, _v in _lr_goto_items.items():
|
|
24
|
-
for _x, _y in zip(_v[0], _v[1]):
|
|
25
|
-
if not _x in _lr_goto: _lr_goto[_x] = {}
|
|
26
|
-
_lr_goto[_x][_k] = _y
|
|
27
|
-
del _lr_goto_items
|
|
28
|
-
_lr_productions = [
|
|
29
|
-
("S' -> merge","S'",1,None,None,None),
|
|
30
|
-
('merge -> filter AND filter','merge',3,'p_merge','query.py',161),
|
|
31
|
-
('merge -> filter OR filter','merge',3,'p_merge','query.py',162),
|
|
32
|
-
('merge -> merge AND filter','merge',3,'p_merge','query.py',163),
|
|
33
|
-
('merge -> merge OR filter','merge',3,'p_merge','query.py',164),
|
|
34
|
-
('merge -> filter','merge',1,'p_merge','query.py',165),
|
|
35
|
-
('filter -> factor EQUAL factor','filter',3,'p_filter','query.py',173),
|
|
36
|
-
('filter -> factor NOT_EQUAL factor','filter',3,'p_filter','query.py',174),
|
|
37
|
-
('filter -> factor GTE factor','filter',3,'p_filter','query.py',175),
|
|
38
|
-
('filter -> factor GT factor','filter',3,'p_filter','query.py',176),
|
|
39
|
-
('filter -> factor LTE factor','filter',3,'p_filter','query.py',177),
|
|
40
|
-
('filter -> factor LT factor','filter',3,'p_filter','query.py',178),
|
|
41
|
-
('filter -> factor LIKE factor','filter',3,'p_filter','query.py',179),
|
|
42
|
-
('factor -> QUOTE_STRING','factor',1,'p_factor','query.py',184),
|
|
43
|
-
('factor -> STRING','factor',1,'p_factor','query.py',185),
|
|
44
|
-
]
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: seatable-api
|
|
3
|
-
Version: 2.8.0
|
|
4
|
-
Summary: Python client for SeaTable web api
|
|
5
|
-
Home-page: https://github.com/seatable/seatable-api-python
|
|
6
|
-
Author: seatable
|
|
7
|
-
Author-email: support@seafile.com
|
|
8
|
-
License: Apache Licence
|
|
9
|
-
Description: # seatable-api-python
|
|
10
|
-
|
|
11
|
-
Python client for SeaTable web api
|
|
12
|
-
|
|
13
|
-
English document: <https://seatable.github.io/seatable-scripts/>
|
|
14
|
-
|
|
15
|
-
Chinese document: <https://seatable.github.io/seatable-scripts-cn/>
|
|
16
|
-
|
|
17
|
-
pypi: <https://pypi.org/project/seatable-api/>
|
|
18
|
-
|
|
19
|
-
github: <https://github.com/seatable/seatable-api-python>
|
|
20
|
-
|
|
21
|
-
Platform: any
|
|
22
|
-
Classifier: Programming Language :: Python
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|