def detailed_author(cls, contributor): """Turn a Contributor into a detailed <author> tag.""" children = [] children.append(AtomFeed.name(contributor.display_name or "")) sort_name = AtomFeed.makeelement("{%s}sort_name" % AtomFeed.SIMPLIFIED_NS) sort_name.text = contributor.sort_name children.append(sort_name) if contributor.family_name: family_name = AtomFeed.makeelement(AtomFeed.schema_("family_name")) family_name.text = contributor.family_name children.append(family_name) if contributor.wikipedia_name: wikipedia_name = AtomFeed.makeelement( "{%s}wikipedia_name" % AtomFeed.SIMPLIFIED_NS) wikipedia_name.text = contributor.wikipedia_name children.append(wikipedia_name) if contributor.viaf: viaf_tag = AtomFeed.makeelement(AtomFeed.schema_("sameas")) viaf_tag.text = "http://viaf.org/viaf/%s" % contributor.viaf children.append(viaf_tag) if contributor.lc: lc_tag = AtomFeed.makeelement(AtomFeed.schema_("sameas")) lc_tag.text = "http://id.loc.gov/authorities/names/%s" % contributor.lc children.append(lc_tag) return AtomFeed.author(*children)
def authors(cls, work, license_pool, edition, identifier): """Create one or more <author> tags for the given work.""" return [AtomFeed.author(AtomFeed.name(edition.author or ""))]
def test_contributor(self): kwargs = {'{%s}role' % AtomFeed.OPF_NS: 'ctb'} tag = etree.tostring(AtomFeed.author(**kwargs)) assert tag.startswith('<author') assert 'xmlns:opf="http://www.idpf.org/2007/opf"' in tag assert tag.endswith('opf:role="ctb"/>')