acdh_arche_pyutils package

Submodules

acdh_arche_pyutils.client module

class acdh_arche_pyutils.client.ArcheApiClient(arche_endpoint, out_dir='.')[source]

Bases: object

Main Class to interact with ARCHE-API

get_resource(res_uri, format='nt')[source]

fetches the given resource and its ancestors/parents

Parameters

res_uri (str) – an ARCHE URI

Returns

A rdflib.Graph object

Return type

rdflib.Graph

top_col_ids()[source]

returns of list of tuples (hasIdentifier, hasTitle) of all TopCollection

write_resource_to_file(res_uri, format='nt')[source]

writes a resource (and its parents/children) to file on disk

Parameters
  • res_uri (str) – An ARCHE-URI

  • format (str) – The serialisation format, defaults to ‘ttl’ -> turtle use ‘xml’ for RDF/XML

Returns

The location of the file

Return type

str

class acdh_arche_pyutils.client.ArcheToTripleStore(triple_store, user=None, pw=None, headers={'Content-Type': 'text/turtle;charset=utf-8'}, **kwargs)[source]

Bases: acdh_arche_pyutils.client.ArcheApiClient

A class to post ARCHE data to a Triplestore

count_triples()[source]

counts all existing triples in the triple store

Returns

The triple count

Return type

int

delete_triples()[source]

deletes everything

post_all_resources()[source]

posts all TopCols to Triple Store

Returns

A list of status codes and response texts and top-col-id

Return type

list

post_resource(res_id)[source]

posts the given resource to the triple store

Parameters

res_uri (str) – An ARCHE-URI

Returns

The HTTP status code of the response and its body

Return type

list

acdh_arche_pyutils.utils module

Some utility functions module.

acdh_arche_pyutils.utils.camel_to_snake(s)[source]

converts CamelCase string to camel_case taken from https://stackoverflow.com/a/44969381

Parameters

s (str:) – some string

Returns

a camel_case string

Return type

str:

acdh_arche_pyutils.utils.create_query_sting(param_dict)[source]

turns a dict into a query string

Parameters

param_dict (dict) – a dictionary

Returns

a clean query string

Return type

str

acdh_arche_pyutils.utils.id_from_uri(uri)[source]

extracts the id from an ARCHE-URL like https://whatever.com/123 -> 123

Parameters

uri (str) – some ARCHE-URL

Returns

the actual ID, e.g. 123

Return type

str:

Module contents

Top-level package for acdh-arche-pyutils.