Skip to content

Commit

Permalink
issue #2; started generating required elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Danstrom committed Jul 12, 2017
1 parent 53fc259 commit 4b035fe
Showing 1 changed file with 46 additions and 21 deletions.
67 changes: 46 additions & 21 deletions mamlukimport/metadata_generatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
rights.url -> MSR rights URL
rights.rightsStatement -> duplication of rights
source -> should refer to this being digital version of old printed version
creator
title
publisher
date.copyright
relation.isFormatOf OR relation.isPartOf
rights.url
rights.rightsStatement
source
type
"""

class Generator(object):
Expand All @@ -21,33 +32,47 @@ def __init__(self, data, fields):

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
authors = self.data["author"].split(';')
for n in authors:
new_au_el = SubElement(root, 'dcvalue')
new_au_el.set("element", "contributor")
new_au_el.set("qualifier", "author")

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

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
mimetype_el = SubElement(root, "dcvalue")
mimetype_el.set("element", "date")
mimetype_el.set("qualifier", "copyright")

rights_url_el = SubElement(root, "dcvalue")
rights_url_el.set("element", "rights")
rights_url_el.set("qualifier", "url")

source_el = SubElement(root, "dcvalue")
source_el.set("element", "source")
source_el.set("qualifier", "none")

rights_state_el = SubElement(root, "dcvalue")
rights_state_el.set("element", "rights")
rights_state_el.set("qualifier", "rightsStatement")

if self.type == 'article':
is_part_of = SubElement(root, "dcvalue")
rights_state_el.set("element", "relation")
rights_state_el.set("qualifier", "isPartOf")

if self.type == 'volume':
is_format_of = SubElement(root, "dcvalue")
is_format_of.set("element", "relation")
is_format_of.set("qualifier", "isFormatOf")

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

0 comments on commit 4b035fe

Please sign in to comment.