Skip to content

Commit 213232d

Browse files
committed
Final action implemented, updated examples
1 parent 74ce8c3 commit 213232d

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ In development.
66

77
Requires: Python 3, python requests library.
88

9-
Final Actions (New DOI Generation) not yet implemented
10-
119
## Examples
1210

1311
Create a record:

caltechdata_write/customize_schema.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def customize_schema(json_record):
2222
json_record['doi'] = identifier
2323
del json_record['identifier']
2424
#will delete other ideintifiers in file
25+
else: #We want tind to generate the identifier
26+
json_record['final_actions'] = [{"type":"create_doi",\
27+
"parameters":{"type":"records","field":"doi"}}]
2528

2629
#Extract description
2730
if "descriptions" in json_record:

edit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
to CaltechDATA repository")
77
parser.add_argument('json_file', nargs=1, help=\
88
'file name for json DataCite metadata file')
9-
parser.add_argument('-ids', nargs='+', help='CaltechDATA IDs')
10-
parser.add_argument('-fnames', nargs='+', help='New Files')
9+
parser.add_argument('-ids', nargs='*', help='CaltechDATA IDs')
10+
parser.add_argument('-fnames', nargs='*', help='New Files')
1111
args = parser.parse_args()
1212

1313
#Get access token from TIND sed as environment variable with source token.bash
@@ -16,4 +16,4 @@
1616
metaf = open(args.json_file[0], 'r')
1717
metadata = json.load(metaf)
1818

19-
Caltechdata_edit(token, args.ids, metadata, args.fnames)
19+
Caltechdata_edit(token, args.ids, metadata, args.fnames, False)

example.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
to CaltechDATA repository")
88
parser.add_argument('json_file',nargs=1, help=\
99
'file name for json DataCite metadata file')
10-
parser.add_argument('-fnames',nargs='+', help='files to attach')
10+
parser.add_argument('-fnames',nargs='*', help='files to attach')
1111
args = parser.parse_args()
1212

1313
#Get access token from TIND sed as environment variable with source token.bash
@@ -16,5 +16,9 @@
1616
metaf = open(args.json_file[0],'r')
1717
metadata = json.load(metaf)
1818

19-
response = Caltechdata_write(metadata,token,args.fnames)
19+
files = args.fnames
20+
if files == None:
21+
files={}
22+
23+
response = Caltechdata_write(metadata,token,files,False)
2024
print(response)

0 commit comments

Comments
 (0)