|
13 | 13 |
|
14 | 14 | logger = structlog.get_logger() |
15 | 15 |
|
| 16 | +cwd = os.getcwd() |
| 17 | + |
| 18 | + |
| 19 | +def validate_path(ctx, param, value): |
| 20 | + """Validates th formatting of The submitted path""" |
| 21 | + if value[-1] == '/': |
| 22 | + return value |
| 23 | + else: |
| 24 | + raise click.BadParameter('Include / at the end of the path.') |
| 25 | + |
16 | 26 |
|
17 | 27 | @click.group(chain=True) |
18 | 28 | @click.option('--url', envvar='DSPACE_URL', required=True,) |
@@ -51,11 +61,13 @@ def main(ctx, url, email, password): |
51 | 61 |
|
52 | 62 | @main.command() |
53 | 63 | @click.option('-m', '--metadata-csv', required=True, |
54 | | - type=click.Path(exists=True), |
| 64 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
55 | 65 | help='The path to the CSV file of metadata for the items.') |
56 | | -@click.option('--field-map', required=True, type=click.Path(exists=True), |
| 66 | +@click.option('--field-map', required=True, |
| 67 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
57 | 68 | help='The path to JSON field mapping file.') |
58 | 69 | @click.option('-d', '--content-directory', required=True, |
| 70 | + type=click.Path(exists=True, dir_okay=True, file_okay=False), |
59 | 71 | help='The full path to the content, either a directory of files ' |
60 | 72 | 'or a URL for the storage location.') |
61 | 73 | @click.option('-t', '--file-type', |
@@ -116,15 +128,19 @@ def newcollection(ctx, community_handle, collection_name): |
116 | 128 |
|
117 | 129 | @main.command() |
118 | 130 | @click.option('-m', '--metadata-csv', required=True, |
| 131 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
119 | 132 | help='The path of the CSV file of metadata.') |
120 | | -@click.option('-o', '--output-directory', default='', required=True, |
| 133 | +@click.option('-o', '--output-directory', |
| 134 | + type=click.Path(exists=True, dir_okay=True, file_okay=False), |
| 135 | + default=f'{cwd}/', callback=validate_path, |
121 | 136 | help='The path of the output files, include / at the end of the ' |
122 | 137 | 'path.') |
123 | 138 | @click.option('-d', '--content-directory', required=True, |
124 | 139 | help='The full path to the content, either a directory of files ' |
125 | 140 | 'or a URL for the storage location.') |
126 | | -@click.option('-t', '--file-type', required=True, |
127 | | - help='The file type to be uploaded.') |
| 141 | +@click.option('-t', '--file-type', |
| 142 | + help='The file type to be uploaded, if limited to one file ' |
| 143 | + 'type.', default='*') |
128 | 144 | def reconcile(metadata_csv, output_directory, content_directory, file_type): |
129 | 145 | """Runs a reconciliation of the specified files and metadata that produces |
130 | 146 | reports of files with no metadata, metadata with no files, metadata |
|
0 commit comments