Skip to content

Instantly share code, notes, and snippets.

View zachary-johnson's full-sized avatar

Zach Johnson zachary-johnson

View GitHub Profile
#!/usr/bin/env python
import os, requests, json, sys, logging, ConfigParser
#config = ConfigParser.ConfigParser()
#config.read('local_settings.cfg')
#dictionary = {'baseURL': config.get('ArchivesSpace', 'baseURL'), 'repository':config.get('ArchivesSpace', 'repository'), 'user': config.get('ArchivesSpace', 'user'), 'password': config.get('ArchivesSpace', 'password'), 'destination': config.get('Destinations', 'EADdestination')}
# parses arguments, if any. This allows you to pass in an string to match against resource IDs
exportIds = sys.argv[0]
@zachary-johnson
zachary-johnson / jesse_wills_extract.xq
Last active March 8, 2018 17:31
Attempts at doing something to extract individual snippets from JesseWills FA extracted portion
xquery version "3.1";
let $xml := fn:doc("https://raw.githubusercontent.com/HeardLibrary/finding-aids/master/ASpace/Working%20EADs/WillsJesseEly_MSS_0001_working_pieces.xml")
let $date := fn:data($xml//unitdate)
let $title := fn:data($xml//unittitle)
(: This was just something I was playing around with, trying to figure things out.:)
(: let $new-title := fn:string-join($title, $date) :)
@zachary-johnson
zachary-johnson / JesseWills FA extracted portion
Created March 8, 2018 17:10
Data from Jesse Wills finding aid that needs to be extracted into individual components
<xml>
<unitdate>1952</unitdate>
<unittitle>26 August to Merrill Moore; 26 August to Coley Harwell; F. 1-1.</unittitle>
<unitdate>1954</unitdate>
<unittitle>8 November to George Mayfield; F. 1-1.</unittitle>
<unitdate>1956</unitdate>
<unittitle>15 June to &#34;Red&#34; (Robert Fenn Warren); F. 1-1. 31 July to William F. Orr; F. 6-14. 5 September to William 0. Batts; F. 1-1.</unittitle>
<unitdate>1958</unitdate>
<unittitle>30 April to Allen Tate; 9 June to Allen Tate; 9 June to . &#34;Bill&#34; (William Yandell Elliott); F. 1-1. 17 December to &#34;Lib&#34; (Mrs. R.D. Crabtree); F. 3-4.</unittitle>
<unitdate>1959</unitdate>
@zachary-johnson
zachary-johnson / ASpace auth python
Created February 26, 2018 16:17
Authenticating portion of ArchivesSpace Python scripts
import json
import requests
import secrets
import time
startTime = time.time()
baseURL = secrets.baseURL
user = secrets.user
password = secrets.password
xquery version "3.1";
declare default element namespace "http://www.w3.org/1999/xhtml";
(: This returns html because we have told it to only validate if it's actually html. <ead>1</ead> wouldn't work. Unless we "call" the html schema, it won't actually check to see if it's a valid html doc. :)
declare function local:template($title as xs:string, $h1 as xs:integer, $p as xs:string) as element(html) {
<html>
<head>
<title>{$title||" - "}</title>
</head>
@zachary-johnson
zachary-johnson / xquery attempt so far
Created October 4, 2017 20:40
Xquery attempt so far
(: This is as far as we got with the xquery command, simply trying to return the data contained in <unitdate> in a single doc for now.:)
xquery version "3.0";
declare namespace ead="http://www.loc.gov/ead/eadschema.html";
let $doc := fn:doc('aspace/HendrixNancy_MSS_206.xml')
let $unitdate := $doc//dsc//unitdate/text()
return $unitdate
@zachary-johnson
zachary-johnson / aspace auth error
Created August 10, 2017 16:53
The authentication error I receive when attempting a GET request
<!DOCTYPE html>
<html>
<head>
<title>ArchivesSpace | Unable to Access Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="stylesheet" media="all" href="/assets/themes/default/bootstrap-d662512eb493113e29487fbc67ec38b75998a7c041f50e7c5e76141e91fc2268.css" /><link rel="stylesheet" media="all" href="/assets/themes/default/application-6d226e82339dfe9f7363502696893ed07c361f4e8e5099119bbabf4ab3e670c7.css" />
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="ssi0nLx8zG/OgiHixpOFBu6l6u+sB+PwQjXSq/mZH+z+HBEB9BfzTTI/QD/1ATna0KX0WGE9ZUGZMyn6cCu6tw==" />
@zachary-johnson
zachary-johnson / mss.102_ead.xml
Created July 17, 2017 14:44
EAD template using MSS.102
<?xml version="1.0" encoding="utf-8"?>
<ead xmlns="urn:isbn:1-931666-22-9" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd">
<eadheader countryencoding="iso3166-1" dateencoding="iso8601" findaidstatus="completed" langencoding="iso639-2b" repositoryencoding="iso15511">
<eadid countrycode="US"></eadid>
<filedesc>
<titlestmt>
<!-- The filing title is the one listed on the Manuscripts register, typically last name, first name. Note the 'faculty' designation. -->
<titleproper type="filing">Davie2, Donald Papers - Faculty</titleproper>
<!-- This is the proper finding aid title found at the beginning at the finding aid. Note that the filing title is different than the titleproper field. -->
<titleproper>Finding Aid for the Donald Davie2 Papers</titleproper>