Skip to content

Instantly share code, notes, and snippets.

@djpillen
djpillen / printextents.py
Last active August 29, 2015 14:21
Print Extents from EADs
import lxml
from lxml import etree
import os
from os.path import join
# Enter the path to the folder containing your EADs
path = 'path/to/EADs'
# Check each file in the EAD folder
for filename in os.listdir(path):
@djpillen
djpillen / missingtitles.py
Last active August 29, 2015 14:21
Find missing titles
import lxml
from lxml import etree
import os
from os.path import join
# Enter the path to the folder containing your EADs
path = 'path/to/EADs'
# Check each file in the EAD folder
for filename in os.listdir(path):
@djpillen
djpillen / normalize_dates.py
Last active August 29, 2015 14:21
Add a normal attribute to dates that are years or ranges of years
#import what we need
import lxml
from lxml import etree
import os
from os.path import join
import re
path = 'path/to/EADs' #<-- Change this to your EAD directory path
@djpillen
djpillen / get_non-normalized_dates.py
Last active August 29, 2015 14:23
Output the text of all <unitdate> tags that are not 'undated' and do not have a 'normal' attribute
import csv
import lxml
from lxml import etree
import os
from os.path import join
import re
path = '/path/to/EADs' # Enter the path to your EAD directory
@djpillen
djpillen / replace_normalized_dates.py
Last active August 29, 2015 14:24
Insert normalized dates from an OpenRefine exported CSV into EADs
# import what we need
import csv
from lxml import etree
from os.path import join
path = 'path/to/eads' # Enter the path to your EAD directory here
normalized_file = 'path/to/exported_csv.csv' # Enter the path to the exported CSV here
with open(normalized_file, 'rb') as csvfile:
@djpillen
djpillen / date_tails.py
Last active August 29, 2015 14:25
Find dates with tails
from lxml import etree
import os
from os.path import join
import re
text = re.compile(r'\w')
for filename in os.listdir(path):
tree = etree.parse(join(path,filename))
titles = tree.xpath('//unittitle')
@djpillen
djpillen / Vagrantfile
Created January 18, 2016 16:57
ArchivesSpace Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 8089, host: 8089
@djpillen
djpillen / setup_python.sh
Last active January 18, 2016 17:22
Setup Python for Archivagrant
#!/usr/bin/env bash
# Update packages
apt-get -y update
# Install pip
apt-get -y install python-pip
# Upgrade it
pip install --upgrade pip
@djpillen
djpillen / setup_mysql.sh
Last active January 18, 2016 17:22
Setup MySQL for Archivgrant
#!/usr/bin/env bash
# Export MySQL root password before installing to prevent MySQL from prompting for a password during the installation process
# http://stackoverflow.com/questions/18812293/vagrant-ssh-provisioning-mysql-password
echo "mysql-server mysql-server/root_password password rootpwd" | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password rootpwd" | debconf-set-selections
# Install mysql-server and create the archivesspace database
# http://archivesspace.github.io/archivesspace/user/running-archivesspace-against-mysql/
# https://gist.github.com/rrosiek/8190550
@djpillen
djpillen / setup_archivesspace_1.sh
Last active January 18, 2016 17:40
Setup ArchivesSpace for Archivagrant -- Part 1
#!/usr/bin/env bash
echo "Installing dependencies"
apt-get -y install default-jre
apt-get -y install unzip
apt-get -y install git
cd /vagrant
echo "Downloading latest ArchivesSpace release"