goat.authorities package

Submodules

goat.authorities.util module

Helper functions for parsing authority descriptions.

class goat.authorities.util.JSONArray(obj=[])[source]

Bases: list

Adds get support to a list.

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

Return the value of key in the first object in list.

get_list(key=None, *args, **kwargs)[source]

Return the value of key in each object in list.

class goat.authorities.util.JSONData(obj={})[source]

Bases: dict

get(key, *args, **kwargs)[source]
goat.authorities.util.content_picker_factory(env, content_getter=<function <lambda>>, attrib_getter=<function <lambda>>)[source]

Generates a function that retrives the CDATA content or attribute value of an element.

env : dict

function

goat.authorities.util.decompose_path(path_string)[source]

Split a path string into its constituent parts.

path_string : str

path : list attribute : str or None

goat.authorities.util.generate_request(config, glob={})[source]

Generate a function that performs an HTTP request based on the configuration in config.

config : dict glob : dict

function
Expects keyword arguments defined in the configuration. If provided, headers will be pulled out and passed as headers in the request.
goat.authorities.util.get_recursive_pathfinder(nsmap={}, method='find', mult_method='findall')[source]

Generate a recursive function that follows the path in tags, starting at elem.

goat.authorities.util.is_multiple(tag)[source]

Detect the multi-value flag (*) in a path part (tag).

tag : str

tuple
tag name (str), multiple (bool)
goat.authorities.util.parse_json_path(path_string, nsmap={}, picker_factory=<function content_picker_factory>)[source]

Generate a function that will retrieve data of interest from a JSONData object.

path_string
: str
See docs for how this should be written. TODO: write the docs.
nsmap: dict
Not used.

picker_factory : function

function

goat.authorities.util.parse_raw_json(raw)[source]

Parse raw JSON response content.

raw : unicode

lxml.etree.Element

goat.authorities.util.parse_raw_xml(raw)[source]

Parse raw XML response content.

raw : unicode

lxml.etree.Element

goat.authorities.util.parse_result(config, data, path_parser=<function parse_xml_path>, glob={}, nsmap={})[source]

Extract data from an lxml.etree.Element using a configuration schema.

config : dict data : lxml.etree.Element path_parser : function glob : dict nsmap : dict

list

goat.authorities.util.parse_xml_path(path_string, nsmap={}, picker_factory=<function content_picker_factory>)[source]

Generate a function that will retrieve data of interest from an lxml.etree.Element.

path_string
: str
See docs for how this should be written. TODO: write the docs.
nsmap: dict
See the lxml.etree docs.

picker_factory : function

function

goat.authorities.util.passthrough_picker_factory(env, *args, **kwargs)[source]

Generates a function that simply returns a passed lxml.etree.Element.

env : dict

function

Module contents

class goat.authorities.AuthorityManager(configuration)[source]

Bases: object

Configuration-driven manager for authority services.

config
: str
Name of an authority configuration in authorities. Will look for {path}/{config}.json.
path
: str
Location of configurations.
accepts(method, *params)[source]
get(identifier=None, local_identifier=None)[source]

Get a concept record from the configured authority.

Although both identifier and local_identifier are declared as optional, it is a good idea to pass them both and let the configuration sort things out.

identifier
: str
Used to populate the id parameter in the request.
local_identifier
: str
Used to populate the local_id parameter in the request.

dict

search(params)[source]

Search for concept records in the configured authority.

params
: kwargs
Query parameters used to populate the search request.

list

class goat.authorities.ConceptSearchResult(name='', identifier='', **extra)[source]

Bases: object

concept_type
description
identities
local_identifier
raw