viapy Code Documentation

API

class viapy.api.SRUItem(items=None, sequence_type=<type 'tuple'>)[source]

Single item returned by a SRU search, for use with ViafAPI.search() and SRUResult.

label

first main heading for this item

nametype

type of name (personal, corporate, title, etc)

uri

VIAF URI for this result

viaf_id

VIAF numeric identifier

class viapy.api.SRUResult(data)[source]

SRU search result object, for use with ViafAPI.search().

records

list of results as SRUItem.

total_results

number of records matching the query

class viapy.api.ViafAPI[source]

Wrapper for VIAF API.

https://platform.worldcat.org/api-explorer/apis/VIAF

api_base = 'https://www.viaf.org/viaf'

base url for VIAF API methods

find_corporate(name)[source]

Search VIAF for local.corporateNames

find_person(name)[source]

Search VIAF for local.personalNames

find_place(name)[source]

Search VIAF for local.geographicNames

search(query)[source]

Query VIAF seach interface. Returns a list of SRUItem :param query: CQL query in viaf syntax (e.g., cql.any all "term")

suggest(term)[source]

Query autosuggest API. Returns a list of results, or an empty list if no suggestions are found or if something went wrong

uri_base = 'http://viaf.org/viaf'

base url for VIAF URIs

classmethod uri_from_id(viaf_id)[source]

Generate a canonical VIAF URI for the specified id

class viapy.api.ViafEntity(viaf_id)[source]

Object for working with a single VIAF entity.

Parameters:viaf_id – viaf identifier (either integer or uri)
birthdate

schema birthdate as rdflib.Literal

birthyear

birth year

deathdate

schema deathdate as rdflib.Literal

deathyear

death year

rdf

VIAF data for this entity as rdflib.Graph

uriref

VIAF URI reference as instance of rdflib.URIRef

classmethod year_from_isodate(date)[source]

Return just the year portion of an ISO8601 date. Expects a string, returns an integer

Views

class viapy.views.ViafLookup(**kwargs)[source]

View to provide VIAF suggestions for autocomplete lookup. Based on dal.autocompleteSelect2ListView. Expects search term as query string parameter q. Returns viaf URI as identifier and display form as text.

get(request, *args, **kwargs)[source]

Return JSON with suggested VIAF ids and display names.

class viapy.views.ViafSearch(**kwargs)[source]

View to provide VIAF suggestions for autocomplete lookup. Based on dal.autocompleteSelect2ListView. Expects search term as query string parameter q. Returns viaf URI as identifier and display form as text.

get(request, *args, **kwargs)[source]

Return JSON with suggested VIAF ids and display names.

Widgets

class viapy.widgets.ViafWidget(url=None, forward=None, *args, **kwargs)[source]

Custom autocomplete select widget that displays VIAF id as a link. Extends dal.autocomplete.Select2.

render(name, value, renderer=None, attrs=None)[source]

Call Django render together with render_forward_conf.