LDAP-Plan für join²

am FZJ

23 August 2018

Torsten Bronger

Zentralbibliothek, Forschungszentrum Jülich

Python Package structure

2

Class methods

class Person(object):

    def __init__(self, data):
       self.data = data

    def get_id(self):
        return self.data["035__"]["a"]

    def merge(self, other):
        new_person = copy.deepcopy(self)
        if other:
            ...
        return new_person

    def delete(self):
        # Ändere Datenfelder, um Entfernung
        # aus dem LDAP zu realisieren
        ...

    def export_to_xml(self, document):
        document.insertData(self.data)

    def __ne__(self, other):
        return normalized(self.data) != normalized(other.data)
3

update_invenio.py

import subprocess, importlib
from invenio.websubmit_functions import MarcXML_hgf
from invenio.config import CFG_WEBSTYLE_TEMPLATE_SKIN
import invenio_db

backend = importlib.import_module(CFG_WEBSTYLE_TEMPLATE_SKIN)
external_db = backend.ExternalDB()

people = {}
for person in invenio_db.read_people():
    person = backend.Person(person)
    people[person.get_id()] = person

outfile_name = "/tmp/update_invenio.xml"
document = MarcXML_hgf.MarcXMLDocument()

4

update_invenio.py

for person in external_db.read_people():
    person = backend.Person(person)
    old_person = people.get(person.get_id())
    new_person = old_person and old_person.merge(person) or person
    if person != old_person:
        new_person.export_to_xml(document)
    people.pop(old_person.get_id(), None)

for person in people.itervalues():
    person.delete()
    person.export_to_xml(document)

outfile = open(outfile_name, "wb")
outfile.write(document.toxml("utf-8"))
outfile.close()

subprocess.check_call(["bibupload", "-r", outfile_name])
5

Thank you

Torsten Bronger

Zentralbibliothek, Forschungszentrum Jülich

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)