Skip to content

Commit

Permalink
moved code over from bzr to git
Browse files Browse the repository at this point in the history
  • Loading branch information
edsu committed Aug 12, 2011
0 parents commit 7147f92
Show file tree
Hide file tree
Showing 28 changed files with 1,816 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
01. install python
02. install mysql
03. python setup.py build # should install python dependencies
04. echo "CREATE DATABASE id CHARACTER SET utf8; GRANT ALL ON id.* to '{username}'@'localhost' identified by '{password}';" | mysql -u root -p

05. update DATABASE_USER and DATABASE_PASSWORD in settings.py
06. update MEDIA_ROOT in settings.py to be the full path to the static directory
07. change AUTHORITIES_URL as appropriate in settings.py
08. python manage.py syncdb
09. echo "ALTER table authorities_concept ADD FULLTEXT INDEX concept_fulltext_index (pref_label);" | mysql -u {username} -p id
10. python manage.py load_marcxml marc.xml
11. python manage.py runserver
12. go to http://localhost:8000/authorities
Empty file added __init__.py
Empty file.
Empty file added authorities/__init__.py
Empty file.
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions authorities/management/commands/load_marc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging
import fileinput

from django.core.management.base import BaseCommand
import pymarc

from id.authorities.marc import create_concept, link_concept

class Command(BaseCommand):
help = 'load a marcxml file'
args = '<marcxml filename>+'

def handle(self, *files, **options):
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler('load_marcxml.log')
formatter = logging.Formatter('[%(asctime)s %(levelname)s %(name)s] %(message)s')
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)

for f in files:
logger.info('creating concepts in %s' % f)
for r in pymarc.MARCReader(file(f)):
create_concept(r)

for f in files:
logger.info('linking concepts in: ' + ', '.join(files))
for r in pymarc.MARCReader(file(f)):
link_concept(r)
25 changes: 25 additions & 0 deletions authorities/management/commands/load_marcxml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from django.core.management.base import BaseCommand
from pymarc.marcxml import map_xml

from id.authorities.marc import create_concept, link_concept

class Command(BaseCommand):
help = 'load a marcxml file'
args = '<marcxml filename>+'

def handle(self, *files, **options):
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler('load_marcxml.log')
formatter = logging.Formatter('[%(asctime)s %(levelname)s %(name)s] %(message)s')
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)

logger.info('creating concepts in: ' + ', '.join(files))
map_xml(create_concept, *files)

logger.info('linking concepts in: ' + ', '.join(files))
map_xml(link_concept, *files)
Loading

0 comments on commit 7147f92

Please sign in to comment.