datablob 0.10.0__py3-none-any.whl
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.
datablob/__init__.py
ADDED
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
import geopandas as gpd
|
|
4
|
+
import io
|
|
5
|
+
from json import dumps as json_dumps
|
|
6
|
+
from json import loads as json_loads
|
|
7
|
+
from openpyxl import Workbook
|
|
8
|
+
import os
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from shapely.geometry import shape
|
|
11
|
+
import tempfile
|
|
12
|
+
from typing import Literal, TypeAlias
|
|
13
|
+
import zipfile
|
|
14
|
+
from zoneinfo import ZoneInfo
|
|
15
|
+
|
|
16
|
+
from datablob.storage_client import (
|
|
17
|
+
GcsClient as GcsClient,
|
|
18
|
+
S3Client,
|
|
19
|
+
StorageClientProtocol,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
POSSIBLE_LATITUDE_KEYS = [
|
|
23
|
+
"LATITUDE",
|
|
24
|
+
"Latitude",
|
|
25
|
+
"latitude",
|
|
26
|
+
"LAT",
|
|
27
|
+
"Lat",
|
|
28
|
+
"lat",
|
|
29
|
+
"@lat",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
POSSIBLE_LONGITUDE_KEYS = [
|
|
33
|
+
"LONGITUDE",
|
|
34
|
+
"Longitude",
|
|
35
|
+
"longitude",
|
|
36
|
+
"LONG",
|
|
37
|
+
"Long",
|
|
38
|
+
"long",
|
|
39
|
+
"LON",
|
|
40
|
+
"Lon",
|
|
41
|
+
"lon",
|
|
42
|
+
"@lon",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
Provider: TypeAlias = Literal["s3", "gcs"]
|
|
46
|
+
VALID_PROVIDERS: tuple[Provider, ...] = ("s3", "gcs")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class DataBlobClient:
|
|
50
|
+
storage_client: StorageClientProtocol
|
|
51
|
+
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
bucket_name,
|
|
55
|
+
bucket_path,
|
|
56
|
+
timezones=None,
|
|
57
|
+
provider: Provider = "s3",
|
|
58
|
+
storage_client: StorageClientProtocol | None = None,
|
|
59
|
+
):
|
|
60
|
+
if provider not in VALID_PROVIDERS:
|
|
61
|
+
raise ValueError(
|
|
62
|
+
f"Unsupported provider '{provider}'. Must be 's3' or 'gcs'."
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
self.bucket_name = bucket_name
|
|
66
|
+
self.bucket_path = bucket_path.rstrip("/")
|
|
67
|
+
self.timezones = timezones or ["UTC"]
|
|
68
|
+
self.provider = provider
|
|
69
|
+
|
|
70
|
+
if storage_client is not None:
|
|
71
|
+
self.storage_client = storage_client
|
|
72
|
+
elif self.provider == "s3":
|
|
73
|
+
self.storage_client = S3Client(self.bucket_name)
|
|
74
|
+
elif self.provider == "gcs":
|
|
75
|
+
self.storage_client = GcsClient(self.bucket_name)
|
|
76
|
+
else:
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"Unsupported provider '{self.provider}'. Must be 's3' or 'gcs'."
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def _get_unique_keys(self, rows):
|
|
82
|
+
columns = set()
|
|
83
|
+
for row in rows:
|
|
84
|
+
columns.update(row.keys())
|
|
85
|
+
return list(sorted(list(columns)))
|
|
86
|
+
|
|
87
|
+
def _flatten_rows(self, rows):
|
|
88
|
+
flat_rows = []
|
|
89
|
+
for row in rows:
|
|
90
|
+
flat_row = {}
|
|
91
|
+
for key, value in row.items():
|
|
92
|
+
if isinstance(value, dict):
|
|
93
|
+
flat_row[key] = json_dumps(value)
|
|
94
|
+
else:
|
|
95
|
+
flat_row[key] = value
|
|
96
|
+
flat_rows.append(flat_row)
|
|
97
|
+
return flat_rows
|
|
98
|
+
|
|
99
|
+
def get_filenames_by_dataset_and_version(self):
|
|
100
|
+
results = {}
|
|
101
|
+
keys = self.storage_client.list_keys(prefix=self.bucket_path)
|
|
102
|
+
prefix_len = len(self.bucket_path) + 1 if self.bucket_path else 0
|
|
103
|
+
for full_key in keys:
|
|
104
|
+
key = full_key[prefix_len:] if prefix_len else full_key
|
|
105
|
+
|
|
106
|
+
if len(key.split("/")) == 3:
|
|
107
|
+
[dataset_id, version, filename] = key.split("/")
|
|
108
|
+
if version.startswith("v"):
|
|
109
|
+
version = version[1:]
|
|
110
|
+
if filename:
|
|
111
|
+
if dataset_id not in results:
|
|
112
|
+
results[dataset_id] = {}
|
|
113
|
+
if version not in results[dataset_id]:
|
|
114
|
+
results[dataset_id][version] = []
|
|
115
|
+
results[dataset_id][version].append(filename)
|
|
116
|
+
|
|
117
|
+
for dataset_id, subdict in results.items():
|
|
118
|
+
versions = list(subdict.keys())
|
|
119
|
+
for version in versions:
|
|
120
|
+
files = subdict[version]
|
|
121
|
+
if "meta.json" in files:
|
|
122
|
+
subdict[version] = sorted(subdict[version])
|
|
123
|
+
else:
|
|
124
|
+
del subdict[version]
|
|
125
|
+
return results
|
|
126
|
+
|
|
127
|
+
def upload_csv(self, dataset_name, dataset_version, data):
|
|
128
|
+
key = (
|
|
129
|
+
self.bucket_path + "/" + dataset_name + "/v" + dataset_version + "/data.csv"
|
|
130
|
+
)
|
|
131
|
+
self.storage_client.put_object(key, data)
|
|
132
|
+
|
|
133
|
+
def upload_tsv(self, dataset_name, dataset_version, data):
|
|
134
|
+
key = (
|
|
135
|
+
self.bucket_path + "/" + dataset_name + "/v" + dataset_version + "/data.tsv"
|
|
136
|
+
)
|
|
137
|
+
self.storage_client.put_object(key, data)
|
|
138
|
+
|
|
139
|
+
def get_dataset_as_csv(self, name, version, remove_bom=True):
|
|
140
|
+
key = self.bucket_path + "/" + name + "/v" + version + "/data.csv"
|
|
141
|
+
object_content = self.storage_client.get_object_bytes(key).decode("utf-8")
|
|
142
|
+
if remove_bom:
|
|
143
|
+
object_content = object_content.lstrip("\ufeff")
|
|
144
|
+
return object_content
|
|
145
|
+
|
|
146
|
+
def get_dataset_as_tsv(self, name, version, remove_bom=True):
|
|
147
|
+
key = self.bucket_path + "/" + name + "/v" + version + "/data.tsv"
|
|
148
|
+
object_content = self.storage_client.get_object_bytes(key).decode("utf-8")
|
|
149
|
+
if remove_bom:
|
|
150
|
+
object_content = object_content.lstrip("\ufeff")
|
|
151
|
+
return object_content
|
|
152
|
+
|
|
153
|
+
def get_dataset_as_json(self, name, version):
|
|
154
|
+
key = self.bucket_path + "/" + name + "/v" + version + "/data.json"
|
|
155
|
+
object_content = self.storage_client.get_object_bytes(key).decode("utf-8")
|
|
156
|
+
return json_loads(object_content)
|
|
157
|
+
|
|
158
|
+
def get_dataset_metadata(self, name: str, version: str):
|
|
159
|
+
key = self.bucket_path + "/" + name + "/v" + version + "/meta.json"
|
|
160
|
+
object_content = self.storage_client.get_object_bytes(key).decode("utf-8")
|
|
161
|
+
return json_loads(object_content)
|
|
162
|
+
|
|
163
|
+
def upload_geojson_points(self, dataset_name, dataset_version, data):
|
|
164
|
+
key = (
|
|
165
|
+
self.bucket_path
|
|
166
|
+
+ "/"
|
|
167
|
+
+ dataset_name
|
|
168
|
+
+ "/v"
|
|
169
|
+
+ dataset_version
|
|
170
|
+
+ "/data.points.geojson"
|
|
171
|
+
)
|
|
172
|
+
self.storage_client.put_object(
|
|
173
|
+
key,
|
|
174
|
+
data if isinstance(data, str) else json_dumps(data),
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
def upload_geojson_polygons(self, dataset_name, dataset_version, data):
|
|
178
|
+
key = (
|
|
179
|
+
self.bucket_path
|
|
180
|
+
+ "/"
|
|
181
|
+
+ dataset_name
|
|
182
|
+
+ "/v"
|
|
183
|
+
+ dataset_version
|
|
184
|
+
+ "/data.polygons.geojson"
|
|
185
|
+
)
|
|
186
|
+
self.storage_client.put_object(
|
|
187
|
+
key,
|
|
188
|
+
data if isinstance(data, str) else json_dumps(data),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def upload_shapefile_points(self, dataset_name, dataset_version, blob):
|
|
192
|
+
key = (
|
|
193
|
+
self.bucket_path
|
|
194
|
+
+ "/"
|
|
195
|
+
+ dataset_name
|
|
196
|
+
+ "/v"
|
|
197
|
+
+ dataset_version
|
|
198
|
+
+ "/data.points.shp.zip"
|
|
199
|
+
)
|
|
200
|
+
self.storage_client.put_object(key, blob)
|
|
201
|
+
|
|
202
|
+
def upload_shapefile_polygons(self, dataset_name, dataset_version, blob):
|
|
203
|
+
key = (
|
|
204
|
+
self.bucket_path
|
|
205
|
+
+ "/"
|
|
206
|
+
+ dataset_name
|
|
207
|
+
+ "/v"
|
|
208
|
+
+ dataset_version
|
|
209
|
+
+ "/data.polygons.shp.zip"
|
|
210
|
+
)
|
|
211
|
+
self.storage_client.put_object(key, blob)
|
|
212
|
+
|
|
213
|
+
def upload_jsonl(self, dataset_name, dataset_version, data):
|
|
214
|
+
key = (
|
|
215
|
+
self.bucket_path
|
|
216
|
+
+ "/"
|
|
217
|
+
+ dataset_name
|
|
218
|
+
+ "/v"
|
|
219
|
+
+ dataset_version
|
|
220
|
+
+ "/data.jsonl"
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
results = ""
|
|
224
|
+
for row in data:
|
|
225
|
+
results += json_dumps(row) + "\n"
|
|
226
|
+
|
|
227
|
+
self.storage_client.put_object(key, results)
|
|
228
|
+
|
|
229
|
+
def upload_json(self, dataset_name, dataset_version, data):
|
|
230
|
+
key = (
|
|
231
|
+
self.bucket_path
|
|
232
|
+
+ "/"
|
|
233
|
+
+ dataset_name
|
|
234
|
+
+ "/v"
|
|
235
|
+
+ dataset_version
|
|
236
|
+
+ "/data.json"
|
|
237
|
+
)
|
|
238
|
+
self.storage_client.put_object(
|
|
239
|
+
key,
|
|
240
|
+
data if isinstance(data, str) else json_dumps(data),
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
def upload_parquet(self, dataset_name, dataset_version, data):
|
|
244
|
+
key = (
|
|
245
|
+
self.bucket_path
|
|
246
|
+
+ "/"
|
|
247
|
+
+ dataset_name
|
|
248
|
+
+ "/v"
|
|
249
|
+
+ dataset_version
|
|
250
|
+
+ "/data.parquet"
|
|
251
|
+
)
|
|
252
|
+
self.storage_client.put_object(key, data)
|
|
253
|
+
|
|
254
|
+
def upload_xlsx(self, dataset_name, dataset_version, data):
|
|
255
|
+
key = (
|
|
256
|
+
self.bucket_path
|
|
257
|
+
+ "/"
|
|
258
|
+
+ dataset_name
|
|
259
|
+
+ "/v"
|
|
260
|
+
+ dataset_version
|
|
261
|
+
+ "/data.xlsx"
|
|
262
|
+
)
|
|
263
|
+
self.storage_client.put_object(key, data)
|
|
264
|
+
|
|
265
|
+
def upload_metadata(self, dataset_name, dataset_version, data):
|
|
266
|
+
key = (
|
|
267
|
+
self.bucket_path
|
|
268
|
+
+ "/"
|
|
269
|
+
+ dataset_name
|
|
270
|
+
+ "/v"
|
|
271
|
+
+ dataset_version
|
|
272
|
+
+ "/meta.json"
|
|
273
|
+
)
|
|
274
|
+
self.storage_client.put_object(
|
|
275
|
+
key,
|
|
276
|
+
data if isinstance(data, str) else json_dumps(data, indent=4),
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
def convert_gdf_to_shapefile(self, gdf):
|
|
280
|
+
buf = io.BytesIO()
|
|
281
|
+
|
|
282
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
283
|
+
path = os.path.join(tmpdir, "data.shp")
|
|
284
|
+
gdf.to_file(path, driver="ESRI Shapefile")
|
|
285
|
+
|
|
286
|
+
# copy temp files into in-memory zip file
|
|
287
|
+
with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
288
|
+
for filename in os.listdir(tmpdir):
|
|
289
|
+
zf.write(os.path.join(tmpdir, filename), filename)
|
|
290
|
+
|
|
291
|
+
buf.seek(0)
|
|
292
|
+
return buf.getvalue()
|
|
293
|
+
|
|
294
|
+
def _convert_row_to_xlsx_data_types(self, row, xlsx_data_types):
|
|
295
|
+
result = []
|
|
296
|
+
for icol, value in enumerate(row):
|
|
297
|
+
data_type = xlsx_data_types[icol]
|
|
298
|
+
if value is None:
|
|
299
|
+
value = ""
|
|
300
|
+
elif data_type == "Number":
|
|
301
|
+
if value != "":
|
|
302
|
+
value = float(value)
|
|
303
|
+
elif data_type == "Text":
|
|
304
|
+
value = str(value)
|
|
305
|
+
else:
|
|
306
|
+
print("[datablob] warning: unsupported xlsx data type " + data_type)
|
|
307
|
+
value = str(value)
|
|
308
|
+
result.append(value)
|
|
309
|
+
return result
|
|
310
|
+
|
|
311
|
+
def convert_to_xlsx(self, meta, data, columns, xlsx_data_types=None):
|
|
312
|
+
wb = Workbook()
|
|
313
|
+
ws_overview = wb.active
|
|
314
|
+
ws_overview.title = "Overview"
|
|
315
|
+
ws_overview.append(["name", meta["name"]])
|
|
316
|
+
for tz, value in meta["lastUpdated"].items():
|
|
317
|
+
ws_overview.append(["last updated (in " + tz + ")", value])
|
|
318
|
+
ws_overview.append(["description", meta["description"]])
|
|
319
|
+
ws_overview.append(["number of columns", meta["numColumns"]])
|
|
320
|
+
ws_overview.append(["number of rows", meta["numRows"]])
|
|
321
|
+
ws_overview.append(["column names", ", ".join(meta["columns"])])
|
|
322
|
+
if "xlsx_data_types" in meta:
|
|
323
|
+
ws_overview.append(["xlsx data types", ", ".join(meta["xlsx_data_types"])])
|
|
324
|
+
|
|
325
|
+
# Iterate through all cells in the first column (Column A)
|
|
326
|
+
max_length = 0
|
|
327
|
+
for cell in ws_overview["A"]:
|
|
328
|
+
if cell.value:
|
|
329
|
+
if len(str(cell.value)) > max_length:
|
|
330
|
+
max_length = len(str(cell.value))
|
|
331
|
+
ws_overview.column_dimensions["A"].width = max_length + 2
|
|
332
|
+
|
|
333
|
+
ws_data = wb.create_sheet(title="Data")
|
|
334
|
+
ws_data.append(columns)
|
|
335
|
+
for row in data:
|
|
336
|
+
row = [str(row.get(col, "")) for col in columns]
|
|
337
|
+
if xlsx_data_types:
|
|
338
|
+
row = self._convert_row_to_xlsx_data_types(row, xlsx_data_types)
|
|
339
|
+
ws_data.append(row)
|
|
340
|
+
xlsx_buffer = io.BytesIO()
|
|
341
|
+
wb.save(xlsx_buffer)
|
|
342
|
+
xlsx_buffer.seek(0)
|
|
343
|
+
return xlsx_buffer
|
|
344
|
+
|
|
345
|
+
def convert_rows_to_csv(self, rows, fieldnames=None):
|
|
346
|
+
f = io.StringIO(newline="")
|
|
347
|
+
if fieldnames is None:
|
|
348
|
+
fieldnames = sorted(list(rows[0].keys()))
|
|
349
|
+
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
|
350
|
+
writer.writeheader()
|
|
351
|
+
writer.writerows(rows)
|
|
352
|
+
f.seek(0)
|
|
353
|
+
# read and make sure we don't have a BOM
|
|
354
|
+
return f.read().lstrip("\ufeff")
|
|
355
|
+
|
|
356
|
+
def convert_rows_to_tsv(self, rows, fieldnames=None):
|
|
357
|
+
f = io.StringIO(newline="")
|
|
358
|
+
if fieldnames is None:
|
|
359
|
+
fieldnames = sorted(list(rows[0].keys()))
|
|
360
|
+
writer = csv.DictWriter(f, fieldnames=fieldnames, delimiter="\t")
|
|
361
|
+
writer.writeheader()
|
|
362
|
+
writer.writerows(rows)
|
|
363
|
+
f.seek(0)
|
|
364
|
+
# read and make sure we don't have a BOM
|
|
365
|
+
return f.read().lstrip("\ufeff")
|
|
366
|
+
|
|
367
|
+
def infer_latitude(self, rows):
|
|
368
|
+
keys = POSSIBLE_LATITUDE_KEYS
|
|
369
|
+
for row in rows:
|
|
370
|
+
keys = [key for key in keys if key in row]
|
|
371
|
+
return keys[0] if len(keys) > 1 else None
|
|
372
|
+
|
|
373
|
+
def infer_longitude(self, rows):
|
|
374
|
+
keys = POSSIBLE_LONGITUDE_KEYS
|
|
375
|
+
for row in rows:
|
|
376
|
+
keys = [key for key in keys if key in row]
|
|
377
|
+
return keys[0] if len(keys) > 1 else None
|
|
378
|
+
|
|
379
|
+
def convert_rows_to_geojson_points(self, rows, longitude_key, latitude_key):
|
|
380
|
+
features = []
|
|
381
|
+
for row in rows:
|
|
382
|
+
features.append(
|
|
383
|
+
{
|
|
384
|
+
"type": "Feature",
|
|
385
|
+
"properties": row,
|
|
386
|
+
"geometry": {
|
|
387
|
+
"type": "Point",
|
|
388
|
+
"coordinates": [row[longitude_key], row[latitude_key]],
|
|
389
|
+
},
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
return {"type": "FeatureCollection", "features": features}
|
|
393
|
+
|
|
394
|
+
def convert_rows_to_geojson_polygons(self, rows, polygon_key):
|
|
395
|
+
features = []
|
|
396
|
+
for row in rows:
|
|
397
|
+
geometry = row[polygon_key]
|
|
398
|
+
if isinstance(geometry, str):
|
|
399
|
+
geometry = json_loads(geometry)
|
|
400
|
+
if geometry["type"] in ["Polygon", "MultiPolygon"]:
|
|
401
|
+
features.append(
|
|
402
|
+
{
|
|
403
|
+
"type": "Feature",
|
|
404
|
+
"properties": row,
|
|
405
|
+
"geometry": geometry,
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
return {"type": "FeatureCollection", "features": features}
|
|
409
|
+
|
|
410
|
+
def update_dataset(
|
|
411
|
+
self,
|
|
412
|
+
name: str,
|
|
413
|
+
version: str,
|
|
414
|
+
data: list[dict],
|
|
415
|
+
column_names: list[str] | None = None,
|
|
416
|
+
description: str | None = None,
|
|
417
|
+
polygon_key: str | None = None,
|
|
418
|
+
latitude_key: str | None = None,
|
|
419
|
+
longitude_key: str | None = None,
|
|
420
|
+
json: bool = True,
|
|
421
|
+
jsonl: bool = True,
|
|
422
|
+
geojson: bool = True,
|
|
423
|
+
parquet: bool = True,
|
|
424
|
+
xlsx: bool = False,
|
|
425
|
+
xlsx_data_types: list[str] | None = None,
|
|
426
|
+
):
|
|
427
|
+
lastUpdated = dict(
|
|
428
|
+
[(tz, datetime.now(ZoneInfo(tz)).isoformat()) for tz in self.timezones]
|
|
429
|
+
)
|
|
430
|
+
columns = column_names if column_names else self._get_unique_keys(data)
|
|
431
|
+
meta = {
|
|
432
|
+
"name": name,
|
|
433
|
+
"lastUpdated": lastUpdated,
|
|
434
|
+
"description": description or "",
|
|
435
|
+
"numColumns": len(columns),
|
|
436
|
+
"numRows": len(data),
|
|
437
|
+
"columns": columns,
|
|
438
|
+
"files": [],
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
flat_rows = self._flatten_rows(data)
|
|
442
|
+
|
|
443
|
+
data_as_csv = self.convert_rows_to_csv(flat_rows, fieldnames=columns)
|
|
444
|
+
data_as_tsv = self.convert_rows_to_tsv(flat_rows, fieldnames=columns)
|
|
445
|
+
|
|
446
|
+
df = pd.DataFrame(data)
|
|
447
|
+
|
|
448
|
+
data_as_geojson_points = None
|
|
449
|
+
data_as_geojson_polygons = None
|
|
450
|
+
shapefile_points_blob = None
|
|
451
|
+
shapefile_polygons_blob = None
|
|
452
|
+
|
|
453
|
+
if latitude_key and longitude_key:
|
|
454
|
+
if geojson:
|
|
455
|
+
data_as_geojson_points = self.convert_rows_to_geojson_points(
|
|
456
|
+
data, longitude_key=longitude_key, latitude_key=latitude_key
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
if parquet:
|
|
460
|
+
gdf = gpd.GeoDataFrame(
|
|
461
|
+
df,
|
|
462
|
+
geometry=gpd.points_from_xy(df[longitude_key], df[latitude_key]),
|
|
463
|
+
crs="EPSG:4326",
|
|
464
|
+
)
|
|
465
|
+
# drops polygonal column that we don't use in shapefile output
|
|
466
|
+
if polygon_key and polygon_key != "geometry":
|
|
467
|
+
gdf.drop(columns=[polygon_key], inplace=True)
|
|
468
|
+
buffer = io.BytesIO()
|
|
469
|
+
gdf.to_parquet(buffer, engine="pyarrow")
|
|
470
|
+
|
|
471
|
+
data_as_parquet_blob = buffer.getvalue()
|
|
472
|
+
else:
|
|
473
|
+
data_as_parquet_blob = None
|
|
474
|
+
|
|
475
|
+
shapefile_points_blob = self.convert_gdf_to_shapefile(gdf)
|
|
476
|
+
|
|
477
|
+
if polygon_key:
|
|
478
|
+
if geojson:
|
|
479
|
+
data_as_geojson_polygons = self.convert_rows_to_geojson_polygons(
|
|
480
|
+
data, polygon_key=polygon_key
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
if parquet:
|
|
484
|
+
gdf = gpd.GeoDataFrame(
|
|
485
|
+
df,
|
|
486
|
+
geometry=df[polygon_key].apply(shape),
|
|
487
|
+
crs="EPSG:4326",
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
if polygon_key != "geometry":
|
|
491
|
+
# can drop old polygon column, since we replaced with a geometry column
|
|
492
|
+
gdf.drop(columns=[polygon_key], inplace=True)
|
|
493
|
+
|
|
494
|
+
buffer = io.BytesIO()
|
|
495
|
+
gdf.to_parquet(buffer, engine="pyarrow")
|
|
496
|
+
data_as_parquet_blob = buffer.getvalue()
|
|
497
|
+
else:
|
|
498
|
+
data_as_parquet_blob = None
|
|
499
|
+
|
|
500
|
+
shapefile_polygons_blob = self.convert_gdf_to_shapefile(gdf)
|
|
501
|
+
|
|
502
|
+
if not ((latitude_key and longitude_key) or polygon_key):
|
|
503
|
+
if parquet:
|
|
504
|
+
buffer = io.BytesIO()
|
|
505
|
+
df.to_parquet(buffer, engine="pyarrow")
|
|
506
|
+
data_as_parquet_blob = buffer.getvalue()
|
|
507
|
+
else:
|
|
508
|
+
data_as_parquet_blob = None
|
|
509
|
+
|
|
510
|
+
if xlsx:
|
|
511
|
+
if xlsx_data_types:
|
|
512
|
+
meta["xlsx_data_types"] = xlsx_data_types
|
|
513
|
+
data_as_xlsx = self.convert_to_xlsx(
|
|
514
|
+
meta, flat_rows, columns, xlsx_data_types
|
|
515
|
+
)
|
|
516
|
+
self.upload_xlsx(name, version, data_as_xlsx)
|
|
517
|
+
meta["files"].append({"filename": "data.xlsx", "format": "Excel"})
|
|
518
|
+
|
|
519
|
+
self.upload_csv(name, version, data_as_csv)
|
|
520
|
+
meta["files"].append({"filename": "data.csv", "format": "CSV"})
|
|
521
|
+
|
|
522
|
+
self.upload_tsv(name, version, data_as_tsv)
|
|
523
|
+
meta["files"].append({"filename": "data.tsv", "format": "TSV"})
|
|
524
|
+
|
|
525
|
+
if json:
|
|
526
|
+
self.upload_json(name, version, data)
|
|
527
|
+
meta["files"].append({"filename": "data.json", "format": "JSON"})
|
|
528
|
+
|
|
529
|
+
if jsonl:
|
|
530
|
+
self.upload_jsonl(name, version, data)
|
|
531
|
+
meta["files"].append({"filename": "data.jsonl", "format": "JSON Lines"})
|
|
532
|
+
|
|
533
|
+
if geojson and data_as_geojson_points:
|
|
534
|
+
self.upload_geojson_points(name, version, data_as_geojson_points)
|
|
535
|
+
meta["files"].append(
|
|
536
|
+
{"filename": "data.points.geojson", "format": "GeoJSON (Points)"}
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
if geojson and data_as_geojson_polygons:
|
|
540
|
+
self.upload_geojson_polygons(name, version, data_as_geojson_polygons)
|
|
541
|
+
meta["files"].append(
|
|
542
|
+
{"filename": "data.polygons.geojson", "format": "GeoJSON (Polygons)"}
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
if shapefile_points_blob:
|
|
546
|
+
self.upload_shapefile_points(name, version, shapefile_points_blob)
|
|
547
|
+
meta["files"].append(
|
|
548
|
+
{"filename": "data.points.shp.zip", "format": "Shapefile (Points)"}
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
if shapefile_polygons_blob:
|
|
552
|
+
self.upload_shapefile_polygons(name, version, shapefile_polygons_blob)
|
|
553
|
+
meta["files"].append(
|
|
554
|
+
{"filename": "data.polygons.shp.zip", "format": "Shapefile (Polygons)"}
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
if parquet and data_as_parquet_blob:
|
|
558
|
+
self.upload_parquet(name, version, data_as_parquet_blob)
|
|
559
|
+
meta["files"].append({"filename": "data.parquet", "format": "Parquet"})
|
|
560
|
+
|
|
561
|
+
self.upload_metadata(name, version, meta)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import io
|
|
2
|
+
from typing import Protocol
|
|
3
|
+
|
|
4
|
+
import boto3
|
|
5
|
+
|
|
6
|
+
BlobBody = str | bytes | io.BytesIO | io.StringIO
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class StorageClientProtocol(Protocol):
|
|
10
|
+
def put_object(self, key: str, body: BlobBody) -> None: ...
|
|
11
|
+
|
|
12
|
+
def get_object_bytes(self, key: str) -> bytes: ...
|
|
13
|
+
|
|
14
|
+
def list_keys(self, prefix: str) -> list[str]: ...
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class S3Client:
|
|
18
|
+
def __init__(self, bucket_name: str):
|
|
19
|
+
self.bucket_name = bucket_name
|
|
20
|
+
self.client = boto3.client("s3")
|
|
21
|
+
|
|
22
|
+
def put_object(self, key: str, body: BlobBody) -> None:
|
|
23
|
+
if isinstance(body, (io.BytesIO, io.StringIO)):
|
|
24
|
+
data = body.getvalue()
|
|
25
|
+
else:
|
|
26
|
+
data = body
|
|
27
|
+
self.client.put_object(
|
|
28
|
+
Bucket=self.bucket_name,
|
|
29
|
+
Key=key,
|
|
30
|
+
Body=data,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def get_object_bytes(self, key: str) -> bytes:
|
|
34
|
+
response = self.client.get_object(Bucket=self.bucket_name, Key=key)
|
|
35
|
+
return response["Body"].read()
|
|
36
|
+
|
|
37
|
+
def list_keys(self, prefix: str) -> list[str]:
|
|
38
|
+
keys = []
|
|
39
|
+
response = self.client.list_objects_v2(Bucket=self.bucket_name, Prefix=prefix)
|
|
40
|
+
if "Contents" in response:
|
|
41
|
+
for obj in response["Contents"]:
|
|
42
|
+
keys.append(obj["Key"])
|
|
43
|
+
return keys
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class GcsClient:
|
|
47
|
+
def __init__(self, bucket_name: str):
|
|
48
|
+
self.bucket_name = bucket_name
|
|
49
|
+
try:
|
|
50
|
+
from google.cloud import storage
|
|
51
|
+
except ImportError:
|
|
52
|
+
raise ImportError(
|
|
53
|
+
"google-cloud-storage is required to use GCS with datablob. "
|
|
54
|
+
"Install it with 'pip install datablob[gcs]'"
|
|
55
|
+
)
|
|
56
|
+
self.client = storage.Client()
|
|
57
|
+
|
|
58
|
+
def put_object(self, key: str, body: BlobBody) -> None:
|
|
59
|
+
bucket = self.client.bucket(self.bucket_name)
|
|
60
|
+
blob = bucket.blob(key)
|
|
61
|
+
if isinstance(body, (io.BytesIO, io.StringIO)):
|
|
62
|
+
data = body.getvalue()
|
|
63
|
+
else:
|
|
64
|
+
data = body
|
|
65
|
+
blob.upload_from_string(data)
|
|
66
|
+
|
|
67
|
+
def get_object_bytes(self, key: str) -> bytes:
|
|
68
|
+
bucket = self.client.bucket(self.bucket_name)
|
|
69
|
+
blob = bucket.blob(key)
|
|
70
|
+
return blob.download_as_bytes()
|
|
71
|
+
|
|
72
|
+
def list_keys(self, prefix: str) -> list[str]:
|
|
73
|
+
keys = []
|
|
74
|
+
blobs = self.client.list_blobs(self.bucket_name, prefix=prefix)
|
|
75
|
+
for blob in blobs:
|
|
76
|
+
keys.append(blob.name)
|
|
77
|
+
return keys
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: datablob
|
|
3
|
+
Version: 0.10.0
|
|
4
|
+
Summary: Client for Updating a Simple Data Warehouse on Blob Storage
|
|
5
|
+
Home-page: https://github.com/gocarta/datablob
|
|
6
|
+
Download-URL: https://github.com/gocarta/datablob/tarball/download
|
|
7
|
+
Author: Daniel J. Dufour
|
|
8
|
+
Author-email: daniel.j.dufour@gmail.com
|
|
9
|
+
Keywords: data,python
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: boto3
|
|
17
|
+
Requires-Dist: geopandas
|
|
18
|
+
Requires-Dist: openpyxl
|
|
19
|
+
Requires-Dist: pandas
|
|
20
|
+
Requires-Dist: pyarrow
|
|
21
|
+
Requires-Dist: shapely
|
|
22
|
+
Requires-Dist: tzdata
|
|
23
|
+
Provides-Extra: gcs
|
|
24
|
+
Requires-Dist: google-cloud-storage; extra == "gcs"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: download-url
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: provides-extra
|
|
37
|
+
Dynamic: requires-dist
|
|
38
|
+
Dynamic: summary
|
|
39
|
+
|
|
40
|
+
# datablob
|
|
41
|
+
Client for Updating a Simple Data Warehouse on Blob Storage
|
|
42
|
+
|
|
43
|
+
## design philosophy
|
|
44
|
+
- optimize for simplicity and user friendliness
|
|
45
|
+
- storage is cheap (compared to compute)
|
|
46
|
+
- pre-compute as much as possible
|
|
47
|
+
- should work out of the box
|
|
48
|
+
- advanced configuration should be opt-in
|
|
49
|
+
- explicit is better than implicit
|
|
50
|
+
- straightforwardness over magic
|
|
51
|
+
|
|
52
|
+
## install
|
|
53
|
+
```sh
|
|
54
|
+
pip install datablob
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To include Google Cloud Storage (GCS) support:
|
|
58
|
+
```sh
|
|
59
|
+
pip install datablob[gcs]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## supported formats
|
|
63
|
+
- csv
|
|
64
|
+
- [geojson (points and polygons)](https://geojson.org/)
|
|
65
|
+
- json
|
|
66
|
+
- [json lines](https://jsonlines.org/)
|
|
67
|
+
- [parquet](https://parquet.apache.org/), including [geoparquet](https://geoparquet.org/)
|
|
68
|
+
- [shapefile (points and polygons)](https://en.wikipedia.org/wiki/Shapefile)
|
|
69
|
+
- tsv
|
|
70
|
+
- xlsx (Microsoft Excel)
|
|
71
|
+
|
|
72
|
+
## basic usage
|
|
73
|
+
```py
|
|
74
|
+
from datablob import DataBlobClient
|
|
75
|
+
|
|
76
|
+
# AWS S3 (default)
|
|
77
|
+
client = DataBlobClient(
|
|
78
|
+
bucket_name="example-test-bucket-123", bucket_path="prefix/to/dataportal"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Google Cloud Storage (GCS)
|
|
82
|
+
client = DataBlobClient(
|
|
83
|
+
bucket_name="example-gcs-bucket-123", bucket_path="prefix/to/dataportal", provider="gcs"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
rows = [
|
|
87
|
+
{
|
|
88
|
+
"name": "Random Building",
|
|
89
|
+
"@lat": 35.XXXXXX,
|
|
90
|
+
"@lon": -85.XXXXXX,
|
|
91
|
+
"@geom": { "type": "Polygon", "coordinates": [...] } // geojson geometry
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
client.update_dataset(
|
|
96
|
+
name="parking_lots", # name of the dataset, shouldn't include spaces or special characters
|
|
97
|
+
version="2", # version of the dataset. It's a string, so you can version as you like.
|
|
98
|
+
data=rows, # list of dictionaries. Each row is a dictionary.
|
|
99
|
+
latitude_key="@lat", # name of the latitude column
|
|
100
|
+
longitude_key="@lon", # name of the longitude column
|
|
101
|
+
polygon_key="@geom", # name of the column with a polygon geometry in it (if applicable)
|
|
102
|
+
xlsx=True # set to True to include an Excel file in output
|
|
103
|
+
)
|
|
104
|
+
# automatically creates the following files
|
|
105
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/meta.json
|
|
106
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.csv
|
|
107
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.points.geojson
|
|
108
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.polygons.geojson
|
|
109
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.json
|
|
110
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.jsonl
|
|
111
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.parquet
|
|
112
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.points.shp.zip
|
|
113
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.polygons.shp.zip
|
|
114
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.tsv
|
|
115
|
+
# s3://example-test-bucket-123/prefix/to/dataportal/buildings/v2/data.xlsx
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## advanced usage
|
|
119
|
+
```py
|
|
120
|
+
client.update_dataset(
|
|
121
|
+
name="fleet",
|
|
122
|
+
version="1",
|
|
123
|
+
data=rows,
|
|
124
|
+
column_names=["ID", "Make", "Model", "Year"] # specify column names and their order
|
|
125
|
+
description="List of Vehicles in Fleet",
|
|
126
|
+
xlsx=True,
|
|
127
|
+
xlsx_data_types=["Number", "Text", "Text", "Number"] # specify format of cell values in columns
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## examples
|
|
132
|
+
- [Clever Vehicle Locations](https://github.com/gocarta/dataops-clever-vehicle-locations)
|
|
133
|
+
- [OpenStreetMap Parking](https://github.com/gocarta/dataops-osm-parking)
|
|
134
|
+
- [Simple Bus Routes](https://github.com/gocarta/dataops-simple-bus-routes)
|
|
135
|
+
- [Simple Bus Stops](https://github.com/gocarta/dataops-simple-bus-stops)
|
|
136
|
+
- [TN NG911 Address Points](https://github.com/gocarta/dataops-tn-ng911-address-points)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
datablob/__init__.py,sha256=aaaKVCSGsMa-PlXBf4gA8VeC0odbE7AJ-Yvg7Trjiv4,19764
|
|
2
|
+
datablob/storage_client.py,sha256=Z5udB-m6d9e1sf1u_5AbZlCXW-mbM3Dnvjb7DEGfvVk,2440
|
|
3
|
+
datablob-0.10.0.dist-info/licenses/LICENSE,sha256=9Ofzc7m5lpUDN-jUGkopOcLZC3cl6brz1QhKInF60yg,7169
|
|
4
|
+
datablob-0.10.0.dist-info/METADATA,sha256=fU4bqGJobus3FAyL37-ZCIuSClL3LArCuVaqbT0w0YY,4853
|
|
5
|
+
datablob-0.10.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
6
|
+
datablob-0.10.0.dist-info/top_level.txt,sha256=trYKBOas9qK0gyjeAqOB4i8C0UNYvELioROXl7NfdWU,9
|
|
7
|
+
datablob-0.10.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
datablob
|