Skip to content

Instantly share code, notes, and snippets.

@lawlesst
lawlesst / openurl_to_bibjson.py
Created March 20, 2012 20:57
Attempts to map OpenURLs to BibJSON
"""
Attempts to parse raw OpenURLs to the BibJSON convention.
"""
import urllib
import urlparse
import sys
import json
from pprint import pprint
@lawlesst
lawlesst / api.py
Created March 13, 2012 20:49
Simple setup for a Tastypie and Solr
"""
Simple setup for tastypie with Solr as the backend. This is based off Daniel Lindsley's Pycon 2012 presentation. Minor modifications.
http://speakerdeck.com/u/daniellindsley/p/restful-apis-with-tastypie
http://django-tastypie.readthedocs.org/
"""
import pysolr
Name|LCNAF
Aaron, Hank|n80126307
Abel, I. W.|n85185062
Abernathy, Ralph|n87870916
Abourezk, James|
Abrams, Robert|
Abt, John|n92122744
Abzug, Bella|n83231578
Acosta, Jerry|
Acosta, Roberto|n84134984
@lawlesst
lawlesst / brown_gadget.xml
Created December 6, 2011 15:40
Brown Sciverse Vufind gadget
<Module><ModulePrefs title="VuFindGadget"
description="&lt;p&gt;This application will search the Brown University collections and display relevant results alongside search
results from SciVerse Hub and ScienceDirect. Clicking on a result will take the user to the Brown University library
website, where more results and services will be available.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;The application was built from the &lt;a href=&quot;http://www.applications.sciverse.com/action/appDetail/293706&quot;&gt;VuFind Template app&lt;/a&gt; for SciVerse developed at Villanova University. If your institution uses VuFind to power its library catalog a version of this application is easy to create for your institution. Learn more about the VuFind Template app to see if such an app on SciVerse can help your institution. Please contact &lt;a href=&quot;http://www.applications.sciverse.com/action/contactus&quot;&gt;Elsevier&lt;/a&gt; to learn more.&lt;/p&gt;
">
<Require feature="sciverse"/>
<Require feature="opensocial-0.9"/>
@lawlesst
lawlesst / openurl.py
Created November 29, 2011 20:12
OpenURL context objects
"""
Really messy attempt at creating OpenURL context
objects for use in link resolver middleware.
Primary use will be to map resolved citiation metadata
from the 360 Link knowledge base and create open url
context objects that can be passed on to other services
- like Illiad - or used in other software.
"""
@lawlesst
lawlesst / innovative-driver.diff
Created November 15, 2011 17:49
Innovative driver patch
Index: web/conf/Innovative.ini
===================================================================
--- web/conf/Innovative.ini (revision 4582)
+++ web/conf/Innovative.ini (working copy)
@@ -1,6 +1,14 @@
[Catalog]
url = http://catalog.library.myuniversity.edu
+; Do not change unless you have changed your indexing routine to
+; strip the leading '.' and trailing check
@lawlesst
lawlesst / oaipmh_marc_harvest.py
Created October 28, 2011 20:57
OAI-PMH harvesting with Python
"""
Harvest MARC records via OAI-PMH.
"""
#Mostly from - http://code.google.com/p/oldmapsonline/source/browse/trunk/oai-pmh/oaipmh-client-pyoai-pymarc.py
# MarcXML reader - parsing done by pymarc
#Handle utf-8 strings
import codecs, sys
@lawlesst
lawlesst / eulxml_updater_demo.py
Created September 15, 2011 12:38
Sample METS update script using eulxml.
from eulxml import xmlmap
from eulxml.xmlmap import load_xmlobject_from_file
MODS_NAMESPACE = 'http://www.loc.gov/mods/v3'
METS_NAMESPACE = 'http://www.loc.gov/METS/'
SF = xmlmap.StringField
class Common(xmlmap.XmlObject):
"MODS class with namespace declaration common to all MODS XmlObjects."
@lawlesst
lawlesst / read_bluebook.py
Created July 23, 2011 15:39
Simple csv reader.
import sys
import csv
csv_file = csv.DictReader(open(sys.argv[1]))
for row in csv_file:
print row['bluebook'], row['journal']
@lawlesst
lawlesst / write_marc_from_xls.py
Created July 23, 2011 13:21
Create MARC records from a spreadsheet
import xlrd, sys
from pymarc import Field, Reader, Record, MARCWriter
#script timer
import time
start_time = time.time()
"""Script that reads data from an Excel sheet and converts the records to MARC format.
Sample incoming data is in Chinese, UTF 8. Would work for other languages as well.