fairspec-metadata 0.0.0.dev0__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.
- fairspec_metadata/__init__.py +504 -0
- fairspec_metadata/actions/column/create.py +175 -0
- fairspec_metadata/actions/column/create_spec.py +83 -0
- fairspec_metadata/actions/column/property.py +28 -0
- fairspec_metadata/actions/column/property_spec.py +29 -0
- fairspec_metadata/actions/data_schema/assert_.py +16 -0
- fairspec_metadata/actions/data_schema/load.py +11 -0
- fairspec_metadata/actions/data_schema/resolve.py +16 -0
- fairspec_metadata/actions/data_schema/save.py +22 -0
- fairspec_metadata/actions/data_schema/validate.py +46 -0
- fairspec_metadata/actions/dataset/assert_.py +16 -0
- fairspec_metadata/actions/dataset/denormalize.py +16 -0
- fairspec_metadata/actions/dataset/fixtures/dataset-invalid.json +8 -0
- fairspec_metadata/actions/dataset/fixtures/dataset.json +66 -0
- fairspec_metadata/actions/dataset/fixtures/schema.json +12 -0
- fairspec_metadata/actions/dataset/fixtures/table.csv +3 -0
- fairspec_metadata/actions/dataset/load.py +13 -0
- fairspec_metadata/actions/dataset/normalize.py +16 -0
- fairspec_metadata/actions/dataset/save.py +30 -0
- fairspec_metadata/actions/dataset/save_spec.py +102 -0
- fairspec_metadata/actions/dataset/validate.py +77 -0
- fairspec_metadata/actions/dataset/validate_spec.py +30 -0
- fairspec_metadata/actions/descriptor/copy.py +9 -0
- fairspec_metadata/actions/descriptor/fixtures/schema.json +1 -0
- fairspec_metadata/actions/descriptor/general.py +7 -0
- fairspec_metadata/actions/descriptor/load.py +47 -0
- fairspec_metadata/actions/descriptor/load_spec.py +40 -0
- fairspec_metadata/actions/descriptor/parse.py +16 -0
- fairspec_metadata/actions/descriptor/save.py +19 -0
- fairspec_metadata/actions/descriptor/save_spec.py +47 -0
- fairspec_metadata/actions/descriptor/stringify.py +9 -0
- fairspec_metadata/actions/descriptor/validate.py +31 -0
- fairspec_metadata/actions/file_dialect/assert_.py +20 -0
- fairspec_metadata/actions/file_dialect/infer.py +35 -0
- fairspec_metadata/actions/file_dialect/infer_spec.py +44 -0
- fairspec_metadata/actions/file_dialect/load.py +15 -0
- fairspec_metadata/actions/file_dialect/resolve.py +20 -0
- fairspec_metadata/actions/file_dialect/save.py +21 -0
- fairspec_metadata/actions/file_dialect/support.py +41 -0
- fairspec_metadata/actions/file_dialect/validate.py +49 -0
- fairspec_metadata/actions/json/inspect.py +59 -0
- fairspec_metadata/actions/json/inspect_spec.py +49 -0
- fairspec_metadata/actions/json_schema/assert_.py +21 -0
- fairspec_metadata/actions/json_schema/inspect.py +43 -0
- fairspec_metadata/actions/json_schema/inspect_spec.py +68 -0
- fairspec_metadata/actions/json_schema/load.py +23 -0
- fairspec_metadata/actions/json_schema/resolve.py +16 -0
- fairspec_metadata/actions/json_schema/save.py +13 -0
- fairspec_metadata/actions/path/basepath.py +37 -0
- fairspec_metadata/actions/path/basepath_spec.py +59 -0
- fairspec_metadata/actions/path/denormalize.py +43 -0
- fairspec_metadata/actions/path/denormalize_spec.py +56 -0
- fairspec_metadata/actions/path/general.py +71 -0
- fairspec_metadata/actions/path/general_spec.py +167 -0
- fairspec_metadata/actions/path/normalize.py +55 -0
- fairspec_metadata/actions/path/normalize_spec.py +76 -0
- fairspec_metadata/actions/profile/assert_.py +37 -0
- fairspec_metadata/actions/profile/assert_spec.py +89 -0
- fairspec_metadata/actions/profile/load.py +19 -0
- fairspec_metadata/actions/profile/registry.py +51 -0
- fairspec_metadata/actions/report/create.py +14 -0
- fairspec_metadata/actions/report/create_spec.py +28 -0
- fairspec_metadata/actions/resource/data.py +50 -0
- fairspec_metadata/actions/resource/data_spec.py +64 -0
- fairspec_metadata/actions/resource/denormalize.py +30 -0
- fairspec_metadata/actions/resource/general.py +19 -0
- fairspec_metadata/actions/resource/infer.py +23 -0
- fairspec_metadata/actions/resource/infer_spec.py +33 -0
- fairspec_metadata/actions/resource/normalize.py +30 -0
- fairspec_metadata/actions/table_schema/assert_.py +16 -0
- fairspec_metadata/actions/table_schema/column.py +24 -0
- fairspec_metadata/actions/table_schema/column_spec.py +55 -0
- fairspec_metadata/actions/table_schema/load.py +11 -0
- fairspec_metadata/actions/table_schema/resolve.py +17 -0
- fairspec_metadata/actions/table_schema/save.py +21 -0
- fairspec_metadata/actions/table_schema/validate.py +47 -0
- fairspec_metadata/actions/table_schema/validate_spec.py +45 -0
- fairspec_metadata/models/base.py +5 -0
- fairspec_metadata/models/catalog.py +20 -0
- fairspec_metadata/models/column/array.py +65 -0
- fairspec_metadata/models/column/base.py +41 -0
- fairspec_metadata/models/column/base64.py +15 -0
- fairspec_metadata/models/column/boolean.py +57 -0
- fairspec_metadata/models/column/categorical.py +52 -0
- fairspec_metadata/models/column/column.py +127 -0
- fairspec_metadata/models/column/date.py +21 -0
- fairspec_metadata/models/column/date_time.py +21 -0
- fairspec_metadata/models/column/decimal.py +54 -0
- fairspec_metadata/models/column/duration.py +15 -0
- fairspec_metadata/models/column/email.py +15 -0
- fairspec_metadata/models/column/geojson.py +15 -0
- fairspec_metadata/models/column/hex.py +15 -0
- fairspec_metadata/models/column/integer.py +83 -0
- fairspec_metadata/models/column/list.py +48 -0
- fairspec_metadata/models/column/number.py +90 -0
- fairspec_metadata/models/column/object.py +69 -0
- fairspec_metadata/models/column/string.py +66 -0
- fairspec_metadata/models/column/time.py +21 -0
- fairspec_metadata/models/column/topojson.py +15 -0
- fairspec_metadata/models/column/unknown.py +43 -0
- fairspec_metadata/models/column/url.py +15 -0
- fairspec_metadata/models/column/wkb.py +15 -0
- fairspec_metadata/models/column/wkt.py +15 -0
- fairspec_metadata/models/data.py +16 -0
- fairspec_metadata/models/data_schema.py +11 -0
- fairspec_metadata/models/datacite/alternate_identifier.py +24 -0
- fairspec_metadata/models/datacite/common.py +187 -0
- fairspec_metadata/models/datacite/content_type.py +17 -0
- fairspec_metadata/models/datacite/contributor.py +22 -0
- fairspec_metadata/models/datacite/creator.py +79 -0
- fairspec_metadata/models/datacite/datacite.py +117 -0
- fairspec_metadata/models/datacite/date.py +35 -0
- fairspec_metadata/models/datacite/description.py +30 -0
- fairspec_metadata/models/datacite/formats.py +12 -0
- fairspec_metadata/models/datacite/funding_reference.py +41 -0
- fairspec_metadata/models/datacite/geo_location.py +67 -0
- fairspec_metadata/models/datacite/identifier.py +29 -0
- fairspec_metadata/models/datacite/language.py +12 -0
- fairspec_metadata/models/datacite/publication_year.py +13 -0
- fairspec_metadata/models/datacite/publisher.py +27 -0
- fairspec_metadata/models/datacite/related_identifier.py +61 -0
- fairspec_metadata/models/datacite/related_item.py +96 -0
- fairspec_metadata/models/datacite/rights.py +40 -0
- fairspec_metadata/models/datacite/size.py +12 -0
- fairspec_metadata/models/datacite/subject.py +41 -0
- fairspec_metadata/models/datacite/title.py +30 -0
- fairspec_metadata/models/datacite/version.py +12 -0
- fairspec_metadata/models/dataset.py +34 -0
- fairspec_metadata/models/descriptor.py +5 -0
- fairspec_metadata/models/error/base.py +13 -0
- fairspec_metadata/models/error/cell.py +118 -0
- fairspec_metadata/models/error/column.py +28 -0
- fairspec_metadata/models/error/data.py +13 -0
- fairspec_metadata/models/error/error.py +11 -0
- fairspec_metadata/models/error/file.py +28 -0
- fairspec_metadata/models/error/foreign_key.py +18 -0
- fairspec_metadata/models/error/metadata.py +13 -0
- fairspec_metadata/models/error/resource.py +31 -0
- fairspec_metadata/models/error/row.py +29 -0
- fairspec_metadata/models/error/table.py +10 -0
- fairspec_metadata/models/exception.py +14 -0
- fairspec_metadata/models/file_dialect/arrow.py +9 -0
- fairspec_metadata/models/file_dialect/base.py +23 -0
- fairspec_metadata/models/file_dialect/common.py +24 -0
- fairspec_metadata/models/file_dialect/csv.py +29 -0
- fairspec_metadata/models/file_dialect/file_dialect.py +30 -0
- fairspec_metadata/models/file_dialect/json.py +25 -0
- fairspec_metadata/models/file_dialect/jsonl.py +23 -0
- fairspec_metadata/models/file_dialect/ods.py +25 -0
- fairspec_metadata/models/file_dialect/parquet.py +9 -0
- fairspec_metadata/models/file_dialect/sqlite.py +11 -0
- fairspec_metadata/models/file_dialect/tsv.py +25 -0
- fairspec_metadata/models/file_dialect/unknown.py +7 -0
- fairspec_metadata/models/file_dialect/xlsx.py +25 -0
- fairspec_metadata/models/foreign_key.py +22 -0
- fairspec_metadata/models/integrity.py +17 -0
- fairspec_metadata/models/json_schema.py +5 -0
- fairspec_metadata/models/path.py +16 -0
- fairspec_metadata/models/profile.py +27 -0
- fairspec_metadata/models/report.py +13 -0
- fairspec_metadata/models/resource.py +49 -0
- fairspec_metadata/models/table_schema.py +79 -0
- fairspec_metadata/models/unique_key.py +13 -0
- fairspec_metadata/plugin.py +56 -0
- fairspec_metadata/profiles/catalog.json +27 -0
- fairspec_metadata/profiles/data-schema.json +23 -0
- fairspec_metadata/profiles/dataset.json +710 -0
- fairspec_metadata/profiles/file-dialect.json +216 -0
- fairspec_metadata/profiles/table-schema.json +715 -0
- fairspec_metadata/py.typed +0 -0
- fairspec_metadata/settings.py +1 -0
- fairspec_metadata-0.0.0.dev0.dist-info/METADATA +21 -0
- fairspec_metadata-0.0.0.dev0.dist-info/RECORD +174 -0
- fairspec_metadata-0.0.0.dev0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
from .actions.column.create import create_column_from_property
|
|
2
|
+
from .actions.column.property import (
|
|
3
|
+
get_base_property_type,
|
|
4
|
+
get_column_properties,
|
|
5
|
+
get_is_nullable_property_type,
|
|
6
|
+
)
|
|
7
|
+
from .actions.data_schema.assert_ import assert_data_schema
|
|
8
|
+
from .actions.data_schema.load import load_data_schema
|
|
9
|
+
from .actions.data_schema.resolve import resolve_data_schema
|
|
10
|
+
from .actions.data_schema.save import save_data_schema
|
|
11
|
+
from .actions.data_schema.validate import (
|
|
12
|
+
DataSchemaValidationResult,
|
|
13
|
+
validate_data_schema,
|
|
14
|
+
)
|
|
15
|
+
from .actions.dataset.assert_ import assert_dataset
|
|
16
|
+
from .actions.dataset.denormalize import denormalize_dataset
|
|
17
|
+
from .actions.dataset.load import load_dataset_descriptor
|
|
18
|
+
from .actions.dataset.normalize import normalize_dataset
|
|
19
|
+
from .actions.dataset.save import save_dataset_descriptor
|
|
20
|
+
from .actions.dataset.validate import (
|
|
21
|
+
DatasetValidationResult,
|
|
22
|
+
validate_dataset_descriptor,
|
|
23
|
+
)
|
|
24
|
+
from .actions.descriptor.copy import copy_descriptor
|
|
25
|
+
from .actions.descriptor.general import get_is_descriptor
|
|
26
|
+
from .actions.descriptor.load import load_descriptor
|
|
27
|
+
from .actions.descriptor.parse import parse_descriptor
|
|
28
|
+
from .actions.descriptor.save import save_descriptor
|
|
29
|
+
from .actions.descriptor.stringify import stringify_descriptor
|
|
30
|
+
from .actions.descriptor.validate import validate_descriptor
|
|
31
|
+
from .actions.file_dialect.assert_ import assert_file_dialect
|
|
32
|
+
from .actions.file_dialect.infer import infer_file_dialect_format
|
|
33
|
+
from .actions.file_dialect.load import load_file_dialect
|
|
34
|
+
from .actions.file_dialect.resolve import resolve_file_dialect
|
|
35
|
+
from .actions.file_dialect.save import save_file_dialect
|
|
36
|
+
from .actions.file_dialect.support import get_supported_file_dialect
|
|
37
|
+
from .actions.file_dialect.validate import (
|
|
38
|
+
FileDialectValidationResult,
|
|
39
|
+
validate_file_dialect,
|
|
40
|
+
)
|
|
41
|
+
from .actions.json.inspect import inspect_json
|
|
42
|
+
from .actions.json_schema.assert_ import assert_json_schema
|
|
43
|
+
from .actions.json_schema.inspect import inspect_json_schema
|
|
44
|
+
from .actions.json_schema.load import load_json_schema
|
|
45
|
+
from .actions.json_schema.resolve import resolve_json_schema
|
|
46
|
+
from .actions.json_schema.save import save_json_schema
|
|
47
|
+
from .actions.path.basepath import get_basepath, resolve_basepath
|
|
48
|
+
from .actions.path.denormalize import denormalize_path
|
|
49
|
+
from .actions.path.general import (
|
|
50
|
+
get_file_basename,
|
|
51
|
+
get_file_extension,
|
|
52
|
+
get_file_name,
|
|
53
|
+
get_file_name_slug,
|
|
54
|
+
get_file_protocol,
|
|
55
|
+
get_is_remote_path,
|
|
56
|
+
)
|
|
57
|
+
from .actions.path.normalize import normalize_path
|
|
58
|
+
from .actions.profile.assert_ import assert_profile
|
|
59
|
+
from .actions.profile.load import load_profile
|
|
60
|
+
from .actions.profile.registry import profile_registry
|
|
61
|
+
from .actions.report.create import create_report
|
|
62
|
+
from .actions.resource.data import (
|
|
63
|
+
get_data_first_path,
|
|
64
|
+
get_data_path,
|
|
65
|
+
get_data_paths,
|
|
66
|
+
get_data_records,
|
|
67
|
+
get_data_value,
|
|
68
|
+
)
|
|
69
|
+
from .actions.resource.denormalize import denormalize_resource
|
|
70
|
+
from .actions.resource.general import get_is_remote_resource
|
|
71
|
+
from .actions.resource.infer import infer_resource_name
|
|
72
|
+
from .actions.resource.normalize import normalize_resource
|
|
73
|
+
from .actions.table_schema.assert_ import assert_table_schema
|
|
74
|
+
from .actions.table_schema.column import get_columns
|
|
75
|
+
from .actions.table_schema.load import load_table_schema
|
|
76
|
+
from .actions.table_schema.resolve import resolve_table_schema
|
|
77
|
+
from .actions.table_schema.save import save_table_schema
|
|
78
|
+
from .actions.table_schema.validate import (
|
|
79
|
+
TableSchemaValidationResult,
|
|
80
|
+
validate_table_schema,
|
|
81
|
+
)
|
|
82
|
+
from .models.base import FairspecModel
|
|
83
|
+
from .models.catalog import Catalog, CatalogDataset
|
|
84
|
+
from .models.datacite.alternate_identifier import (
|
|
85
|
+
AlternateIdentifier,
|
|
86
|
+
AlternateIdentifiers,
|
|
87
|
+
)
|
|
88
|
+
from .models.datacite.common import (
|
|
89
|
+
ContributorType,
|
|
90
|
+
ContentTypeGeneral,
|
|
91
|
+
CreatorNameType,
|
|
92
|
+
DateType,
|
|
93
|
+
DescriptionType,
|
|
94
|
+
FunderIdentifierType,
|
|
95
|
+
Latitude,
|
|
96
|
+
Longitude,
|
|
97
|
+
NumberType,
|
|
98
|
+
RelatedIdentifierType,
|
|
99
|
+
RelationType,
|
|
100
|
+
TitleType,
|
|
101
|
+
)
|
|
102
|
+
from .models.datacite.content_type import ContentTypes
|
|
103
|
+
from .models.datacite.contributor import Contributor, Contributors
|
|
104
|
+
from .models.datacite.creator import (
|
|
105
|
+
Creator,
|
|
106
|
+
CreatorAffiliation,
|
|
107
|
+
CreatorNameIdentifier,
|
|
108
|
+
Creators,
|
|
109
|
+
)
|
|
110
|
+
from .models.datacite.date import DataciteDate, DateValue, Dates
|
|
111
|
+
from .models.datacite.description import DataciteDescription, Descriptions
|
|
112
|
+
from .models.datacite.formats import Formats
|
|
113
|
+
from .models.datacite.funding_reference import FundingReference, FundingReferences
|
|
114
|
+
from .models.datacite.geo_location import (
|
|
115
|
+
GeoLocation,
|
|
116
|
+
GeoLocationBox,
|
|
117
|
+
GeoLocationPoint,
|
|
118
|
+
GeoLocationPolygonItem,
|
|
119
|
+
GeoLocations,
|
|
120
|
+
)
|
|
121
|
+
from .models.datacite.identifier import Doi, DoiPrefix, DoiSuffix
|
|
122
|
+
from .models.datacite.language import Language
|
|
123
|
+
from .models.datacite.publication_year import PublicationYear
|
|
124
|
+
from .models.datacite.publisher import Publisher
|
|
125
|
+
from .models.datacite.related_identifier import (
|
|
126
|
+
RelatedIdentifier,
|
|
127
|
+
RelatedIdentifiers,
|
|
128
|
+
RelatedObject,
|
|
129
|
+
)
|
|
130
|
+
from .models.datacite.related_item import (
|
|
131
|
+
RelatedItem,
|
|
132
|
+
RelatedItemIdentifier,
|
|
133
|
+
RelatedItems,
|
|
134
|
+
)
|
|
135
|
+
from .models.datacite.rights import Rights, RightsList
|
|
136
|
+
from .models.datacite.size import Sizes
|
|
137
|
+
from .models.datacite.subject import Subject, Subjects
|
|
138
|
+
from .models.datacite.title import Title, Titles
|
|
139
|
+
from .models.datacite.version import Version
|
|
140
|
+
from .models.column.array import ArrayColumn, ArrayColumnProperty
|
|
141
|
+
from .models.column.base import BaseColumn, BaseColumnProperty, BasePropertyType
|
|
142
|
+
from .models.column.base64 import Base64Column, Base64ColumnProperty
|
|
143
|
+
from .models.column.boolean import BooleanColumn, BooleanColumnProperty
|
|
144
|
+
from .models.column.categorical import (
|
|
145
|
+
CategoricalColumn,
|
|
146
|
+
IntegerCategoricalColumnProperty,
|
|
147
|
+
IntegerCategoryItem,
|
|
148
|
+
StringCategoricalColumnProperty,
|
|
149
|
+
StringCategoryItem,
|
|
150
|
+
)
|
|
151
|
+
from .models.column.column import Column, ColumnProperty, ColumnType
|
|
152
|
+
from .models.column.date import DateColumn, DateColumnProperty
|
|
153
|
+
from .models.column.date_time import DateTimeColumn, DateTimeColumnProperty
|
|
154
|
+
from .models.column.decimal import DecimalColumn, DecimalColumnProperty
|
|
155
|
+
from .models.column.duration import DurationColumn, DurationColumnProperty
|
|
156
|
+
from .models.column.email import EmailColumn, EmailColumnProperty
|
|
157
|
+
from .models.column.geojson import GeojsonColumn, GeojsonColumnProperty
|
|
158
|
+
from .models.column.hex import HexColumn, HexColumnProperty
|
|
159
|
+
from .models.column.integer import IntegerColumn, IntegerColumnProperty
|
|
160
|
+
from .models.column.list import ListColumn, ListColumnProperty
|
|
161
|
+
from .models.column.number import NumberColumn, NumberColumnProperty
|
|
162
|
+
from .models.column.object import ObjectColumn, ObjectColumnProperty
|
|
163
|
+
from .models.column.string import StringColumn, StringColumnProperty
|
|
164
|
+
from .models.column.time import TimeColumn, TimeColumnProperty
|
|
165
|
+
from .models.column.topojson import TopojsonColumn, TopojsonColumnProperty
|
|
166
|
+
from .models.column.unknown import UnknownColumn, UnknownColumnProperty
|
|
167
|
+
from .models.column.url import UrlColumn, UrlColumnProperty
|
|
168
|
+
from .models.column.wkb import WkbColumn, WkbColumnProperty
|
|
169
|
+
from .models.column.wkt import WktColumn, WktColumnProperty
|
|
170
|
+
from .models.data import Data, ResourceData, ResourceDataPath, ResourceDataValue
|
|
171
|
+
from .models.data_schema import DataSchema, RenderDataSchemaOptions
|
|
172
|
+
from .models.datacite.datacite import Datacite
|
|
173
|
+
from .models.dataset import (
|
|
174
|
+
ConvertDatasetFromOptions,
|
|
175
|
+
ConvertDatasetToOptions,
|
|
176
|
+
Dataset,
|
|
177
|
+
RenderDatasetOptions,
|
|
178
|
+
)
|
|
179
|
+
from .models.descriptor import Descriptor
|
|
180
|
+
from .models.error.base import BaseError
|
|
181
|
+
from .models.error.cell import (
|
|
182
|
+
CellConstError,
|
|
183
|
+
CellEnumError,
|
|
184
|
+
CellError,
|
|
185
|
+
CellExclusiveMaximumError,
|
|
186
|
+
CellExclusiveMinimumError,
|
|
187
|
+
CellJsonError,
|
|
188
|
+
CellMaximumError,
|
|
189
|
+
CellMaxItemsError,
|
|
190
|
+
CellMaxLengthError,
|
|
191
|
+
CellMinimumError,
|
|
192
|
+
CellMinItemsError,
|
|
193
|
+
CellMinLengthError,
|
|
194
|
+
CellMissingError,
|
|
195
|
+
CellMultipleOfError,
|
|
196
|
+
CellPatternError,
|
|
197
|
+
CellTypeError,
|
|
198
|
+
CellUniqueError,
|
|
199
|
+
)
|
|
200
|
+
from .models.error.column import ColumnError, ColumnMissingError, ColumnTypeError
|
|
201
|
+
from .models.error.data import DataError
|
|
202
|
+
from .models.error.error import FairspecError
|
|
203
|
+
from .models.error.file import FileError, IntegrityError, TextualError
|
|
204
|
+
from .models.error.foreign_key import ForeignKeyError
|
|
205
|
+
from .models.error.metadata import MetadataError
|
|
206
|
+
from .models.error.resource import (
|
|
207
|
+
ResourceError,
|
|
208
|
+
ResourceMissingError,
|
|
209
|
+
ResourceTypeError,
|
|
210
|
+
)
|
|
211
|
+
from .models.error.row import RowError, RowPrimaryKeyError, RowUniqueKeyError
|
|
212
|
+
from .models.error.table import TableError
|
|
213
|
+
from .models.exception import FairspecException
|
|
214
|
+
from .models.file_dialect.common import RowType
|
|
215
|
+
from .models.file_dialect.arrow import ArrowFileDialect
|
|
216
|
+
from .models.file_dialect.csv import CsvFileDialect
|
|
217
|
+
from .models.file_dialect.file_dialect import FileDialect
|
|
218
|
+
from .models.file_dialect.json import JsonFileDialect
|
|
219
|
+
from .models.file_dialect.jsonl import JsonlFileDialect
|
|
220
|
+
from .models.file_dialect.ods import OdsFileDialect
|
|
221
|
+
from .models.file_dialect.parquet import ParquetFileDialect
|
|
222
|
+
from .models.file_dialect.sqlite import SqliteFileDialect
|
|
223
|
+
from .models.file_dialect.tsv import TsvFileDialect
|
|
224
|
+
from .models.file_dialect.unknown import UnknownFileDialect
|
|
225
|
+
from .models.file_dialect.xlsx import XlsxFileDialect
|
|
226
|
+
from .models.foreign_key import ForeignKey, ForeignKeyReference
|
|
227
|
+
from .models.integrity import Integrity, IntegrityType
|
|
228
|
+
from .models.json_schema import JsonSchema
|
|
229
|
+
from .models.path import ExternalPath, InternalPath, Path
|
|
230
|
+
from .models.profile import Profile, ProfileRegistry, ProfileType
|
|
231
|
+
from .models.report import Report
|
|
232
|
+
from .models.resource import Resource
|
|
233
|
+
from .models.table_schema import (
|
|
234
|
+
ConvertTableSchemaFromOptions,
|
|
235
|
+
ConvertTableSchemaToOptions,
|
|
236
|
+
RenderTableSchemaOptions,
|
|
237
|
+
TableSchema,
|
|
238
|
+
TableSchemaMissingValueItem,
|
|
239
|
+
)
|
|
240
|
+
from .models.unique_key import UniqueKey
|
|
241
|
+
from .plugin import MetadataPlugin
|
|
242
|
+
from .settings import FAIRSPEC_VERSION
|
|
243
|
+
|
|
244
|
+
__all__ = [
|
|
245
|
+
"ArrowFileDialect",
|
|
246
|
+
"assert_data_schema",
|
|
247
|
+
"assert_dataset",
|
|
248
|
+
"assert_file_dialect",
|
|
249
|
+
"assert_json_schema",
|
|
250
|
+
"assert_profile",
|
|
251
|
+
"assert_table_schema",
|
|
252
|
+
"copy_descriptor",
|
|
253
|
+
"create_column_from_property",
|
|
254
|
+
"create_report",
|
|
255
|
+
"DataSchemaValidationResult",
|
|
256
|
+
"DatasetValidationResult",
|
|
257
|
+
"denormalize_dataset",
|
|
258
|
+
"denormalize_path",
|
|
259
|
+
"denormalize_resource",
|
|
260
|
+
"FileDialectValidationResult",
|
|
261
|
+
"get_base_property_type",
|
|
262
|
+
"get_basepath",
|
|
263
|
+
"get_column_properties",
|
|
264
|
+
"get_columns",
|
|
265
|
+
"get_data_first_path",
|
|
266
|
+
"get_data_path",
|
|
267
|
+
"get_data_paths",
|
|
268
|
+
"get_data_records",
|
|
269
|
+
"get_data_value",
|
|
270
|
+
"get_file_basename",
|
|
271
|
+
"get_file_extension",
|
|
272
|
+
"get_file_name",
|
|
273
|
+
"get_file_name_slug",
|
|
274
|
+
"get_file_protocol",
|
|
275
|
+
"get_is_descriptor",
|
|
276
|
+
"get_is_nullable_property_type",
|
|
277
|
+
"get_is_remote_path",
|
|
278
|
+
"get_is_remote_resource",
|
|
279
|
+
"get_supported_file_dialect",
|
|
280
|
+
"infer_file_dialect_format",
|
|
281
|
+
"infer_resource_name",
|
|
282
|
+
"inspect_json",
|
|
283
|
+
"inspect_json_schema",
|
|
284
|
+
"load_data_schema",
|
|
285
|
+
"load_dataset_descriptor",
|
|
286
|
+
"load_descriptor",
|
|
287
|
+
"load_file_dialect",
|
|
288
|
+
"load_json_schema",
|
|
289
|
+
"load_profile",
|
|
290
|
+
"load_table_schema",
|
|
291
|
+
"normalize_dataset",
|
|
292
|
+
"normalize_path",
|
|
293
|
+
"normalize_resource",
|
|
294
|
+
"parse_descriptor",
|
|
295
|
+
"profile_registry",
|
|
296
|
+
"resolve_basepath",
|
|
297
|
+
"resolve_data_schema",
|
|
298
|
+
"resolve_file_dialect",
|
|
299
|
+
"resolve_json_schema",
|
|
300
|
+
"resolve_table_schema",
|
|
301
|
+
"save_data_schema",
|
|
302
|
+
"save_dataset_descriptor",
|
|
303
|
+
"save_descriptor",
|
|
304
|
+
"save_file_dialect",
|
|
305
|
+
"save_json_schema",
|
|
306
|
+
"save_table_schema",
|
|
307
|
+
"stringify_descriptor",
|
|
308
|
+
"TableSchemaValidationResult",
|
|
309
|
+
"validate_data_schema",
|
|
310
|
+
"validate_dataset_descriptor",
|
|
311
|
+
"validate_descriptor",
|
|
312
|
+
"validate_file_dialect",
|
|
313
|
+
"validate_table_schema",
|
|
314
|
+
"AlternateIdentifier",
|
|
315
|
+
"AlternateIdentifiers",
|
|
316
|
+
"ArrayColumn",
|
|
317
|
+
"ArrayColumnProperty",
|
|
318
|
+
"Base64Column",
|
|
319
|
+
"Base64ColumnProperty",
|
|
320
|
+
"BaseColumn",
|
|
321
|
+
"BaseColumnProperty",
|
|
322
|
+
"BaseError",
|
|
323
|
+
"BasePropertyType",
|
|
324
|
+
"BooleanColumn",
|
|
325
|
+
"BooleanColumnProperty",
|
|
326
|
+
"Catalog",
|
|
327
|
+
"CatalogDataset",
|
|
328
|
+
"CategoricalColumn",
|
|
329
|
+
"CellConstError",
|
|
330
|
+
"CellEnumError",
|
|
331
|
+
"CellError",
|
|
332
|
+
"CellExclusiveMaximumError",
|
|
333
|
+
"CellExclusiveMinimumError",
|
|
334
|
+
"CellJsonError",
|
|
335
|
+
"CellMaxItemsError",
|
|
336
|
+
"CellMaxLengthError",
|
|
337
|
+
"CellMaximumError",
|
|
338
|
+
"CellMinItemsError",
|
|
339
|
+
"CellMinLengthError",
|
|
340
|
+
"CellMinimumError",
|
|
341
|
+
"CellMissingError",
|
|
342
|
+
"CellMultipleOfError",
|
|
343
|
+
"CellPatternError",
|
|
344
|
+
"CellTypeError",
|
|
345
|
+
"CellUniqueError",
|
|
346
|
+
"Column",
|
|
347
|
+
"ColumnError",
|
|
348
|
+
"ContentTypeGeneral",
|
|
349
|
+
"ContentTypes",
|
|
350
|
+
"Contributor",
|
|
351
|
+
"Contributors",
|
|
352
|
+
"ContributorType",
|
|
353
|
+
"ConvertDatasetFromOptions",
|
|
354
|
+
"ConvertDatasetToOptions",
|
|
355
|
+
"ConvertTableSchemaFromOptions",
|
|
356
|
+
"ConvertTableSchemaToOptions",
|
|
357
|
+
"ColumnMissingError",
|
|
358
|
+
"ColumnProperty",
|
|
359
|
+
"ColumnType",
|
|
360
|
+
"ColumnTypeError",
|
|
361
|
+
"Creator",
|
|
362
|
+
"CreatorAffiliation",
|
|
363
|
+
"CreatorNameIdentifier",
|
|
364
|
+
"CreatorNameType",
|
|
365
|
+
"Creators",
|
|
366
|
+
"CsvFileDialect",
|
|
367
|
+
"Data",
|
|
368
|
+
"DataError",
|
|
369
|
+
"DataSchema",
|
|
370
|
+
"Datacite",
|
|
371
|
+
"DataciteDate",
|
|
372
|
+
"DataciteDescription",
|
|
373
|
+
"Dataset",
|
|
374
|
+
"DateColumn",
|
|
375
|
+
"DateColumnProperty",
|
|
376
|
+
"DateTimeColumn",
|
|
377
|
+
"DateTimeColumnProperty",
|
|
378
|
+
"Dates",
|
|
379
|
+
"DateType",
|
|
380
|
+
"DateValue",
|
|
381
|
+
"DecimalColumn",
|
|
382
|
+
"DecimalColumnProperty",
|
|
383
|
+
"Descriptions",
|
|
384
|
+
"DescriptionType",
|
|
385
|
+
"Descriptor",
|
|
386
|
+
"Doi",
|
|
387
|
+
"DoiPrefix",
|
|
388
|
+
"DoiSuffix",
|
|
389
|
+
"DurationColumn",
|
|
390
|
+
"DurationColumnProperty",
|
|
391
|
+
"EmailColumn",
|
|
392
|
+
"EmailColumnProperty",
|
|
393
|
+
"ExternalPath",
|
|
394
|
+
"FAIRSPEC_VERSION",
|
|
395
|
+
"FairspecError",
|
|
396
|
+
"FairspecModel",
|
|
397
|
+
"FairspecException",
|
|
398
|
+
"FileDialect",
|
|
399
|
+
"FileError",
|
|
400
|
+
"ForeignKey",
|
|
401
|
+
"ForeignKeyError",
|
|
402
|
+
"ForeignKeyReference",
|
|
403
|
+
"Formats",
|
|
404
|
+
"FunderIdentifierType",
|
|
405
|
+
"FundingReference",
|
|
406
|
+
"FundingReferences",
|
|
407
|
+
"GeoLocation",
|
|
408
|
+
"GeoLocationBox",
|
|
409
|
+
"GeoLocationPoint",
|
|
410
|
+
"GeoLocationPolygonItem",
|
|
411
|
+
"GeoLocations",
|
|
412
|
+
"GeojsonColumn",
|
|
413
|
+
"GeojsonColumnProperty",
|
|
414
|
+
"HexColumn",
|
|
415
|
+
"HexColumnProperty",
|
|
416
|
+
"Integrity",
|
|
417
|
+
"IntegerCategoricalColumnProperty",
|
|
418
|
+
"IntegerCategoryItem",
|
|
419
|
+
"IntegerColumn",
|
|
420
|
+
"IntegerColumnProperty",
|
|
421
|
+
"IntegrityError",
|
|
422
|
+
"IntegrityType",
|
|
423
|
+
"InternalPath",
|
|
424
|
+
"JsonFileDialect",
|
|
425
|
+
"JsonSchema",
|
|
426
|
+
"JsonlFileDialect",
|
|
427
|
+
"Language",
|
|
428
|
+
"Latitude",
|
|
429
|
+
"ListColumn",
|
|
430
|
+
"ListColumnProperty",
|
|
431
|
+
"Longitude",
|
|
432
|
+
"MetadataError",
|
|
433
|
+
"MetadataPlugin",
|
|
434
|
+
"NumberColumn",
|
|
435
|
+
"NumberColumnProperty",
|
|
436
|
+
"NumberType",
|
|
437
|
+
"ObjectColumn",
|
|
438
|
+
"ObjectColumnProperty",
|
|
439
|
+
"OdsFileDialect",
|
|
440
|
+
"ParquetFileDialect",
|
|
441
|
+
"Path",
|
|
442
|
+
"Profile",
|
|
443
|
+
"ProfileRegistry",
|
|
444
|
+
"ProfileType",
|
|
445
|
+
"PublicationYear",
|
|
446
|
+
"Publisher",
|
|
447
|
+
"RelatedIdentifier",
|
|
448
|
+
"RelatedIdentifierType",
|
|
449
|
+
"RelatedIdentifiers",
|
|
450
|
+
"RelatedItem",
|
|
451
|
+
"RelatedItemIdentifier",
|
|
452
|
+
"RelatedItems",
|
|
453
|
+
"RelatedObject",
|
|
454
|
+
"RelationType",
|
|
455
|
+
"RenderDataSchemaOptions",
|
|
456
|
+
"RenderDatasetOptions",
|
|
457
|
+
"RenderTableSchemaOptions",
|
|
458
|
+
"Report",
|
|
459
|
+
"Resource",
|
|
460
|
+
"ResourceData",
|
|
461
|
+
"ResourceDataPath",
|
|
462
|
+
"ResourceDataValue",
|
|
463
|
+
"ResourceError",
|
|
464
|
+
"ResourceMissingError",
|
|
465
|
+
"ResourceTypeError",
|
|
466
|
+
"Rights",
|
|
467
|
+
"RightsList",
|
|
468
|
+
"RowError",
|
|
469
|
+
"RowPrimaryKeyError",
|
|
470
|
+
"RowType",
|
|
471
|
+
"RowUniqueKeyError",
|
|
472
|
+
"Sizes",
|
|
473
|
+
"SqliteFileDialect",
|
|
474
|
+
"StringCategoricalColumnProperty",
|
|
475
|
+
"StringCategoryItem",
|
|
476
|
+
"StringColumn",
|
|
477
|
+
"StringColumnProperty",
|
|
478
|
+
"Subject",
|
|
479
|
+
"Subjects",
|
|
480
|
+
"TableError",
|
|
481
|
+
"TableSchema",
|
|
482
|
+
"TableSchemaMissingValueItem",
|
|
483
|
+
"TextualError",
|
|
484
|
+
"TimeColumn",
|
|
485
|
+
"TimeColumnProperty",
|
|
486
|
+
"Title",
|
|
487
|
+
"Titles",
|
|
488
|
+
"TitleType",
|
|
489
|
+
"TopojsonColumn",
|
|
490
|
+
"TopojsonColumnProperty",
|
|
491
|
+
"TsvFileDialect",
|
|
492
|
+
"UniqueKey",
|
|
493
|
+
"UnknownColumn",
|
|
494
|
+
"UnknownColumnProperty",
|
|
495
|
+
"UnknownFileDialect",
|
|
496
|
+
"UrlColumn",
|
|
497
|
+
"UrlColumnProperty",
|
|
498
|
+
"Version",
|
|
499
|
+
"WkbColumn",
|
|
500
|
+
"WkbColumnProperty",
|
|
501
|
+
"WktColumn",
|
|
502
|
+
"WktColumnProperty",
|
|
503
|
+
"XlsxFileDialect",
|
|
504
|
+
]
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, cast
|
|
4
|
+
|
|
5
|
+
from fairspec_metadata.models.column.array import ArrayColumn, ArrayColumnProperty
|
|
6
|
+
from fairspec_metadata.models.column.base import BaseColumn, BaseColumnProperty
|
|
7
|
+
from fairspec_metadata.models.column.base64 import Base64Column, Base64ColumnProperty
|
|
8
|
+
from fairspec_metadata.models.column.boolean import (
|
|
9
|
+
BooleanColumn,
|
|
10
|
+
BooleanColumnProperty,
|
|
11
|
+
)
|
|
12
|
+
from fairspec_metadata.models.column.categorical import (
|
|
13
|
+
CategoricalColumn,
|
|
14
|
+
IntegerCategoricalColumnProperty,
|
|
15
|
+
StringCategoricalColumnProperty,
|
|
16
|
+
)
|
|
17
|
+
from fairspec_metadata.models.column.column import ColumnType
|
|
18
|
+
from fairspec_metadata.models.column.date import DateColumn, DateColumnProperty
|
|
19
|
+
from fairspec_metadata.models.column.date_time import (
|
|
20
|
+
DateTimeColumn,
|
|
21
|
+
DateTimeColumnProperty,
|
|
22
|
+
)
|
|
23
|
+
from fairspec_metadata.models.column.decimal import DecimalColumn, DecimalColumnProperty
|
|
24
|
+
from fairspec_metadata.models.column.duration import (
|
|
25
|
+
DurationColumn,
|
|
26
|
+
DurationColumnProperty,
|
|
27
|
+
)
|
|
28
|
+
from fairspec_metadata.models.column.email import EmailColumn, EmailColumnProperty
|
|
29
|
+
from fairspec_metadata.models.column.geojson import GeojsonColumn, GeojsonColumnProperty
|
|
30
|
+
from fairspec_metadata.models.column.hex import HexColumn, HexColumnProperty
|
|
31
|
+
from fairspec_metadata.models.column.integer import IntegerColumn, IntegerColumnProperty
|
|
32
|
+
from fairspec_metadata.models.column.list import ListColumn, ListColumnProperty
|
|
33
|
+
from fairspec_metadata.models.column.number import NumberColumn, NumberColumnProperty
|
|
34
|
+
from fairspec_metadata.models.column.object import ObjectColumn, ObjectColumnProperty
|
|
35
|
+
from fairspec_metadata.models.column.string import StringColumn, StringColumnProperty
|
|
36
|
+
from fairspec_metadata.models.column.time import TimeColumn, TimeColumnProperty
|
|
37
|
+
from fairspec_metadata.models.column.topojson import (
|
|
38
|
+
TopojsonColumn,
|
|
39
|
+
TopojsonColumnProperty,
|
|
40
|
+
)
|
|
41
|
+
from fairspec_metadata.models.column.unknown import UnknownColumn, UnknownColumnProperty
|
|
42
|
+
from fairspec_metadata.models.column.url import UrlColumn, UrlColumnProperty
|
|
43
|
+
from fairspec_metadata.models.column.wkb import WkbColumn, WkbColumnProperty
|
|
44
|
+
from fairspec_metadata.models.column.wkt import WktColumn, WktColumnProperty
|
|
45
|
+
|
|
46
|
+
from .property import get_base_property_type, get_is_nullable_property_type
|
|
47
|
+
|
|
48
|
+
if TYPE_CHECKING:
|
|
49
|
+
from fairspec_metadata.models.column.column import Column
|
|
50
|
+
from fairspec_metadata.models.descriptor import Descriptor
|
|
51
|
+
|
|
52
|
+
_COLUMN_CLASS_MAP: dict[
|
|
53
|
+
ColumnType, tuple[type[BaseColumn], type[BaseColumnProperty]]
|
|
54
|
+
] = {
|
|
55
|
+
ColumnType.array: (ArrayColumn, ArrayColumnProperty),
|
|
56
|
+
ColumnType.base64: (Base64Column, Base64ColumnProperty),
|
|
57
|
+
ColumnType.boolean: (BooleanColumn, BooleanColumnProperty),
|
|
58
|
+
ColumnType.date: (DateColumn, DateColumnProperty),
|
|
59
|
+
ColumnType.date_time: (DateTimeColumn, DateTimeColumnProperty),
|
|
60
|
+
ColumnType.decimal: (DecimalColumn, DecimalColumnProperty),
|
|
61
|
+
ColumnType.duration: (DurationColumn, DurationColumnProperty),
|
|
62
|
+
ColumnType.email: (EmailColumn, EmailColumnProperty),
|
|
63
|
+
ColumnType.geojson: (GeojsonColumn, GeojsonColumnProperty),
|
|
64
|
+
ColumnType.hex: (HexColumn, HexColumnProperty),
|
|
65
|
+
ColumnType.integer: (IntegerColumn, IntegerColumnProperty),
|
|
66
|
+
ColumnType.list: (ListColumn, ListColumnProperty),
|
|
67
|
+
ColumnType.number: (NumberColumn, NumberColumnProperty),
|
|
68
|
+
ColumnType.object: (ObjectColumn, ObjectColumnProperty),
|
|
69
|
+
ColumnType.string: (StringColumn, StringColumnProperty),
|
|
70
|
+
ColumnType.time: (TimeColumn, TimeColumnProperty),
|
|
71
|
+
ColumnType.topojson: (TopojsonColumn, TopojsonColumnProperty),
|
|
72
|
+
ColumnType.unknown: (UnknownColumn, UnknownColumnProperty),
|
|
73
|
+
ColumnType.url: (UrlColumn, UrlColumnProperty),
|
|
74
|
+
ColumnType.wkb: (WkbColumn, WkbColumnProperty),
|
|
75
|
+
ColumnType.wkt: (WktColumn, WktColumnProperty),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_CATEGORICAL_PROPERTY_MAP: dict[str | None, type[BaseColumnProperty]] = {
|
|
79
|
+
"integer": IntegerCategoricalColumnProperty,
|
|
80
|
+
"string": StringCategoricalColumnProperty,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def create_column_from_property(name: str, property: Descriptor) -> Column:
|
|
85
|
+
base_type = get_base_property_type(property.get("type"))
|
|
86
|
+
format = property.get("format")
|
|
87
|
+
nullable = get_is_nullable_property_type(property.get("type")) or None
|
|
88
|
+
column_type = _get_column_type(base_type, format)
|
|
89
|
+
|
|
90
|
+
if column_type == ColumnType.categorical:
|
|
91
|
+
cat_property_cls = _CATEGORICAL_PROPERTY_MAP.get(
|
|
92
|
+
base_type, StringCategoricalColumnProperty
|
|
93
|
+
)
|
|
94
|
+
property_model = cat_property_cls.model_validate(property)
|
|
95
|
+
# Upcast concrete subclass to Column union (type checker can't infer this)
|
|
96
|
+
return cast(
|
|
97
|
+
"Column",
|
|
98
|
+
CategoricalColumn.model_validate(
|
|
99
|
+
{
|
|
100
|
+
"type": column_type,
|
|
101
|
+
"name": name,
|
|
102
|
+
"nullable": nullable,
|
|
103
|
+
"property": property_model,
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
column_cls, property_cls = _COLUMN_CLASS_MAP[column_type]
|
|
109
|
+
property_model = property_cls.model_validate(property)
|
|
110
|
+
# Upcast concrete subclass to Column union (type checker can't infer this)
|
|
111
|
+
return cast(
|
|
112
|
+
"Column",
|
|
113
|
+
column_cls.model_validate(
|
|
114
|
+
{
|
|
115
|
+
"type": column_type,
|
|
116
|
+
"name": name,
|
|
117
|
+
"nullable": nullable,
|
|
118
|
+
"property": property_model,
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _get_column_type(base_type: str | None, format: str | None) -> ColumnType:
|
|
125
|
+
match base_type:
|
|
126
|
+
case "boolean":
|
|
127
|
+
return ColumnType.boolean
|
|
128
|
+
case "integer":
|
|
129
|
+
if format == "categorical":
|
|
130
|
+
return ColumnType.categorical
|
|
131
|
+
return ColumnType.integer
|
|
132
|
+
case "number":
|
|
133
|
+
return ColumnType.number
|
|
134
|
+
case "string":
|
|
135
|
+
match format:
|
|
136
|
+
case "categorical":
|
|
137
|
+
return ColumnType.categorical
|
|
138
|
+
case "decimal":
|
|
139
|
+
return ColumnType.decimal
|
|
140
|
+
case "list":
|
|
141
|
+
return ColumnType.list
|
|
142
|
+
case "base64":
|
|
143
|
+
return ColumnType.base64
|
|
144
|
+
case "hex":
|
|
145
|
+
return ColumnType.hex
|
|
146
|
+
case "email":
|
|
147
|
+
return ColumnType.email
|
|
148
|
+
case "url":
|
|
149
|
+
return ColumnType.url
|
|
150
|
+
case "date-time":
|
|
151
|
+
return ColumnType.date_time
|
|
152
|
+
case "date":
|
|
153
|
+
return ColumnType.date
|
|
154
|
+
case "time":
|
|
155
|
+
return ColumnType.time
|
|
156
|
+
case "duration":
|
|
157
|
+
return ColumnType.duration
|
|
158
|
+
case "wkt":
|
|
159
|
+
return ColumnType.wkt
|
|
160
|
+
case "wkb":
|
|
161
|
+
return ColumnType.wkb
|
|
162
|
+
case _:
|
|
163
|
+
return ColumnType.string
|
|
164
|
+
case "array":
|
|
165
|
+
return ColumnType.array
|
|
166
|
+
case "object":
|
|
167
|
+
match format:
|
|
168
|
+
case "geojson":
|
|
169
|
+
return ColumnType.geojson
|
|
170
|
+
case "topojson":
|
|
171
|
+
return ColumnType.topojson
|
|
172
|
+
case _:
|
|
173
|
+
return ColumnType.object
|
|
174
|
+
case _:
|
|
175
|
+
return ColumnType.unknown
|