plastron-cli 4.3.2__tar.gz
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.
- plastron_cli-4.3.2/PKG-INFO +521 -0
- plastron_cli-4.3.2/README.md +500 -0
- plastron_cli-4.3.2/VERSION +1 -0
- plastron_cli-4.3.2/pyproject.toml +46 -0
- plastron_cli-4.3.2/setup.cfg +4 -0
- plastron_cli-4.3.2/src/plastron/cli/__init__.py +210 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/__init__.py +46 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/annotate.py +51 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/create.py +106 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/delete.py +97 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/echo.py +53 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/export.py +69 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/extractocr.py +107 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/find.py +141 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/imgsize.py +50 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/importcommand.py +222 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/list.py +47 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/load.py +320 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/ping.py +19 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/publish.py +70 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/reindex.py +52 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/set.py +83 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/stub.py +173 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/unpublish.py +60 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/update.py +99 -0
- plastron_cli-4.3.2/src/plastron/cli/commands/verify.py +43 -0
- plastron_cli-4.3.2/src/plastron/cli/handlers/__init__.py +0 -0
- plastron_cli-4.3.2/src/plastron/cli/handlers/mapped-csv.py +265 -0
- plastron_cli-4.3.2/src/plastron/cli/handlers/ndnp.py +349 -0
- plastron_cli-4.3.2/src/plastron/cli/handlers/reel.py +53 -0
- plastron_cli-4.3.2/src/plastron/cli/handlers/turtle.py +178 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/PKG-INFO +521 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/SOURCES.txt +38 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/dependency_links.txt +1 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/entry_points.txt +2 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/requires.txt +14 -0
- plastron_cli-4.3.2/src/plastron_cli.egg-info/top_level.txt +1 -0
- plastron_cli-4.3.2/tests/test_cli.py +19 -0
- plastron_cli-4.3.2/tests/test_embedded_objects.py +43 -0
- plastron_cli-4.3.2/tests/test_update_command.py +23 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: plastron-cli
|
|
3
|
+
Version: 4.3.2
|
|
4
|
+
Summary: Plastron command line client
|
|
5
|
+
Author-email: University of Maryland Libraries <lib-ssdr@umd.edu>, Josh Westgard <westgard@umd.edu>, Peter Eichman <peichman@umd.edu>, Mohamed Abdul Rasheed <mohideen@umd.edu>, Ben Wallberg <wallberg@umd.edu>, David Steelman <dsteelma@umd.edu>, Marc Andreu Grillo Aguilar <aguilarm@umd.edu>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: BeautifulSoup4
|
|
9
|
+
Requires-Dist: lxml
|
|
10
|
+
Requires-Dist: Pillow
|
|
11
|
+
Requires-Dist: plastron-models
|
|
12
|
+
Requires-Dist: plastron-repo
|
|
13
|
+
Requires-Dist: plastron-utils
|
|
14
|
+
Requires-Dist: pyparsing
|
|
15
|
+
Requires-Dist: pysolr
|
|
16
|
+
Requires-Dist: PyYAML
|
|
17
|
+
Requires-Dist: rdflib
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: pytest; extra == "test"
|
|
20
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
21
|
+
|
|
22
|
+
# plastron-cli
|
|
23
|
+
|
|
24
|
+
Plastron command-line client
|
|
25
|
+
|
|
26
|
+
## Common Options
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
$ plastron --help
|
|
30
|
+
usage: plastron [-h] (-r REPO | -c CONFIG_FILE | -V) [-v] [-q]
|
|
31
|
+
[--on-behalf-of DELEGATED_USER]
|
|
32
|
+
{annotate,create,delete,del,rm,echo,export,extractocr,find,imgsize,import,list,ls,load,mkcol,ping,reindex,stub,update}
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
Batch operation tool for Fedora 4.
|
|
36
|
+
|
|
37
|
+
optional arguments:
|
|
38
|
+
-h, --help show this help message and exit
|
|
39
|
+
-r REPO, --repo REPO Path to repository configuration file.
|
|
40
|
+
-c CONFIG_FILE, --config CONFIG_FILE
|
|
41
|
+
Path to configuration file.
|
|
42
|
+
-V, --version Print version and exit.
|
|
43
|
+
-v, --verbose increase the verbosity of the status output
|
|
44
|
+
-q, --quiet decrease the verbosity of the status output
|
|
45
|
+
--on-behalf-of DELEGATED_USER
|
|
46
|
+
delegate repository operations to this username
|
|
47
|
+
|
|
48
|
+
commands:
|
|
49
|
+
{annotate,create,delete,del,rm,echo,export,extractocr,find,imgsize,import,list,ls,load,mkcol,ping,reindex,stub,update}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Check version
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
$ plastron --version
|
|
56
|
+
4.0.0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
All commands require you to specify a configuration file using either the
|
|
62
|
+
`-c|--config` or `-r|--repo` option *before* the command name. For example,
|
|
63
|
+
`plastron -c path/to/repo.yml ping`.
|
|
64
|
+
|
|
65
|
+
### Annotate (annotate)
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
$ plastron annotate --help
|
|
69
|
+
usage: plastron annotate [-h] [uris [uris ...]]
|
|
70
|
+
|
|
71
|
+
Annotate resources with the text content of their HTML files
|
|
72
|
+
|
|
73
|
+
positional arguments:
|
|
74
|
+
uris URIs of repository objects to process
|
|
75
|
+
|
|
76
|
+
optional arguments:
|
|
77
|
+
-h, --help show this help message and exit
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Create (create)
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
$ plastron create -h
|
|
84
|
+
usage: plastron create [-h] [-D PREDICATE VALUE] [-O PREDICATE VALUE]
|
|
85
|
+
[-T TYPE] [--collection NAME] [--container PATH]
|
|
86
|
+
[path]
|
|
87
|
+
|
|
88
|
+
Create a resource in the repository
|
|
89
|
+
|
|
90
|
+
positional arguments:
|
|
91
|
+
path path to the new resource
|
|
92
|
+
|
|
93
|
+
optional arguments:
|
|
94
|
+
-h, --help show this help message and exit
|
|
95
|
+
-D PREDICATE VALUE, --data-property PREDICATE VALUE
|
|
96
|
+
an RDF data property to set on the newly created
|
|
97
|
+
resource; VALUE is treated as a Literal; repeatable
|
|
98
|
+
-O PREDICATE VALUE, --object-property PREDICATE VALUE
|
|
99
|
+
an RDF object property to set on the newly created
|
|
100
|
+
resource; VALUE is treated as a CURIE or URIRef;
|
|
101
|
+
repeatable
|
|
102
|
+
-T TYPE, --rdf-type TYPE
|
|
103
|
+
RDF type to add to the newly created resource;
|
|
104
|
+
equivalent to "-O rdf:type TYPE"; TYPE is treated as a
|
|
105
|
+
CURIE or URIRef; repeatable
|
|
106
|
+
--collection NAME shortcut for "-T pcdm:collection -D dcterms:title
|
|
107
|
+
NAME"
|
|
108
|
+
--container PATH parent container for the new resource; use this to
|
|
109
|
+
create a new resource with a repository-generated
|
|
110
|
+
identifier
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Delete (delete, del, rm)
|
|
114
|
+
|
|
115
|
+
See [Delete Command](docs/delete.md)
|
|
116
|
+
|
|
117
|
+
### Echo (echo)
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
$ plastron echo --help
|
|
121
|
+
usage: plastron echo [-h] [-e ECHO_DELAY] -b BODY
|
|
122
|
+
|
|
123
|
+
Diagnostic command for echoing input to output. Primarily intended for testing
|
|
124
|
+
synchronous message processing.
|
|
125
|
+
|
|
126
|
+
optional arguments:
|
|
127
|
+
-h, --help show this help message and exit
|
|
128
|
+
-e ECHO_DELAY, --echo-delay ECHO_DELAY
|
|
129
|
+
The amount of time to delay the reply, in seconds
|
|
130
|
+
-b BODY, --body BODY The text to echo back
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Export (export)
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
$ plastron export --help
|
|
137
|
+
usage: plastron export [-h] -o OUTPUT_DEST [--key KEY] -f
|
|
138
|
+
{text/turtle,turtle,ttl,text/csv,csv}
|
|
139
|
+
[--uri-template URI_TEMPLATE] [-B]
|
|
140
|
+
[--binary-types BINARY_TYPES]
|
|
141
|
+
[uris [uris ...]]
|
|
142
|
+
|
|
143
|
+
Export resources from the repository as a BagIt bag
|
|
144
|
+
|
|
145
|
+
positional arguments:
|
|
146
|
+
uris URIs of repository objects to export
|
|
147
|
+
|
|
148
|
+
optional arguments:
|
|
149
|
+
-h, --help show this help message and exit
|
|
150
|
+
-o OUTPUT_DEST, --output-dest OUTPUT_DEST
|
|
151
|
+
Where to send the export. Can be a local filename or
|
|
152
|
+
an SFTP URI
|
|
153
|
+
--key KEY SSH private key file to use for SFTP connections
|
|
154
|
+
-f {text/turtle,turtle,ttl,text/csv,csv}, --format {text/turtle,turtle,ttl,text/csv,csv}
|
|
155
|
+
Format for exported metadata
|
|
156
|
+
--uri-template URI_TEMPLATE
|
|
157
|
+
Public URI template
|
|
158
|
+
-B, --export-binaries
|
|
159
|
+
Export binaries in addition to the metadata
|
|
160
|
+
--binary-types BINARY_TYPES
|
|
161
|
+
Include only binaries with a MIME type from this list
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Extract OCR (extractocr)
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
$ plastron extractocr --help
|
|
168
|
+
usage: plastron extractocr [-h] [--ignore IGNORE] [--no-transactions]
|
|
169
|
+
[--completed COMPLETED] [-f URIS_FILE]
|
|
170
|
+
[uris [uris ...]]
|
|
171
|
+
|
|
172
|
+
Create annotations from OCR data stored in the repository
|
|
173
|
+
|
|
174
|
+
positional arguments:
|
|
175
|
+
uris Repository URIs
|
|
176
|
+
|
|
177
|
+
optional arguments:
|
|
178
|
+
-h, --help show this help message and exit
|
|
179
|
+
--ignore IGNORE, -i IGNORE
|
|
180
|
+
file listing items to ignore
|
|
181
|
+
--no-transactions, --no-txn
|
|
182
|
+
run the annotation process without using transactions
|
|
183
|
+
--completed COMPLETED
|
|
184
|
+
file recording the URIs of processed resources
|
|
185
|
+
-f URIS_FILE, --file URIS_FILE
|
|
186
|
+
File containing a list of URIs
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Find (find)
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
$ plastron find --help
|
|
193
|
+
usage: plastron find [-h] [-R RECURSIVE] [-D PREDICATE VALUE]
|
|
194
|
+
[-O PREDICATE VALUE] [-T TYPE]
|
|
195
|
+
[--match-all | --match-any]
|
|
196
|
+
[URI [URI ...]]
|
|
197
|
+
|
|
198
|
+
Find objects in the repository
|
|
199
|
+
|
|
200
|
+
positional arguments:
|
|
201
|
+
URI search at this URI in the repository
|
|
202
|
+
|
|
203
|
+
optional arguments:
|
|
204
|
+
-h, --help show this help message and exit
|
|
205
|
+
-R RECURSIVE, --recursive RECURSIVE
|
|
206
|
+
search additional objects found by traversing the
|
|
207
|
+
given predicate(s)
|
|
208
|
+
-D PREDICATE VALUE, --data-property PREDICATE VALUE
|
|
209
|
+
an RDF data property to match; VALUE is treated as a
|
|
210
|
+
Literal; repeatable
|
|
211
|
+
-O PREDICATE VALUE, --object-property PREDICATE VALUE
|
|
212
|
+
an RDF object property to match; VALUE is treated as a
|
|
213
|
+
CURIE or URIRef; repeatable
|
|
214
|
+
-T TYPE, --rdf-type TYPE
|
|
215
|
+
RDF type to match; equivalent to "-O rdf:type TYPE";
|
|
216
|
+
TYPE is treated as a CURIE or URIRef; repeatable
|
|
217
|
+
--match-all require all properties to match to include a resource
|
|
218
|
+
in the result list; this is the default behavior
|
|
219
|
+
--match-any require at least one property to match to include a
|
|
220
|
+
resource in the result list
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Image Size (imgsize)
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
$ plastron imgsize --help
|
|
227
|
+
usage: plastron imgsize [-h] [uris [uris ...]]
|
|
228
|
+
|
|
229
|
+
Add width and height to image resources
|
|
230
|
+
|
|
231
|
+
positional arguments:
|
|
232
|
+
uris URIs of repository objects to get image info
|
|
233
|
+
|
|
234
|
+
optional arguments:
|
|
235
|
+
-h, --help show this help message and exit
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Import (import)
|
|
239
|
+
|
|
240
|
+
See [Import Command](docs/import.md)
|
|
241
|
+
|
|
242
|
+
### List (list, ls)
|
|
243
|
+
|
|
244
|
+
```text
|
|
245
|
+
$ plastron list --help
|
|
246
|
+
usage: plastron list [-h] [-l] [uris [uris ...]]
|
|
247
|
+
|
|
248
|
+
List objects in the repository
|
|
249
|
+
|
|
250
|
+
positional arguments:
|
|
251
|
+
uris URIs of repository objects to list
|
|
252
|
+
|
|
253
|
+
optional arguments:
|
|
254
|
+
-h, --help show this help message and exit
|
|
255
|
+
-l, --long Display additional information besides the URI
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Load (load)
|
|
259
|
+
|
|
260
|
+
```text
|
|
261
|
+
$ plastron load --help
|
|
262
|
+
usage: plastron load [-h] -b BATCH [-d] [-n] [-l LIMIT] [-% PERCENT]
|
|
263
|
+
[--no-annotations] [--no-transactions] [--ignore IGNORE]
|
|
264
|
+
[--wait WAIT]
|
|
265
|
+
|
|
266
|
+
Load a batch into the repository
|
|
267
|
+
|
|
268
|
+
optional arguments:
|
|
269
|
+
-h, --help show this help message and exit
|
|
270
|
+
-d, --dry-run iterate over the batch without POSTing
|
|
271
|
+
-n, --no-binaries iterate without uploading binaries
|
|
272
|
+
-l LIMIT, --limit LIMIT
|
|
273
|
+
limit the load to a specified number of top-level
|
|
274
|
+
objects
|
|
275
|
+
-% PERCENT, --percent PERCENT
|
|
276
|
+
load specified percentage of total items
|
|
277
|
+
--no-annotations iterate without loading annotations (e.g. OCR)
|
|
278
|
+
--no-transactions, --no-txn
|
|
279
|
+
run the load without using transactions
|
|
280
|
+
--ignore IGNORE, -i IGNORE
|
|
281
|
+
file listing items to ignore
|
|
282
|
+
--wait WAIT, -w WAIT wait n seconds between items
|
|
283
|
+
|
|
284
|
+
required arguments:
|
|
285
|
+
-b BATCH, --batch BATCH
|
|
286
|
+
path to batch configuration file
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Batch Configuration
|
|
290
|
+
|
|
291
|
+
##### Required
|
|
292
|
+
|
|
293
|
+
| Option | Description |
|
|
294
|
+
|--------------|--------------------------------------------------------------------|
|
|
295
|
+
| `BATCH_FILE` | The "main" file of the batch |
|
|
296
|
+
| `COLLECTION` | URI of the repository collection that the objects will be added to |
|
|
297
|
+
| `HANDLER` | The handler to use |
|
|
298
|
+
|
|
299
|
+
##### Optional
|
|
300
|
+
|
|
301
|
+
| Option | Description | Default |
|
|
302
|
+
|-------------------|---------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
|
|
303
|
+
| `ROOT_DIR` | | The directory containing the batch configuration file |
|
|
304
|
+
| `DATA_DIR` | Where to find the data files for the batch; relative paths are relative to `ROOT_DIR` | `data` |
|
|
305
|
+
| `LOG_DIR` | Where to write the mapfile, skipfile, and other logging info; relative paths are relative to `ROOT_DIR` | `logs` |
|
|
306
|
+
| `MAPFILE` | Where to store the record of completed items in this batch; relative paths are relative to `LOG_DIR` | `mapfile.csv` |
|
|
307
|
+
| `HANDLER_OPTIONS` | Any additional options required by the handler | |
|
|
308
|
+
|
|
309
|
+
**Note:** The `plastron.load.*.log` files are currently written to the
|
|
310
|
+
repository log directory, *not* to batch log directory.
|
|
311
|
+
|
|
312
|
+
### Ping (ping)
|
|
313
|
+
|
|
314
|
+
```text
|
|
315
|
+
$ plastron ping --help
|
|
316
|
+
usage: plastron ping [-h]
|
|
317
|
+
|
|
318
|
+
Check connection to the repository
|
|
319
|
+
|
|
320
|
+
optional arguments:
|
|
321
|
+
-h, --help show this help message and exit
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Reindex (reindex)
|
|
325
|
+
|
|
326
|
+
```text
|
|
327
|
+
$ plastron reindex --help
|
|
328
|
+
usage: plastron reindex [-h] [-R RECURSIVE] [uris [uris ...]]
|
|
329
|
+
|
|
330
|
+
Reindex objects in the repository
|
|
331
|
+
|
|
332
|
+
positional arguments:
|
|
333
|
+
uris URIs of repository objects to reindex
|
|
334
|
+
|
|
335
|
+
optional arguments:
|
|
336
|
+
-h, --help show this help message and exit
|
|
337
|
+
-R RECURSIVE, --recursive RECURSIVE
|
|
338
|
+
Reindex additional objects found by traversing the
|
|
339
|
+
given predicate(s)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Stub (stub)
|
|
343
|
+
|
|
344
|
+
```text
|
|
345
|
+
$ plastron stub --help
|
|
346
|
+
usage: plastron stub [-h] --identifier-column IDENTIFIER_COLUMN
|
|
347
|
+
--binary-column BINARY_COLUMN
|
|
348
|
+
[--rename-binary-column RENAME_BINARY_COLUMN]
|
|
349
|
+
[--member-of MEMBER_OF] [--access ACCESS]
|
|
350
|
+
[--container CONTAINER_PATH] [-o OUTPUT_FILE]
|
|
351
|
+
source_file
|
|
352
|
+
|
|
353
|
+
create stub resources with just an identifier and binary
|
|
354
|
+
|
|
355
|
+
positional arguments:
|
|
356
|
+
source_file name of the CSV file to create stubs from; use "-" to
|
|
357
|
+
read from STDIN
|
|
358
|
+
|
|
359
|
+
optional arguments:
|
|
360
|
+
-h, --help show this help message and exit
|
|
361
|
+
--identifier-column IDENTIFIER_COLUMN
|
|
362
|
+
column in the source CSV file with a unique identifier
|
|
363
|
+
for each item
|
|
364
|
+
--binary-column BINARY_COLUMN
|
|
365
|
+
column in the source CSV file with the location of the
|
|
366
|
+
binary to load. Supports http: and https: (must begin
|
|
367
|
+
with "http:" or "https:"), and file resources
|
|
368
|
+
(relative or absolute file path). Relative file paths
|
|
369
|
+
are relative to where the command is run.
|
|
370
|
+
--rename-binary-column RENAME_BINARY_COLUMN
|
|
371
|
+
Renames the binary column in the CSV output to the
|
|
372
|
+
provided name.
|
|
373
|
+
--member-of MEMBER_OF
|
|
374
|
+
URI of the object that new items are PCDM members of
|
|
375
|
+
--access ACCESS URI or CURIE of the access class to apply to new items
|
|
376
|
+
--container CONTAINER_PATH
|
|
377
|
+
parent container for new items; defaults to the
|
|
378
|
+
RELPATH in the repo configuration file
|
|
379
|
+
-o OUTPUT_FILE, --output-file OUTPUT_FILE
|
|
380
|
+
destination for a copy of the source CSV file with the
|
|
381
|
+
binary-column value replaced with the newly created
|
|
382
|
+
repository URI for the binary; defaults to STDOUT if
|
|
383
|
+
not given
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Update (update)
|
|
387
|
+
|
|
388
|
+
```text
|
|
389
|
+
$ plastron update --help
|
|
390
|
+
usage: plastron update [-h] -u UPDATE_FILE [-R RECURSIVE] [-d]
|
|
391
|
+
[--no-transactions] [--validate] [-m MODEL]
|
|
392
|
+
[--completed COMPLETED] [-f FILE]
|
|
393
|
+
[uris [uris ...]]
|
|
394
|
+
|
|
395
|
+
Update objects in the repository
|
|
396
|
+
|
|
397
|
+
positional arguments:
|
|
398
|
+
uris URIs of repository objects to update
|
|
399
|
+
|
|
400
|
+
optional arguments:
|
|
401
|
+
-h, --help show this help message and exit
|
|
402
|
+
-u UPDATE_FILE, --update-file UPDATE_FILE
|
|
403
|
+
Path to SPARQL Update file to apply
|
|
404
|
+
-R RECURSIVE, --recursive RECURSIVE
|
|
405
|
+
Update additional objects found by traversing the
|
|
406
|
+
given predicate(s)
|
|
407
|
+
-d, --dry-run Simulate an update without modifying the repository
|
|
408
|
+
--no-transactions, --no-txn
|
|
409
|
+
run the update without using transactions
|
|
410
|
+
--validate validate before updating
|
|
411
|
+
-m MODEL, --model MODEL
|
|
412
|
+
The model class to use for validation (Item, Issue,
|
|
413
|
+
Poster, or Letter)
|
|
414
|
+
--completed COMPLETED
|
|
415
|
+
file recording the URIs of updated resources
|
|
416
|
+
-f FILE, --file FILE File containing a list of URIs to update
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Verify (verify)
|
|
420
|
+
|
|
421
|
+
```text
|
|
422
|
+
$ plastron verify -h
|
|
423
|
+
usage: plastron verify [-h] [-l LOG]
|
|
424
|
+
|
|
425
|
+
Verify item URI's are indexed in Solr and display URI's that aren't
|
|
426
|
+
|
|
427
|
+
optional arguments:
|
|
428
|
+
-h, --help show this help message and exit
|
|
429
|
+
-l LOG, --log LOG completed log file from an import job
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Extending
|
|
433
|
+
|
|
434
|
+
### Adding Commands
|
|
435
|
+
|
|
436
|
+
Commands are implemented as a package in `plastron.cli.commands.{cmd_name}`
|
|
437
|
+
that contain, at a minimum, a function named `configure_cli` and a class
|
|
438
|
+
named `Command`.
|
|
439
|
+
|
|
440
|
+
The `configure_cli` function takes an [argparse subparsers object] and
|
|
441
|
+
creates and configures a subparser to handle its specific command-line
|
|
442
|
+
arguments.
|
|
443
|
+
|
|
444
|
+
The `Command` class should inherit from `plastron.cli.BaseCommand`, and must
|
|
445
|
+
have a `__call__` method that takes an [argparse.Namespace] object, and
|
|
446
|
+
executes the actual command.
|
|
447
|
+
|
|
448
|
+
For a simple example, see the `list` command, as implemented in
|
|
449
|
+
[`plastron.cli.commands.list`](src/plastron/cli/commands/list.py):
|
|
450
|
+
|
|
451
|
+
```python
|
|
452
|
+
import logging
|
|
453
|
+
from argparse import Namespace
|
|
454
|
+
|
|
455
|
+
from plastron.cli.commands import BaseCommand
|
|
456
|
+
from plastron.models.pcdm import PCDMFile
|
|
457
|
+
from plastron.namespaces import ldp
|
|
458
|
+
|
|
459
|
+
logger = logging.getLogger(__name__)
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def configure_cli(subparsers):
|
|
463
|
+
parser = subparsers.add_parser(
|
|
464
|
+
name='list',
|
|
465
|
+
aliases=['ls'],
|
|
466
|
+
description='List objects in the repository'
|
|
467
|
+
)
|
|
468
|
+
# long mode to print more than just the URIs (name modeled after ls -l)
|
|
469
|
+
parser.add_argument(
|
|
470
|
+
'-l', '--long',
|
|
471
|
+
help='Display additional information besides the URI',
|
|
472
|
+
action='store_true'
|
|
473
|
+
)
|
|
474
|
+
parser.add_argument(
|
|
475
|
+
'uris', nargs='*',
|
|
476
|
+
help='URIs of repository objects to list'
|
|
477
|
+
)
|
|
478
|
+
parser.set_defaults(cmd_name='list')
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
class Command(BaseCommand):
|
|
482
|
+
def __call__(self, args: Namespace):
|
|
483
|
+
self.long = args.long
|
|
484
|
+
|
|
485
|
+
for uri in args.uris:
|
|
486
|
+
resource = self.context.repo[uri].read()
|
|
487
|
+
|
|
488
|
+
if resource.is_binary:
|
|
489
|
+
print(uri)
|
|
490
|
+
continue
|
|
491
|
+
|
|
492
|
+
for child_resource in resource.walk(min_depth=1, max_depth=1,
|
|
493
|
+
traverse=[ldp.contains]):
|
|
494
|
+
if self.long:
|
|
495
|
+
description = child_resource.describe(PCDMFile)
|
|
496
|
+
title = str(description.title)
|
|
497
|
+
print(f'{child_resource.url} {title}')
|
|
498
|
+
else:
|
|
499
|
+
print(child_resource.url)
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
The `Command` class has a `context` attribute that contains a
|
|
503
|
+
`PlastronContext` object. This context object provides the following
|
|
504
|
+
objects, configured using the current config file and arguments:
|
|
505
|
+
|
|
506
|
+
| Attribute | Type |
|
|
507
|
+
|-----------------|--------------------------------------|
|
|
508
|
+
| `endpoint` | plastron.client.Endpoint |
|
|
509
|
+
| `client` | plastron.client.Client |
|
|
510
|
+
| `repo` | plastron.repo.Repository |
|
|
511
|
+
| `broker` | plastron.stomp.broker.Broker |
|
|
512
|
+
| `handle_client` | plastron.handles.HandleServiceClient |
|
|
513
|
+
|
|
514
|
+
Any `RuntimeError` exceptions are caught by the `plastron` script and
|
|
515
|
+
cause it to exit with a status code of 1. Any `KeyboardInterrupt`
|
|
516
|
+
exceptions (for instance, due to the user pressing <kbd>Ctrl+C</kbd>) are
|
|
517
|
+
also caught by the `plastron` script and cause it to exit with a status
|
|
518
|
+
code of 2.
|
|
519
|
+
|
|
520
|
+
[argparse subparsers object]: https://docs.python.org/3/library/argparse.html#sub-commands
|
|
521
|
+
[argparse.Namespace]: https://docs.python.org/3/library/argparse.html#the-namespace-object
|