Skip to content

Commit

Permalink
issue #2: started metadata generator class
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Danstrom committed Jul 6, 2017
1 parent 8ab8568 commit 4abb5fe
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions mamlukimport/metadata_generatory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

from xml.etree.ElementTree import Element, SubElement, Comment, tostring


class Generator(object):
def __init__(self, data, fields):
for n_field in fields:
setattr(self, n_field, data[field])

def generate_metadata(self):
root = Element("dublin_core")
author_el = SubElement(root, 'dcvalue')
author_el.set("element", "contributor")
author_el.set("qualifier", "author")
author_el.text = self.author

date_el = SubElemet(root, "dcvalue")
date_el.set("element", "date")
date_el.set("qualifier", "issued")
date_el.text = self.creationDate

title_el = SubElement(root, "dcvalue")
title_el.set("element", "title")
title_el.set("qualifier", "none")
title_el.text = self.title

mimetype_el = SubElement(root, "dcvalue")
mimetype_el.set("element", "format")
mimetype_el.set("qualifier", "mimetype")
mimetype_el.text = "application/pdf"

for n_keyw in self.keywords.split(';'):
subj_el = SubElement(root, "dcvalue")
subj_el.set("element", "subject")
subj_el.set("qualifier", "none")
subj_el.text = n_keyw

subj_el = SubElement(root, "dcvalue")
subj_el.set("element", "subject")
subj_el.set("qualifier", "none")
subj_el.text = self.subject

0 comments on commit 4abb5fe

Please sign in to comment.