@@ -39,12 +39,15 @@ class Dataset:
39
39
"""Python representation of a Croissant dataset.
40
40
41
41
Args:
42
- file: A JSON object or a path to a Croissant file (string or pathlib.Path).
43
- operations: The operation graph class. None by default.
42
+ jsonld: A JSON object or a path to a Croissant file (URL, str or pathlib.Path).
44
43
debug: Whether to print debug hints. False by default.
44
+ mapping: Mapping filename->filepath as a Python dict[str, str] to handle manual
45
+ downloads. If `document.csv` is the FileObject and you downloaded it to
46
+ `~/Downloads/document.csv`, you can specify `mapping={"document.csv":
47
+ "~/Downloads/document.csv"}`.,
45
48
"""
46
49
47
- file : epath .PathLike | str | dict [str , Any ] | None
50
+ jsonld : epath .PathLike | str | dict [str , Any ] | None
48
51
operations : OperationGraph = dataclasses .field (init = False )
49
52
metadata : Metadata = dataclasses .field (init = False )
50
53
debug : bool = False
@@ -54,10 +57,10 @@ def __post_init__(self):
54
57
"""Runs the static analysis of `file`."""
55
58
ctx = Context ()
56
59
ctx .mapping = _expand_mapping (self .mapping )
57
- if isinstance (self .file , dict ):
58
- self .metadata = Metadata .from_json (ctx = ctx , json_ = self .file )
59
- elif self .file is not None :
60
- self .metadata = Metadata .from_file (ctx = ctx , file = self .file )
60
+ if isinstance (self .jsonld , dict ):
61
+ self .metadata = Metadata .from_json (ctx = ctx , json_ = self .jsonld )
62
+ elif self .jsonld is not None :
63
+ self .metadata = Metadata .from_file (ctx = ctx , file = self .jsonld )
61
64
else :
62
65
return
63
66
# Draw the structure graph for debugging purposes.
@@ -71,7 +74,7 @@ def __post_init__(self):
71
74
@classmethod
72
75
def from_metadata (cls , metadata : Metadata ) -> Dataset :
73
76
"""Creates a new `Dataset` from a `Metadata`."""
74
- dataset = Dataset (file = None )
77
+ dataset = Dataset (jsonld = None )
75
78
dataset .metadata = metadata
76
79
dataset .operations = get_operations (metadata .ctx , metadata )
77
80
return dataset
0 commit comments