Skip to content

Commit 8fcf182

Browse files
authored
Merge pull request #194 from simleo/document_dest_path
Clarify the role of `dest_path` in the readme
2 parents ad8e816 + 61f055f commit 8fcf182

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ diagram = crate.add_file("exp/diagram.svg", dest_path="images/figure.svg", prope
5353
})
5454
```
5555

56+
The `dest_path` argument is used to specify the relative path of the file with respect to the crate's directory (which will be determined when the crate is written). Note that the first two `add_file` calls do not specify `dest_path`: in this case, it will be set to the source file's basename (`"paper.pdf"` in the first case), so the file will be at the crate's top level when it is written.
57+
5658
We've started by adding the data entities. Now we need contextual entities to represent Alice and Bob:
5759

5860
```python
@@ -98,7 +100,19 @@ Finally, we serialize the crate to disk:
98100
crate.write("exp_crate")
99101
```
100102

101-
Now the `exp_crate` directory should contain copies of all the files we added and an `ro-crate-metadata.json` file with a [JSON-LD](https://json-ld.org) representation of the entities and relationships we created. Note that we have chosen a different destination path for the diagram, while the other two files have been placed at the top level with their names unchanged (the default).
103+
Now the `exp_crate` directory should contain copies of all the files we added and an `ro-crate-metadata.json` file with a [JSON-LD](https://json-ld.org) representation of the entities and relationships we created, with the following layout:
104+
105+
```
106+
exp_crate/
107+
|-- images/
108+
| `-- figure.svg
109+
|-- logs/
110+
| |-- log1.txt
111+
| `-- log2.txt
112+
|-- paper.pdf
113+
|-- results.csv
114+
`-- ro-crate-metadata.json
115+
```
102116

103117
Exploring the `exp_crate` directory, we see that all files and directories contained in `exp/logs` have been added recursively to the crate. However, in the `ro-crate-metadata.json` file, only the top level Dataset with `@id` `"exp/logs"` is listed. This is because we used `crate.add_dataset("exp/logs")` rather than adding every file individually. There is no requirement to represent every file and folder within the crate in the `ro-crate-metadata.json` file. If you do want to add files and directories recursively to the metadata, use `crate.add_tree` instead of `crate.add_dataset` (but note that it only works on local directory trees).
104118

0 commit comments

Comments
 (0)