from __future__ import print_function from catalog.infostore import get_site from catalog.olwrite import Infogami from catalog.read_rc import read_rc rc = read_rc() infogami = Infogami(rc['infogami']) site = get_site() # throwaway bit of code for deleting bad scan records # BPL can't scan microtext keys = site.things({'type': '/type/scan_record', 'locations': '/scanning_center/MBMBN/BPL1MI', 'scan_status': 'NOT_SCANNED'}) while keys: for key in keys: sr = site.withKey(key) print(key) q = { 'key': key, 'type': { 'connect': 'update', 'value': '/type/delete' }, } ret = infogami.write(q, comment="can't scan microtext") assert ret['status'] == 'ok' keys = site.things({'type': '/type/scan_record', 'locations': '/scanning_center/MBMBN/BPL1MI', 'scan_status': 'NOT_SCANNED'})
from __future__ import print_function from catalog.infostore import get_site from catalog.read_rc import read_rc import web, sys, codecs, os.path, re from pprint import pprint from catalog.olwrite import Infogami site = get_site() import psycopg2 rc = read_rc() infogami = Infogami(rc['infogami']) infogami.login('EdwardBot', rc['EdwardBot']) re_marc_name = re.compile('^(.*), (.*)$') re_end_dot = re.compile('[^ ][^ ]\.$', re.UNICODE) out = open('author_replace3', 'w') # find books with matching ISBN and fix them to use better author record def flip_name(name): # strip end dots like this: "Smith, John." but not like this: "Smith, J." m = re_end_dot.search(name) if m: name = name[:-1] m = re_marc_name.match(name) return m.group(2) + ' ' + m.group(1) conn = psycopg2.connect("dbname='%s' user='******' host='%s' password='******'" \ % ('ol_merge', rc['user'], rc['host'], rc['pw']));
from catalog.olwrite import Infogami from catalog.read_rc import read_rc import sys rc = read_rc() infogami = Infogami(rc['infogami']) infogami.login('EdwardBot', rc['EdwardBot']) name = sys.argv[1] q = { 'create': 'unless_exists', 'name': name, 'personal_name': name, 'entity_type': 'person', 'key': infogami.new_key('/type/author'), 'type': '/type/author', } print infogami.write(q, comment='create author')
from __future__ import print_function from catalog.infostore import get_site from catalog.olwrite import Infogami from catalog.read_rc import read_rc rc = read_rc() infogami = Infogami(rc['infogami']) site = get_site() # throwaway bit of code for deleting bad scan records # BPL can't scan microtext keys = site.things({ 'type': '/type/scan_record', 'locations': '/scanning_center/MBMBN/BPL1MI', 'scan_status': 'NOT_SCANNED' }) while keys: for key in keys: sr = site.withKey(key) print(key) q = { 'key': key, 'type': { 'connect': 'update', 'value': '/type/delete' }, } ret = infogami.write(q, comment="can't scan microtext") assert ret['status'] == 'ok'