python-dwca-reader 0.16.2__py3-none-any.whl → 0.16.4__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.
- dwca/darwincore/build_dc_terms_list.py +8 -6
- dwca/darwincore/terms.py +171 -1
- dwca/darwincore/utils.py +1 -1
- dwca/descriptors.py +104 -81
- dwca/files.py +5 -5
- dwca/minibench.py +8 -6
- dwca/read.py +82 -41
- dwca/rows.py +85 -47
- dwca/star_record.py +27 -19
- dwca/test/helpers.py +1 -1
- dwca/test/test_datafile.py +8 -3
- dwca/test/test_descriptors.py +144 -90
- dwca/test/test_dwcareader.py +95 -43
- dwca/test/test_rows.py +8 -4
- dwca/test/test_star_record.py +117 -27
- dwca/vendor.py +1 -0
- dwca/version.py +1 -1
- {python_dwca_reader-0.16.2.dist-info → python_dwca_reader-0.16.4.dist-info}/METADATA +1 -1
- python_dwca_reader-0.16.4.dist-info/RECORD +28 -0
- python_dwca_reader-0.16.2.dist-info/RECORD +0 -28
- {python_dwca_reader-0.16.2.dist-info → python_dwca_reader-0.16.4.dist-info}/AUTHORS +0 -0
- {python_dwca_reader-0.16.2.dist-info → python_dwca_reader-0.16.4.dist-info}/LICENSE.txt +0 -0
- {python_dwca_reader-0.16.2.dist-info → python_dwca_reader-0.16.4.dist-info}/WHEEL +0 -0
- {python_dwca_reader-0.16.2.dist-info → python_dwca_reader-0.16.4.dist-info}/top_level.txt +0 -0
dwca/test/test_dwcareader.py
CHANGED
|
@@ -38,15 +38,23 @@ class TestPandasIntegration(unittest.TestCase):
|
|
|
38
38
|
# check types, headers and dimensions
|
|
39
39
|
assert isinstance(df, pd.DataFrame)
|
|
40
40
|
cols = df.columns.values.tolist()
|
|
41
|
-
assert cols == [
|
|
41
|
+
assert cols == [
|
|
42
|
+
"id",
|
|
43
|
+
"basisOfRecord",
|
|
44
|
+
"locality",
|
|
45
|
+
"family",
|
|
46
|
+
"scientificName",
|
|
47
|
+
]
|
|
42
48
|
assert df.shape == (2, 5) # Row/col counts are correct
|
|
43
49
|
|
|
44
50
|
# check content
|
|
45
51
|
assert df["basisOfRecord"].values.tolist() == ["Observation", "Observation"]
|
|
46
52
|
assert df["family"].values.tolist() == ["Tetraodontidae", "Osphronemidae"]
|
|
47
53
|
assert df["locality"].values.tolist() == ["Borneo", "Mumbai"]
|
|
48
|
-
assert df["scientificName"].values.tolist() ==
|
|
49
|
-
|
|
54
|
+
assert df["scientificName"].values.tolist() == [
|
|
55
|
+
"tetraodon fluviatilis",
|
|
56
|
+
"betta splendens",
|
|
57
|
+
]
|
|
50
58
|
|
|
51
59
|
def test_pd_read_chunked_default_value(self):
|
|
52
60
|
"""Pandas chuncksize should not be used with default values.
|
|
@@ -67,7 +75,6 @@ class TestPandasIntegration(unittest.TestCase):
|
|
|
67
75
|
for chunk in dwca.pd_read("occurrence.txt", chunksize=2):
|
|
68
76
|
assert isinstance(chunk, pd.DataFrame)
|
|
69
77
|
|
|
70
|
-
|
|
71
78
|
def test_pd_read_no_data_files(self):
|
|
72
79
|
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
73
80
|
with pytest.raises(NotADataFile):
|
|
@@ -107,7 +114,7 @@ class TestPandasIntegration(unittest.TestCase):
|
|
|
107
114
|
"""Ensure we don't split lines based on the x85 utf8 EOL char.
|
|
108
115
|
|
|
109
116
|
(only the EOL string specified in meta.xml should be used).
|
|
110
|
-
|
|
117
|
+
"""
|
|
111
118
|
with DwCAReader(sample_data_path("dwca-utf8-eol-test.zip")) as dwca:
|
|
112
119
|
df = dwca.pd_read("occurrence.txt")
|
|
113
120
|
# If line properly split => 64 columns.
|
|
@@ -116,7 +123,6 @@ class TestPandasIntegration(unittest.TestCase):
|
|
|
116
123
|
|
|
117
124
|
def test_pd_read_simple_csv(self):
|
|
118
125
|
with DwCAReader(sample_data_path("dwca-simple-csv.zip")) as dwca:
|
|
119
|
-
|
|
120
126
|
df = dwca.pd_read("0008333-160118175350007.csv")
|
|
121
127
|
# Ensure we get the correct number of rows
|
|
122
128
|
assert 3 == df.shape[0]
|
|
@@ -131,8 +137,12 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
131
137
|
|
|
132
138
|
def test_partial_default(self):
|
|
133
139
|
with DwCAReader(sample_data_path("dwca-partial-default.zip")) as dwca:
|
|
134
|
-
assert
|
|
135
|
-
|
|
140
|
+
assert (
|
|
141
|
+
dwca.rows[0].data[qn("country")] == "France"
|
|
142
|
+
) # Value comes from data file
|
|
143
|
+
assert (
|
|
144
|
+
dwca.rows[1].data[qn("country")] == "Belgium"
|
|
145
|
+
) # Value is field default
|
|
136
146
|
|
|
137
147
|
def test_core_file_location(self):
|
|
138
148
|
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
@@ -162,16 +172,25 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
162
172
|
assert len(dwca.extension_files) == 2
|
|
163
173
|
|
|
164
174
|
# Check the order of the metafile is respected + quick content check
|
|
165
|
-
assert
|
|
166
|
-
|
|
167
|
-
"
|
|
175
|
+
assert (
|
|
176
|
+
dwca.extension_files[0].file_descriptor.file_location
|
|
177
|
+
== "description.txt"
|
|
178
|
+
)
|
|
179
|
+
assert (
|
|
180
|
+
dwca.extension_files[1].file_descriptor.file_location
|
|
181
|
+
== "vernacularname.txt"
|
|
182
|
+
)
|
|
168
183
|
|
|
169
184
|
def test_get_descriptor_for(self):
|
|
170
185
|
with DwCAReader(sample_data_path("dwca-2extensions.zip")) as dwca:
|
|
171
186
|
# We can get a DataFileDescriptor for each data file
|
|
172
187
|
assert isinstance(dwca.get_descriptor_for("taxon.txt"), DataFileDescriptor)
|
|
173
|
-
assert isinstance(
|
|
174
|
-
|
|
188
|
+
assert isinstance(
|
|
189
|
+
dwca.get_descriptor_for("description.txt"), DataFileDescriptor
|
|
190
|
+
)
|
|
191
|
+
assert isinstance(
|
|
192
|
+
dwca.get_descriptor_for("vernacularname.txt"), DataFileDescriptor
|
|
193
|
+
)
|
|
175
194
|
|
|
176
195
|
# But NotADataFile exception for non-data files
|
|
177
196
|
with pytest.raises(NotADataFile):
|
|
@@ -194,17 +213,25 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
194
213
|
description_descriptor = dwca.get_descriptor_for("description.txt")
|
|
195
214
|
assert description_descriptor.file_location == "description.txt"
|
|
196
215
|
assert description_descriptor.file_encoding == "utf-8"
|
|
197
|
-
assert
|
|
216
|
+
assert (
|
|
217
|
+
description_descriptor.type
|
|
218
|
+
== "http://rs.gbif.org/terms/1.0/Description"
|
|
219
|
+
)
|
|
198
220
|
|
|
199
221
|
vernacular_descriptor = dwca.get_descriptor_for("vernacularname.txt")
|
|
200
222
|
assert vernacular_descriptor.file_location == "vernacularname.txt"
|
|
201
223
|
assert vernacular_descriptor.file_encoding == "utf-8"
|
|
202
|
-
assert
|
|
203
|
-
|
|
224
|
+
assert (
|
|
225
|
+
vernacular_descriptor.type
|
|
226
|
+
== "http://rs.gbif.org/terms/1.0/VernacularName"
|
|
227
|
+
)
|
|
204
228
|
|
|
205
229
|
# Also check we can get a DataFileDescriptor for a simple Archive (without metafile)
|
|
206
230
|
with DwCAReader(sample_data_path("dwca-simple-csv.zip")) as dwca:
|
|
207
|
-
assert isinstance(
|
|
231
|
+
assert isinstance(
|
|
232
|
+
dwca.get_descriptor_for("0008333-160118175350007.csv"),
|
|
233
|
+
DataFileDescriptor,
|
|
234
|
+
)
|
|
208
235
|
|
|
209
236
|
def test_open_included_file(self):
|
|
210
237
|
"""Ensure DwCAReader.open_included_file work as expected."""
|
|
@@ -259,8 +286,20 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
259
286
|
# We ignore the extension, so archive appears without
|
|
260
287
|
assert not dwca.use_extensions
|
|
261
288
|
|
|
289
|
+
def test_skip_metadata_option(self):
|
|
290
|
+
"""Ensure the skip_metadata option works as intended."""
|
|
291
|
+
# By default, metadata should be read and parsed
|
|
292
|
+
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
293
|
+
assert isinstance(dwca.metadata, ET.Element)
|
|
294
|
+
|
|
295
|
+
# ... but it can be skipped with the 'skip_metadata' option
|
|
296
|
+
with DwCAReader(
|
|
297
|
+
sample_data_path("dwca-simple-test-archive.zip"), skip_metadata=True
|
|
298
|
+
) as dwca:
|
|
299
|
+
assert dwca.metadata is None
|
|
300
|
+
|
|
262
301
|
def test_default_metadata_filename(self):
|
|
263
|
-
"""Ensure that metadata is found by
|
|
302
|
+
"""Ensure that metadata is found by its default name.
|
|
264
303
|
|
|
265
304
|
Metadata is named "EML.xml", but no metadata attribute in Metafile.
|
|
266
305
|
"""
|
|
@@ -323,7 +362,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
323
362
|
.find("surName")
|
|
324
363
|
.text
|
|
325
364
|
)
|
|
326
|
-
assert v ==
|
|
365
|
+
assert v == "Noé"
|
|
327
366
|
|
|
328
367
|
def test_explicit_encoding_metadata(self):
|
|
329
368
|
"""If the metadata file explicitly specifies encoding (<xml ...>), make sure it is used."""
|
|
@@ -336,7 +375,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
336
375
|
.find("surName")
|
|
337
376
|
.text
|
|
338
377
|
)
|
|
339
|
-
assert v ==
|
|
378
|
+
assert v == "Noé" # Is the accent properly interpreted?
|
|
340
379
|
|
|
341
380
|
def test_exception_invalid_simple_archives(self):
|
|
342
381
|
"""Ensure an exception is raised when simple archives can't be interpreted.
|
|
@@ -381,7 +420,9 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
381
420
|
# Ensure we get the correct number of rows
|
|
382
421
|
assert len(dwca.rows) == 3
|
|
383
422
|
# Ensure we can access arbitrary data
|
|
384
|
-
assert
|
|
423
|
+
assert (
|
|
424
|
+
dwca.get_corerow_by_position(1).data["decimallatitude"] == "-31.98333"
|
|
425
|
+
)
|
|
385
426
|
# Archive descriptor should be None
|
|
386
427
|
assert dwca.descriptor is None
|
|
387
428
|
# (scientific) metadata should be None
|
|
@@ -392,7 +433,9 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
392
433
|
# Ensure we get the correct number of rows
|
|
393
434
|
assert len(dwca.rows) == 3
|
|
394
435
|
# Ensure we can access arbitrary data
|
|
395
|
-
assert
|
|
436
|
+
assert (
|
|
437
|
+
dwca.get_corerow_by_position(1).data["decimallatitude"] == "-31.98333"
|
|
438
|
+
)
|
|
396
439
|
# Archive descriptor should be None
|
|
397
440
|
assert dwca.descriptor is None
|
|
398
441
|
# (scientific) metadata should be None
|
|
@@ -403,7 +446,9 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
403
446
|
# Ensure we get the correct number of rows
|
|
404
447
|
assert len(dwca.rows) == 3
|
|
405
448
|
# Ensure we can access arbitrary data
|
|
406
|
-
assert
|
|
449
|
+
assert (
|
|
450
|
+
dwca.get_corerow_by_position(1).data["decimallatitude"] == "-31.98333"
|
|
451
|
+
)
|
|
407
452
|
# Archive descriptor should be None
|
|
408
453
|
assert dwca.descriptor is None
|
|
409
454
|
# (scientific) metadata should be None
|
|
@@ -413,15 +458,17 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
413
458
|
"""Test Archive without metafile, but containing metadata.
|
|
414
459
|
|
|
415
460
|
Similar to test_simplecsv_archive, except the archive also contains a Metadata file named
|
|
416
|
-
EML.xml. This
|
|
461
|
+
EML.xml. This corresponds to the second case on page #2 of
|
|
417
462
|
http://www.gbif.org/resource/80639. The metadata file having the "standard name", it should
|
|
418
|
-
properly handled.
|
|
463
|
+
properly be handled.
|
|
419
464
|
"""
|
|
420
465
|
with DwCAReader(sample_data_path("dwca-simple-csv-eml.zip")) as dwca:
|
|
421
466
|
# Ensure we get the correct number of rows
|
|
422
467
|
assert len(dwca.rows) == 3
|
|
423
468
|
# Ensure we can access arbitrary data
|
|
424
|
-
assert
|
|
469
|
+
assert (
|
|
470
|
+
dwca.get_corerow_by_position(1).data["decimallatitude"] == "-31.98333"
|
|
471
|
+
)
|
|
425
472
|
# Archive descriptor should be None
|
|
426
473
|
assert dwca.descriptor is None
|
|
427
474
|
# (scientific) metadata is found
|
|
@@ -486,8 +533,10 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
486
533
|
assert "Row id:" in l_repr
|
|
487
534
|
assert "Reference extension rows: No" in l_repr
|
|
488
535
|
assert "Reference source metadata: No" in l_repr
|
|
489
|
-
assert
|
|
490
|
-
|
|
536
|
+
assert (
|
|
537
|
+
"http://rs.tdwg.org/dwc/terms/scientificName': 'tetraodon fluviatilis'"
|
|
538
|
+
in l_repr
|
|
539
|
+
)
|
|
491
540
|
|
|
492
541
|
with DwCAReader(sample_data_path("dwca-star-test-archive.zip")) as star_dwca:
|
|
493
542
|
l = star_dwca.rows[0]
|
|
@@ -499,7 +548,10 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
499
548
|
assert "Reference source metadata: No" in l_repr
|
|
500
549
|
|
|
501
550
|
extension_l_repr = str(l.extensions[0])
|
|
502
|
-
assert
|
|
551
|
+
assert (
|
|
552
|
+
"Rowtype: http://rs.gbif.org/terms/1.0/VernacularName"
|
|
553
|
+
in extension_l_repr
|
|
554
|
+
)
|
|
503
555
|
assert "Source: Extension file" in extension_l_repr
|
|
504
556
|
assert "Core row id: 1" in extension_l_repr
|
|
505
557
|
assert "ostrich" in extension_l_repr
|
|
@@ -723,7 +775,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
723
775
|
assert "Peliperdix" == r.data[genus_qn]
|
|
724
776
|
|
|
725
777
|
def test_get_inexistent_row(self):
|
|
726
|
-
"""
|
|
778
|
+
"""Ensure get_corerow_by_id() raises RowNotFound if we ask it an unexistent row."""
|
|
727
779
|
with DwCAReader(sample_data_path("dwca-ids.zip")) as dwca:
|
|
728
780
|
with pytest.raises(RowNotFound):
|
|
729
781
|
dwca.get_corerow_by_id(8000)
|
|
@@ -828,7 +880,6 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
828
880
|
sample_data_path("dwca-2extensions.zip"),
|
|
829
881
|
extensions_to_ignore="description.txt",
|
|
830
882
|
) as multi_dwca:
|
|
831
|
-
|
|
832
883
|
rows = list(multi_dwca)
|
|
833
884
|
|
|
834
885
|
# 3 vernacular names
|
|
@@ -856,7 +907,6 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
856
907
|
sample_data_path("dwca-2extensions.zip"),
|
|
857
908
|
extensions_to_ignore="helloworld.txt",
|
|
858
909
|
) as multi_dwca:
|
|
859
|
-
|
|
860
910
|
rows = list(multi_dwca)
|
|
861
911
|
|
|
862
912
|
# 3 vernacular names + 2 taxon descriptions
|
|
@@ -911,7 +961,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
911
961
|
"""Ensure we don't split lines based on the x85 utf8 EOL char.
|
|
912
962
|
|
|
913
963
|
(only the EOL string specified in meta.xml should be used).
|
|
914
|
-
|
|
964
|
+
"""
|
|
915
965
|
|
|
916
966
|
with DwCAReader(sample_data_path("dwca-utf8-eol-test.zip")) as dwca:
|
|
917
967
|
rows = dwca.rows
|
|
@@ -940,12 +990,14 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
940
990
|
assert isinstance(metadata, ET.Element)
|
|
941
991
|
|
|
942
992
|
# Assert we can read basic fields from EML:
|
|
943
|
-
assert
|
|
944
|
-
.find("
|
|
945
|
-
.find("
|
|
946
|
-
.find("
|
|
947
|
-
.
|
|
948
|
-
|
|
993
|
+
assert (
|
|
994
|
+
metadata.find("dataset")
|
|
995
|
+
.find("creator")
|
|
996
|
+
.find("individualName")
|
|
997
|
+
.find("givenName")
|
|
998
|
+
.text
|
|
999
|
+
== "Rob"
|
|
1000
|
+
)
|
|
949
1001
|
|
|
950
1002
|
def test_row_source_metadata(self):
|
|
951
1003
|
# For normal DwC-A, it should always be None (NO source data
|
|
@@ -979,7 +1031,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
979
1031
|
assert v == "en"
|
|
980
1032
|
|
|
981
1033
|
def test_unknown_archive_format(self):
|
|
982
|
-
"""
|
|
1034
|
+
"""Ensure InvalidArchive is raised when passed file is not a .zip nor .tgz."""
|
|
983
1035
|
invalid_origin_file = tempfile.NamedTemporaryFile(delete=False)
|
|
984
1036
|
|
|
985
1037
|
with pytest.raises(InvalidArchive):
|
|
@@ -989,7 +1041,7 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
989
1041
|
invalid_origin_file.close()
|
|
990
1042
|
|
|
991
1043
|
def test_orphaned_extension_rows_noext(self):
|
|
992
|
-
"""
|
|
1044
|
+
"""orphaned_extension_rows returns {} when there's no extensions."""
|
|
993
1045
|
# Archive without extensions: we expect {}
|
|
994
1046
|
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
995
1047
|
assert {} == dwca.orphaned_extension_rows()
|
|
@@ -1005,8 +1057,8 @@ class TestDwCAReader(unittest.TestCase):
|
|
|
1005
1057
|
# Archive with extensions and orphaned rows
|
|
1006
1058
|
with DwCAReader(sample_data_path("dwca-orphaned-rows.zip")) as dwca:
|
|
1007
1059
|
expected = {
|
|
1008
|
-
"description.txt": {
|
|
1009
|
-
"vernacularname.txt": {
|
|
1060
|
+
"description.txt": {"5": [3, 4], "6": [5]},
|
|
1061
|
+
"vernacularname.txt": {"7": [4]},
|
|
1010
1062
|
}
|
|
1011
1063
|
assert expected == dwca.orphaned_extension_rows()
|
|
1012
1064
|
|
dwca/test/test_rows.py
CHANGED
|
@@ -7,7 +7,9 @@ from .helpers import sample_data_path
|
|
|
7
7
|
|
|
8
8
|
class TestUtils(unittest.TestCase):
|
|
9
9
|
def test_csv_line_to_fields(self):
|
|
10
|
-
raw_fields = csv_line_to_fields(
|
|
10
|
+
raw_fields = csv_line_to_fields(
|
|
11
|
+
'field 1,"field 2, with comma",field 3', "\n", ",", '"'
|
|
12
|
+
)
|
|
11
13
|
assert raw_fields[0] == "field 1"
|
|
12
14
|
assert raw_fields[1] == "field 2, with comma"
|
|
13
15
|
assert raw_fields[2] == "field 3"
|
|
@@ -16,7 +18,10 @@ class TestUtils(unittest.TestCase):
|
|
|
16
18
|
class TestCoreRow(unittest.TestCase):
|
|
17
19
|
def test_position(self):
|
|
18
20
|
# Test with archives with and without headers:
|
|
19
|
-
archives_to_test = (
|
|
21
|
+
archives_to_test = (
|
|
22
|
+
sample_data_path("dwca-simple-test-archive.zip"),
|
|
23
|
+
sample_data_path("dwca-noheaders-1.zip"),
|
|
24
|
+
)
|
|
20
25
|
|
|
21
26
|
for archive_path in archives_to_test:
|
|
22
27
|
with DwCAReader(archive_path) as dwca:
|
|
@@ -26,8 +31,7 @@ class TestCoreRow(unittest.TestCase):
|
|
|
26
31
|
|
|
27
32
|
class TestExtensionRow(unittest.TestCase):
|
|
28
33
|
def test_position(self):
|
|
29
|
-
|
|
30
|
-
with DwCAReader(sample_data_path('dwca-2extensions.zip')) as dwca:
|
|
34
|
+
with DwCAReader(sample_data_path("dwca-2extensions.zip")) as dwca:
|
|
31
35
|
ostrich = dwca.rows[0]
|
|
32
36
|
|
|
33
37
|
description_first_line = ostrich.extensions[0]
|
dwca/test/test_star_record.py
CHANGED
|
@@ -4,51 +4,141 @@ from dwca.star_record import StarRecordIterator
|
|
|
4
4
|
from .helpers import sample_data_path
|
|
5
5
|
import unittest
|
|
6
6
|
|
|
7
|
-
class TestStarRecordIterator(unittest.TestCase):
|
|
8
7
|
|
|
8
|
+
class TestStarRecordIterator(unittest.TestCase):
|
|
9
9
|
def test_inner_join(self):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
expected_inner_join = frozenset(
|
|
11
|
+
{
|
|
12
|
+
frozenset(
|
|
13
|
+
{
|
|
14
|
+
("1", 0, "Description"),
|
|
15
|
+
("1", 0, "Taxon"),
|
|
16
|
+
("1", 0, "VernacularName"),
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
frozenset(
|
|
20
|
+
{
|
|
21
|
+
("1", 0, "Description"),
|
|
22
|
+
("1", 0, "Taxon"),
|
|
23
|
+
("1", 1, "VernacularName"),
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
frozenset(
|
|
27
|
+
{
|
|
28
|
+
("1", 0, "Description"),
|
|
29
|
+
("1", 0, "Taxon"),
|
|
30
|
+
("1", 2, "VernacularName"),
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
frozenset(
|
|
34
|
+
{
|
|
35
|
+
("1", 1, "Description"),
|
|
36
|
+
("1", 0, "Taxon"),
|
|
37
|
+
("1", 0, "VernacularName"),
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
frozenset(
|
|
41
|
+
{
|
|
42
|
+
("1", 1, "Description"),
|
|
43
|
+
("1", 0, "Taxon"),
|
|
44
|
+
("1", 1, "VernacularName"),
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
frozenset(
|
|
48
|
+
{
|
|
49
|
+
("1", 1, "Description"),
|
|
50
|
+
("1", 0, "Taxon"),
|
|
51
|
+
("1", 2, "VernacularName"),
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
}
|
|
55
|
+
)
|
|
19
56
|
|
|
20
57
|
with DwCAReader(sample_data_path("dwca-2extensions.zip")) as dwca:
|
|
21
|
-
star_records = StarRecordIterator(
|
|
58
|
+
star_records = StarRecordIterator(
|
|
59
|
+
dwca.extension_files + [dwca.core_file], how="inner"
|
|
60
|
+
)
|
|
22
61
|
stars = []
|
|
23
62
|
for star_record in star_records:
|
|
24
63
|
rows = []
|
|
25
64
|
for row in star_record:
|
|
26
|
-
rows.append(
|
|
65
|
+
rows.append(
|
|
66
|
+
(
|
|
67
|
+
row.id if isinstance(row, CoreRow) else row.core_id,
|
|
68
|
+
row.position,
|
|
69
|
+
row.rowtype.split("/")[-1],
|
|
70
|
+
)
|
|
71
|
+
)
|
|
27
72
|
stars.append(frozenset(rows))
|
|
28
73
|
|
|
29
74
|
assert frozenset(stars) == expected_inner_join
|
|
30
|
-
|
|
31
|
-
def test_outer_join(self):
|
|
32
75
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
76
|
+
def test_outer_join(self):
|
|
77
|
+
expected_outer_join = frozenset(
|
|
78
|
+
{
|
|
79
|
+
frozenset({("4", 2, "Description"), ("4", 3, "Taxon")}),
|
|
80
|
+
frozenset(
|
|
81
|
+
{
|
|
82
|
+
("1", 0, "Description"),
|
|
83
|
+
("1", 0, "Taxon"),
|
|
84
|
+
("1", 0, "VernacularName"),
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
frozenset(
|
|
88
|
+
{
|
|
89
|
+
("1", 0, "Description"),
|
|
90
|
+
("1", 0, "Taxon"),
|
|
91
|
+
("1", 1, "VernacularName"),
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
frozenset(
|
|
95
|
+
{
|
|
96
|
+
("1", 0, "Description"),
|
|
97
|
+
("1", 0, "Taxon"),
|
|
98
|
+
("1", 2, "VernacularName"),
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
frozenset(
|
|
102
|
+
{
|
|
103
|
+
("1", 1, "Description"),
|
|
104
|
+
("1", 0, "Taxon"),
|
|
105
|
+
("1", 0, "VernacularName"),
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
frozenset(
|
|
109
|
+
{
|
|
110
|
+
("1", 1, "Description"),
|
|
111
|
+
("1", 0, "Taxon"),
|
|
112
|
+
("1", 1, "VernacularName"),
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
frozenset(
|
|
116
|
+
{
|
|
117
|
+
("1", 1, "Description"),
|
|
118
|
+
("1", 0, "Taxon"),
|
|
119
|
+
("1", 2, "VernacularName"),
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
frozenset({("3", 2, "Taxon")}),
|
|
123
|
+
frozenset({("2", 1, "Taxon"), ("2", 3, "VernacularName")}),
|
|
124
|
+
}
|
|
125
|
+
)
|
|
44
126
|
|
|
45
127
|
with DwCAReader(sample_data_path("dwca-2extensions.zip")) as dwca:
|
|
46
|
-
star_records = StarRecordIterator(
|
|
128
|
+
star_records = StarRecordIterator(
|
|
129
|
+
dwca.extension_files + [dwca.core_file], how="outer"
|
|
130
|
+
)
|
|
47
131
|
stars = []
|
|
48
132
|
for star_record in star_records:
|
|
49
133
|
rows = []
|
|
50
134
|
for row in star_record:
|
|
51
|
-
rows.append(
|
|
135
|
+
rows.append(
|
|
136
|
+
(
|
|
137
|
+
row.id if isinstance(row, CoreRow) else row.core_id,
|
|
138
|
+
row.position,
|
|
139
|
+
row.rowtype.split("/")[-1],
|
|
140
|
+
)
|
|
141
|
+
)
|
|
52
142
|
stars.append(frozenset(rows))
|
|
53
143
|
|
|
54
144
|
assert frozenset(stars) == expected_outer_join
|
dwca/vendor.py
CHANGED
dwca/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ =
|
|
1
|
+
__version__ = "0.16.4"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-dwca-reader
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.4
|
|
4
4
|
Summary: A simple Python package to read Darwin Core Archive (DwC-A) files.
|
|
5
5
|
Home-page: https://github.com/BelgianBiodiversityPlatform/python-dwca-reader
|
|
6
6
|
Author: Nicolas Noé - Belgian Biodiversity Platform
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
dwca/__init__.py,sha256=Jzb_RfgvXCrm_SQ4AfeGVi1N36YybxnM5mpyxrnihgI,33
|
|
2
|
+
dwca/descriptors.py,sha256=QxpCKBBT1yftkGA9oHq45eCNney5Xtq898McLuwqSxo,12817
|
|
3
|
+
dwca/exceptions.py,sha256=3TyIelM2rrnFPH97isxQGv0ICRLebT_bXMnXOhuIg30,380
|
|
4
|
+
dwca/files.py,sha256=7EIDxNyqrf8ef9Wl71iDl1jap8X5n6BajD3BlPnamcs,6542
|
|
5
|
+
dwca/helpers.py,sha256=3o6L4yTqtVIsFEl9PMpDoyqITKXvS-ErTGVvjWIlFZA,245
|
|
6
|
+
dwca/minibench.py,sha256=6hP4Z-kAz-i57QUdipLvj7D_BCq2YW9wndyg3eW6e9A,1537
|
|
7
|
+
dwca/read.py,sha256=fQce6xOBmzzWv7AMlya2hUNO_Jpgq8bIvwGqfbPN5c0,22814
|
|
8
|
+
dwca/rows.py,sha256=hxc5k27ZFFSaiVsqkIZXJT3D6jOuo4wThIEl2LBd_JE,9392
|
|
9
|
+
dwca/star_record.py,sha256=CXsKLc9Hb6VMYGWAd1p93mR48VExPxLeUyh0k5alo-E,2804
|
|
10
|
+
dwca/vendor.py,sha256=521cjnCVI-tsomTcc7B-cS6F79wQmqU8fai47zviv0o,99
|
|
11
|
+
dwca/version.py,sha256=v0NTmSx9E_r4wWkO-UdvuH1fI3XtgjoFi5IbuPS9pjY,23
|
|
12
|
+
dwca/darwincore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
dwca/darwincore/build_dc_terms_list.py,sha256=3ZTOM8vvKpQR5H-LTDxeo3JoSpuu79OtyWsw4WDfr0A,1388
|
|
14
|
+
dwca/darwincore/terms.py,sha256=Q3ieJp-Fjf3Vrx4qVqhn4NOqiLo6BuxyOluk2cYwzhc,8772
|
|
15
|
+
dwca/darwincore/utils.py,sha256=7k_XNIBuykHWTRGyZ_BWLjw2cP-jmo9Y-78FEl3dQz4,845
|
|
16
|
+
dwca/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
dwca/test/helpers.py,sha256=1FB4lDV9gtcz6yHvLTAMiWFH-_YLmaMuBiUYYd47T1o,156
|
|
18
|
+
dwca/test/test_datafile.py,sha256=UGBJg5ZIe21OkeaMKhSRbxZLgY_fmDE24_tEJkrS1ps,7152
|
|
19
|
+
dwca/test/test_descriptors.py,sha256=md0NZo9-b-NoOIG752Yqq6VvNMCNFG_MfL0xtzRPo4o,25977
|
|
20
|
+
dwca/test/test_dwcareader.py,sha256=AgimWJFjW3Mrswu8n9EO7GqRpcY6CkDv4mpjCTXIcSI,44848
|
|
21
|
+
dwca/test/test_rows.py,sha256=PbR6EDpCM9NneDAyYjyoHlO8gaue-FLFtIXgsdWA5NU,1693
|
|
22
|
+
dwca/test/test_star_record.py,sha256=5YYVdjIOy8QNuclS7fareApTIvqJuDmNLt4GEak7Z2I,4906
|
|
23
|
+
python_dwca_reader-0.16.4.dist-info/AUTHORS,sha256=5qn6Kxn1rBj2J7M4LHSwQiQHhVOs5ejilGssEmEhct4,528
|
|
24
|
+
python_dwca_reader-0.16.4.dist-info/LICENSE.txt,sha256=2Rc1BeoBQjG30Abb8zL34Wd9MrxVBRftyXiltvK2hJg,1506
|
|
25
|
+
python_dwca_reader-0.16.4.dist-info/METADATA,sha256=j1gPCRXiwZha7tPu4VvvxO0GSUrhIgfuDd_9O-VrznU,1551
|
|
26
|
+
python_dwca_reader-0.16.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
27
|
+
python_dwca_reader-0.16.4.dist-info/top_level.txt,sha256=wUMEHbrB4ck4vyfybf4X2bv-HLgIU8uen_C5bMw8P1E,5
|
|
28
|
+
python_dwca_reader-0.16.4.dist-info/RECORD,,
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
dwca/__init__.py,sha256=Jzb_RfgvXCrm_SQ4AfeGVi1N36YybxnM5mpyxrnihgI,33
|
|
2
|
-
dwca/descriptors.py,sha256=tjbS8ul_FMUP_frCBG4q635Ui3htEy7ffJEXN9CtSk0,13118
|
|
3
|
-
dwca/exceptions.py,sha256=3TyIelM2rrnFPH97isxQGv0ICRLebT_bXMnXOhuIg30,380
|
|
4
|
-
dwca/files.py,sha256=EgOTbzyyH5mCeILqOc30wL9FdjXklHgosf0JKtSZnBU,6535
|
|
5
|
-
dwca/helpers.py,sha256=3o6L4yTqtVIsFEl9PMpDoyqITKXvS-ErTGVvjWIlFZA,245
|
|
6
|
-
dwca/minibench.py,sha256=9_kXsT4bKjxgb5NtYBVgePp1yFK8KkH7h5okxh3XVBY,1539
|
|
7
|
-
dwca/read.py,sha256=5ITKQYyvPzL7LUzefgT6YVThxYg_iFGsdG80zkeV09Q,22228
|
|
8
|
-
dwca/rows.py,sha256=BW81_eY4beCEygGzlfhoKyi5RFy2KIRAaG1dME0rXx8,9111
|
|
9
|
-
dwca/star_record.py,sha256=swNQIv5jeBRDxKzW_t5FVJ9LdvaSNINF17sWESisx2k,2763
|
|
10
|
-
dwca/vendor.py,sha256=Qcg1I0qh4Q-nZ_n5zui7loDOq59QsxFHKa2ywmaRcpA,98
|
|
11
|
-
dwca/version.py,sha256=zA3Is963yicS_tJKC2SjI8Arr1-HiEa3ICYj1uj8QJ0,23
|
|
12
|
-
dwca/darwincore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
dwca/darwincore/build_dc_terms_list.py,sha256=F-MT5UAJYtDnmz0-SbD7rInypQak-u56hoCSXICaBjQ,1464
|
|
14
|
-
dwca/darwincore/terms.py,sha256=SnNnWHzpe99FndzByVzTt8xrOOi43MYvEMZunoUL95Q,8093
|
|
15
|
-
dwca/darwincore/utils.py,sha256=7fA2mI1Pghz_zW5FP9D8e38iZ2AK2XrrqdxPBCrd8eE,845
|
|
16
|
-
dwca/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
dwca/test/helpers.py,sha256=_ymEel-HudB9g8DhwsKqVXh_KnXFiYaHaDV1u9bjBvk,156
|
|
18
|
-
dwca/test/test_datafile.py,sha256=LKYk_jZavahR5tZmA9v3tabHnw8Z0HgBPqOnDVLsIXE,7073
|
|
19
|
-
dwca/test/test_descriptors.py,sha256=t8M8buEHAbEwjbiAsEuZgIiF1kSpidzbqG9hti-KipA,25888
|
|
20
|
-
dwca/test/test_dwcareader.py,sha256=0EiSUYNnjk0pRGLBY4XICbBeEbiuutwR-rDW3DkwCcY,43642
|
|
21
|
-
dwca/test/test_rows.py,sha256=J125mYdVu9zxkauOzaV2DLgSldLBPJwKNDkMuPwWuRc,1637
|
|
22
|
-
dwca/test/test_star_record.py,sha256=Y9nm1WlN4JB6xcmEviyPEQPrvUeP5O4wpbbWI1BAVGQ,2829
|
|
23
|
-
python_dwca_reader-0.16.2.dist-info/AUTHORS,sha256=5qn6Kxn1rBj2J7M4LHSwQiQHhVOs5ejilGssEmEhct4,528
|
|
24
|
-
python_dwca_reader-0.16.2.dist-info/LICENSE.txt,sha256=2Rc1BeoBQjG30Abb8zL34Wd9MrxVBRftyXiltvK2hJg,1506
|
|
25
|
-
python_dwca_reader-0.16.2.dist-info/METADATA,sha256=lxC6sFUMF1iYbzrp2Pjemru7FwLkPYr8rRE1fzZzzz4,1551
|
|
26
|
-
python_dwca_reader-0.16.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
27
|
-
python_dwca_reader-0.16.2.dist-info/top_level.txt,sha256=wUMEHbrB4ck4vyfybf4X2bv-HLgIU8uen_C5bMw8P1E,5
|
|
28
|
-
python_dwca_reader-0.16.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|