Skip to content

Commit 25db98c

Browse files
author
ehanson8
committed
updates
1 parent 28ddd5d commit 25db98c

13 files changed

+54
-29
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ All of these scripts require a secrets.py file in the same directory that must c
77
password='my_dspace_password'
88
filePath = '/Users/dspace_user/dspace-data-collection/data/'
99
handlePrefix = 'http://dspace.myuni.edu/handle/'
10+
verify = True or False (no quotes). Use False if using an SSH tunnel to connect to the DSpace API
1011
```
11-
The 'filePath' is directory into which output files will be written and 'handlePrefix' may or may not vary from your DSpace URL depending on your configuration. This secrets.py file will be ignored according to the repository's .gitignore file so that DSpace login details will not be inadvertently exposed through Github
12+
The 'filePath' is directory into which output files will be written and 'handlePrefix' may or may not vary from your DSpace URL depending on your configuration. This secrets.py file will be ignored according to the repository's .gitignore file so that DSpace login details will not be inadvertently exposed through Github.
13+
14+
If you are using both a development server and a production server, you can create a separate secrets.py file with a different name (e.g. secretsProd.py) and containing the production server information. When running each of these scripts, you will be prompted to enter the file name (e.g 'secretsProd' without '.py') of an alternate secrets file. If you skip the prompt or incorrectly type the file name, the scripts will default to the information in the secrets.py file. This ensures that you will only edit the production server if you really intend to.
15+
16+
The command 'requests.packages.urllib3.disable_warnings()' is used to disable the excessive warnings that will be produced if the 'verify' variable is set to False, which necessary if you are using an SSH tunnel to connect to the DSpace API.
17+
18+
1219

1320
**Note**: All of these scripts skip collection '24' for local reasons. To change this, edit the following portion of the script (typically between line 27-39)
1421

1522

16-
Skips collection 24:
23+
Skips collection 24:
1724

1825
for j in range (0, len (collections)):
1926
collectionID = collections[j]['id']
2027
if collectionID != 24:
2128
offset = 0
22-
23-
29+
30+
2431
No collections skipped:
2532

2633
for j in range (0, len (collections)):
@@ -29,12 +36,12 @@ No collections skipped:
2936
offset = 0
3037

3138
#### [addKeyValuePairOnHandleCSV.py](addKeyValuePairOnHandleCSV.py)
32-
Based on user input, this script uses a specified CSV file of DSpace item handles and the value to be added to that item using the specified key. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
39+
Based on user input, this script uses a specified CSV file of DSpace item handles and the value to be added to that item using the specified key. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
3340

3441
#### [addKeyValuePairToCollection.py](addKeyValuePairToCollection.py)
3542

3643
#### [createItemMetadataFromCSV.py](createItemMetadataFromCSV.py)
37-
Based on user input, this script created a JSON file of metadata that can be added to a DSpace item from the specified CSV file. The 'createMetadataElement' function in the script is used to create the desired metadata elements based on three variables:
44+
Based on user input, this script created a JSON file of metadata that can be added to a DSpace item from the specified CSV file. The 'createMetadataElement' function in the script is used to create the desired metadata elements based on three variables:
3845
'key' - The Dublin Core property to be used for the element.
3946
'value' - The column in the CSV that contains the data for the element.
4047
'language' - The desired language value for the element
@@ -45,13 +52,13 @@ Based on user input, this script created a JSON file of metadata that can be add
4552
Based on user input, this script creates a community with a specified name and collection with a specified name within that community. In the specified directory (within the filePath set by the secrets.py file), the script creates items and associated metadata based on a 'collectionMetadata.json' file in the directory. Based on the specified file extension, the script then posts each file in the directory with that extension as a bitstream for the appropriate item, which is determined by having the file name (minus the file extension) in a 'dc.identifier.other' field in the item metadata record.
4653

4754
#### [removeDuplicateKeyValuePairsFromItems.py](removeDuplicateKeyValuePairsFromItems.py)
48-
This script finds all items with duplicate key-value pairs and removes the duplicates. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
55+
This script finds all items with duplicate key-value pairs and removes the duplicates. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
4956

5057
#### [replaceKey.py](replaceKey.py)
51-
Based on user input, this script replaces one specified key with another specified key in all item metadata across the repository. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
58+
Based on user input, this script replaces one specified key with another specified key in all item metadata across the repository. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
5259

5360
#### [replaceKeyValuePairsFromCSV.py](replaceKeyValuePairsFromCSV.py)
54-
Based on user input, this scripts updates key-value pairs from the specified CSV file with the columns: 'replacedKey,' 'replacementKey,'replacedValue,' and 'replacementValue.' A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
61+
Based on user input, this scripts updates key-value pairs from the specified CSV file with the columns: 'replacedKey,' 'replacementKey,'replacedValue,' and 'replacementValue.' A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
5562

5663
#### [replaceUnnecessarySpaces.py](replaceUnnecessarySpaces.py)
5764
Based on user input, this script removes double spaces, triple spaces, and spaces before commas in the values from the specified key in the specified community.
@@ -63,4 +70,4 @@ This scripts creates a folder with a timestamp in the folder name and creates a
6370
Based on user input, this script restores the metadata from a specified backup folder that was created by the repositoryMetadataBackup.py script.
6471

6572
#### [updateLanguageTagsForKey.py](updateLanguageTagsForKey.py)
66-
Based on user input, this script updates the language value for the specified key to 'en_us' for all items with that key in the repository. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.
73+
Based on user input, this script updates the language value for the specified key to 'en_us' for all items with that key in the repository. A CSV log is written with all of the changes made and a 'dc.description.provenance' note describing the change is added to the metadata of each item that is updated.

addKeyValuePairOnHandleCSV.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

addKeyValuePairToCollection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

createItemMetadataFromCSV.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def createMetadataElementDirect (key, value, language):
3939
createMetadataElementDirect('dc.language.iso', 'en_US', 'en_US')
4040
createMetadataElementDirect('dc.type', 'Text', 'en_US')
4141
createMetadataElementDirect('dc.format.mimetype','application/pdf', 'en_US')
42+
createMetadataElementDirect('dc.subject','magazines (periodicals)','en_US')
43+
createMetadataElementDirect('dc.subject','Maryland--Baltimore','en_US')
44+
createMetadataElementDirect('dc.subject','Engineering','en_US')
45+
createMetadataElementDirect('dc.subject','City planning','en_US')
4246
# createMetadataElementCSV('dc.relation.ispartof', 'location', 'en_US')
4347
# createMetadataElementCSV('dc.identifier', 'identifier', '')
4448
# createMetadataElementCSV('dc.format.extent', 'size', '')

deleteKeyFromCollection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

postCollection.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password
@@ -75,14 +77,6 @@
7577
files = {'file': open(bitstream, 'rb')}
7678
post = requests.post(baseURL+itemID+'/bitstreams?name='+fileName, headers=headerAuthFileUpload, verify=verify, data=data).json()
7779

78-
79-
# #Post bitstream
80-
# bitstream = directory+'/'+fileIdentifier+fileExtension
81-
# fileName = bitstream[bitstream.rfind('/')+1:]
82-
# data = open(bitstream, 'rb')
83-
# files = {'file': open(bitstream, 'rb')}
84-
# post = requests.post(baseURL+itemID+'/bitstreams?name='+fileName, headers=headerAuthFileUpload, verify=verify, data=data).json()
85-
8680
#Create provenance notes
8781
provNote = {}
8882
provNote['key'] = 'dc.description.provenance'

removeDuplicateKeyValuePairsFromItems.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

replaceKey.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

replaceKeyValuePairsFromCSV.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

replaceUnnecessarySpaces.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
print 'Editing Production'
1313
except ImportError:
1414
print 'Editing Stage'
15-
15+
else:
16+
print 'Editing Stage'
17+
1618
baseURL = secrets.baseURL
1719
email = secrets.email
1820
password = secrets.password

0 commit comments

Comments
 (0)