Skip to content

Commit d5d2fb0

Browse files
authored
Merge branch 'master' into master
2 parents 6e55602 + ac35b3a commit d5d2fb0

35 files changed

+481
-27
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Network Trash Folder
4646
Temporary Items
4747
.apdisk
4848
secrets.py
49+
secretsProd.py
4950
*.pyc
5051
data/*
5152
!data/.keep
@@ -55,3 +56,4 @@ data/*
5556
local/*
5657
*.xml
5758
*.xslx
59+
*.txt

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ All of these scripts require a secrets.py file in the same directory that must c
88
user='[user name]'
99
password='[password]'
1010

11+
This secrets.py file will be ignored according to the repository's .gitignore file so that ArchivesSpace login details will not be inadvertently exposed through GitHub.
12+
13+
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 access the production server if you really intend to.
14+
1115
## Scripts
1216

1317
#### [addBibNumbersAndPost.py](/addBibNumbersAndPost.py)
@@ -67,6 +71,9 @@ Retrieves all of the top containers from a particular repository into a JSON fil
6771
#### [getUrisAndIds.py](getUrisAndIds.py)
6872
For the specified record type, retrieves URI and the 'id_0,' 'id_1,' 'id_2,' 'id_3,' and a concatenated version of all the 'id' fields.
6973

74+
#### [modifyDigitalObjectUrls.py](/modifyDigitalObjectUrls.py)
75+
Based on user input, replaces a string in the URLs in both the 'Identifier' and 'File URI' fields for digital objects across the repository.
76+
7077
#### [postContainersFromCSV.py](/postContainersFromCSV.py)
7178
Creates instances (consisting of top_containers) from a separate CSV file. The CSV file should have two columns, indicator and barcode. The directory where this file is stored must match the directory in the filePath variable. The script will prompt you first for the exact name of the CSV file, and then for the exact resource or accession to attach the containers to.
7279

addBibNumbersAndPost.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
import secrets
44
import time
55
import csv
6+
from datetime import datetime
7+
8+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
9+
if secretsVersion != '':
10+
try:
11+
secrets = __import__(secretsVersion)
12+
print 'Editing Production'
13+
except ImportError:
14+
print 'Editing Development'
15+
else:
16+
print 'Editing Development'
617

718
startTime = time.time()
819

@@ -16,7 +27,7 @@
1627

1728
urisBibs = csv.DictReader(open(''))
1829

19-
f=csv.writer(open('bibNumberPush.csv', 'wb'))
30+
f=csv.writer(open('bibNumberPush'+datetime.now().strftime('%Y-%m-%d %H.%M.%S')+'.csv', 'wb'))
2031
f.writerow(['uri']+['existingValue']+['bibNum'])
2132

2233
for row in urisBibs:

dateCheck.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
import time
55
import csv
66

7+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
8+
if secretsVersion != '':
9+
try:
10+
secrets = __import__(secretsVersion)
11+
print 'Editing Production'
12+
except ImportError:
13+
print 'Editing Development'
14+
else:
15+
print 'Editing Development'
16+
717
startTime = time.time()
818

919
baseURL = secrets.baseURL

eadToCsv.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ def extractValuesFromComponentLevel (componentLevel):
77
unittitle = componentLevel.find('did').find('unittitle').text.replace('\n','').encode('utf-8')
88
controlAccess = []
99
originationList = []
10+
try:
11+
physdesc = componentLevel.find('did').find('physdesc').text.replace('\n','').encode('utf-8')
12+
except:
13+
physdesc = ''
1014
try:
1115
unitdate = componentLevel.find('did').find('unitdate')
1216
dateExpression = unitdate.text.encode('utf-8').replace('\n','').replace(' ',' ').replace(' ',' ').encode('utf-8')
@@ -73,22 +77,19 @@ def extractValuesFromComponentLevel (componentLevel):
7377
originationList = ''
7478
global sortOrder
7579
sortOrder += 1
76-
f.writerow([sortOrder]+[level]+[componentLevelLabel]+[containerType1]+[container1]+[containerType2]+[container2]+[unittitle]+[dateExpression]+[dateType]+[beginDate]+[endDate]+[scopecontent]+[controlAccess]+[originationList]+[containerId1]+[containerId2])
80+
f.writerow([sortOrder]+[level]+[componentLevelLabel]+[containerType1]+[container1]+[containerType2]+[container2]+[unittitle]+[physdesc]+[dateExpression]+[dateType]+[beginDate]+[endDate]+[scopecontent]+[controlAccess]+[originationList]+[containerId1]+[containerId2])
7781

78-
filepath = '/home/mjanowi3/archivesspace-api'
7982
filepath = ''
80-
fileName = 'Coll.011.xml'
83+
fileName = 'Coll.004_20181012_144804_UTC__ead.xml'
8184
xml = open(filepath+fileName)
8285

83-
84-
8586
f=csv.writer(open(filepath+'eadFields.csv', 'wb'))
86-
f.writerow(['sortOrder']+['hierarchy']+['level']+['containerType1']+['container1']+['containerType2']+['container2']+['unittitle']+['dateexpression']+['datetype']+['begindate']+['enddate']+['scopecontent']+['controlAccess']+['origination']+['containerId1']+['containerId2'])
87+
f.writerow(['sortOrder']+['hierarchy']+['level']+['containerType1']+['container1']+['containerType2']+['container2']+['unittitle']+['physdesc']+['dateexpression']+['datetype']+['begindate']+['enddate']+['scopecontent']+['controlAccess']+['origination']+['containerId1']+['containerId2'])
8788
upperComponentLevels = BeautifulSoup(xml, 'lxml').find('dsc').find_all('c01')
8889
sortOrder = 0
8990
for upperComponentLevel in upperComponentLevels:
9091
componentLevelLabel = upperComponentLevel['level']
91-
unittitle = upperComponentLevel.find('did').find('unittitle').text.encode('utf-8')
92+
unittitle = upperComponentLevel.find('did').find('unittitle').text.encode('utf-8').replace('\n','').replace(' ', ' ')
9293
try:
9394
unitdate = upperComponentLevel.find('did').find('unitdate')
9495
dateExpression = unitdate.text.encode('utf-8').replace('\n','').replace(' ',' ').replace(' ',' ').encode('utf-8')
@@ -117,7 +118,7 @@ def extractValuesFromComponentLevel (componentLevel):
117118
except:
118119
scopecontent = ''
119120
sortOrder += 1
120-
f.writerow([sortOrder]+['c01']+[componentLevelLabel]+['']+['']+['']+['']+[unittitle]+[dateExpression]+[dateType]+[beginDate]+[endDate]+[scopecontent]+['']+['']+['']+[''])
121+
f.writerow([sortOrder]+['c01']+[componentLevelLabel]+['']+['']+['']+['']+[unittitle]+['']+[dateExpression]+[dateType]+[beginDate]+[endDate]+[scopecontent]+['']+['']+['']+[''])
121122

122123
componentLevelArray = upperComponentLevel.find_all('c02')
123124
for componentLevel in componentLevelArray:

getAccessionUDFs.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
import time
55
import csv
66

7-
startTime = time.time()
7+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
8+
if secretsVersion != '':
9+
try:
10+
secrets = __import__(secretsVersion)
11+
print 'Editing Production'
12+
except ImportError:
13+
print 'Editing Development'
14+
else:
15+
print 'Editing Development'
816

9-
def findKey(d, key):
10-
if key in d:
11-
yield d[key]
12-
for k in d:
13-
if isinstance(d[k], list) and k == 'children':
14-
for i in d[k]:
15-
for j in findKey(i, key):
16-
yield j
17+
startTime = time.time()
1718

1819
baseURL = secrets.baseURL
1920
user = secrets.user

getAccessions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
import secrets
44
import time
55

6+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
7+
if secretsVersion != '':
8+
try:
9+
secrets = __import__(secretsVersion)
10+
print 'Editing Production'
11+
except ImportError:
12+
print 'Editing Development'
13+
else:
14+
print 'Editing Development'
15+
616
startTime = time.time()
717

818
baseURL = secrets.baseURL

getAllArchivalObjectTitles.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
import time
55
import csv
66

7+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
8+
if secretsVersion != '':
9+
try:
10+
secrets = __import__(secretsVersion)
11+
print 'Editing Production'
12+
except ImportError:
13+
print 'Editing Development'
14+
else:
15+
print 'Editing Development'
16+
717
startTime = time.time()
818

919
baseURL = secrets.baseURL

getArchivalObjectCountByResource.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
import time
55
import csv
66

7+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
8+
if secretsVersion != '':
9+
try:
10+
secrets = __import__(secretsVersion)
11+
print 'Editing Production'
12+
except ImportError:
13+
print 'Editing Development'
14+
else:
15+
print 'Editing Development'
16+
717
startTime = time.time()
818

919
def findKey(d, key):

getArchivalObjectRefIdsForResource.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
import time
55
import csv
66

7+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
8+
if secretsVersion != '':
9+
try:
10+
secrets = __import__(secretsVersion)
11+
print 'Editing Production'
12+
except ImportError:
13+
print 'Editing Development'
14+
else:
15+
print 'Editing Development'
16+
717
startTime = time.time()
818

919
def findKey(d, key):

0 commit comments

Comments
 (0)