provit package

Submodules

provit.agent module

Everything agent profile related

  1. Classes
  • Person
  • SoftwareAgent
  • Organization

Each class contains :to_json(): and :graph(): functions, returning the data of the classes either as json-dict or rdflib Graph.

  1. Helper functions
  • load_agent_profile(slug) loads the yaml file of agent :slug: and initiates the respective agent class (depending on type)
  • load_agent_profiles() loads all agent yaml files and returns a list of agent classes
  • agent_factory(slug, type_) initializes an agent class of type :type_: with id/uri :slug:
class provit.agent.OrganizationAgent(slug, name=[], homepage=[], uri='')[source]

Bases: object

graph()[source]
to_json()[source]
update(data)[source]
class provit.agent.PersonAgent(slug, name=[], institution=[], homepage=[], email=[], uri='')[source]

Bases: object

graph()[source]
to_json()[source]
update(data)[source]
class provit.agent.SoftwareAgent(slug, name=[], version=[], homepage=[], uri='')[source]

Bases: object

graph()[source]
to_json()[source]
update(data)[source]
provit.agent.agent_factory(slug, type_)[source]

return “empty” agent class instance of the specified type

provit.agent.load_agent_profile(slug)[source]

loads agent yaml profile (if available) and initiates agent class with the values obtained from the yaml file

provit.agent.load_agent_profiles()[source]

provit.cli module

provit.config module

provit configuration module

provides the Config-class as well as its factory method get_config.

By default, $HOME/.provit is assumed to be provits default config directory. This can be customized.

class provit.config.Config(provit_dir: pathlib.Path, person: str = 'Person', software: str = 'SoftwareAgent', organization: str = 'Organization', base_uri: str = 'http://vocab.ub.uni-leipzig.de/provit/{}')[source]

Bases: object

agent_profile(slug)[source]
agent_profile_exists(slug)[source]
agents_dir
base_uri = 'http://vocab.ub.uni-leipzig.de/provit/{}'
directories_file
get_agent_profile(slug)[source]
organization = 'Organization'
person = 'Person'
software = 'SoftwareAgent'
provit.config.get_config(provit_dir=None)[source]

factory method for Config class. can be given a custom provit dir. If no directory is given, the default directory ~/.provit will be chosen.

provit.home module

Helper functions for accessing data in the provit home directory

provit.home.add_directory(directory, directories_file=None)[source]

Add directory to project directories list

provit.home.load_directories(directories_file=None)[source]

load the list of directories from the directories yaml file

provit.home.remove_directories(directory)[source]

Remove directories from project directory list

provit.namespaces module

provit.prov module

Provenance class handles provenance metadata information.

Use:

from pit.prov import Provenance

#load prov data for a file, or create new prov for file prov = Provenance(<filepath>)

#add provenance metadata prov.add(agent=”agent”, activity=”activity”, description=”…”) prov.add_primary_source(“primary_source”, url=”http://…”, comment=”…”) prov.add_sources([“filepath1”, “filepath2”])

#return provenance as json tree prov_dict = prov.tree()

#save provenance metadata into “<filename>.prov” file prov.save()

class provit.prov.Provenance(filepath, namespace=None, overwrite=False)[source]

Bases: object

Provenance class handles the provenance metadata graph

add(agents, activity, description, started_at='', ended_at='')[source]

Add new basic provenance information (agent, activity) to file

add_graph(graph)[source]
add_primary_source(primary_source, url=None, comment=None)[source]

Adds primary source (+ url and comment) to provenance information

add_sources(filepaths, add_prov_to_source=True)[source]

Add provenance information from source file (wasDerivedFrom) to provenance graph If source file does not have valid provenance data, a prov graph for the source file is initialized

get_agents(include_primary_sources=False)[source]

Returns agent profiles from prov graph

get_current_location()[source]

Returs the file location of root element

get_primary_sources(root_entity=None)[source]

Returns the URIs of all primary sources in prov graph

iter_remove(root_uri)[source]
remove_last_event()[source]

removes the last provenance event and all sources, if they do not belong to the same file

save()[source]

Serializes prov graph as json-ld and saves it to file

tree()[source]

Returns of dict tree with provenance information

provit.prov.load_prov(filepath, namespace=Namespace('http://vocab.ub.uni-leipzig.de/provit/'))[source]

Loads a Provenance Object from the given file path or returns None if no (valid) provenance file was found. :param filepath: :return:

provit.prov.load_prov_files(directory)[source]

provit.utils module

provit.utils.load_jsonld(filepath)[source]

Reads json-ld file and returns (rdfslib) graph and context

provit.utils.provit_uri(slug)[source]
provit.utils.walk_up(start_dir)[source]

Walks up directory tree from :start_dir: and returns directory paths

Module contents