semvec/pypi-packages huggingface dataset:
kleio 0.2.3
A simple python implementation of the W3C PROV data model
License: MIT
Keywords: provenance PROV PROV-O rdf

Kleio
=====

`|Build Status| <https://travis-ci.org/tetherless-world/kleio>`_
`|License| <https://github.com/tetherless-world/kleio/blob/master/LICENSE>`_
`|Latest Release| <http://badge.fury.io/py/kleio>`_
`|Downloads| <https://pypi.python.org/pypi/kleio/>`_

A python library for W3C Provenance Data Model supporting PROV-O.

Kleio is free software released under the MIT license.

Features
--------

-  An implementation of the W3C PROV Data Model in Python
-  Supports serialization and deserialization as PROV-O in RDF/XML,
   Turtle, TriG, N3, NTriples, and JSON-LD formats
-  Supports provenance-of-provenance (PROV bundles) via named graphs
-  Built using `RDFlib <https://github.com/RDFLib/rdflib>`_

Getting Started
---------------

Kleio can be installed from PyPI using the pip installer:

::

    $ pip install kleio

From kleio use the prov module to generate PROV records and output
PROV-O.

\`\`\`python from kleio import prov

prov.ns("test", "http://tw.rpi.edu/ns/test#")

entity = prov.Entity("test:entity") entity.set\_label("example entity")

activity = prov.Activity("test:activity") activity.set\_label("example
activity")

entity.set\_was\_generated\_by(activity)
print(prov.serialize(format="turtle")) \`\`\` output:

::

    @prefix prov: <http://www.w3.org/ns/prov#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix test: <http://tw.rpi.edu/ns/test#> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    <test:activity> a prov:Activity ;
        rdfs:label "example activity" ;
        prov:generated <test:entity> ;
        prov:influenced <test:entity> .

    <test:entity> a prov:Entity ;
        rdfs:label "example entity" ;
        prov:wasGeneratedBy <test:activity> ;
        prov:wasInfluencedBy <test:activity> .

Kleio can also be used to load and update existing PROV-O records.

::


    from kleio import prov

    # load the existing PROV-O graph
    prov.graph.load("load-example.ttl", format="turtle")

    # get a reference to the existing entity with id="test:entity"
    entity = prov.Entity("test:entity")

    # ... update entity ...

Support
-------

More information is available on the project webpage:

https://github.com/tetherless-world/kleio

Continuous integration status details available from Travis CI:

https://travis-ci.org/tetherless-world/kleio

The documentation can be built by doing:

::

    $ python setup.py build_sphinx

And is also available from ReadTheDocs:

http://kleio.readthedocs.org/en/latest

.. |Build
Status| image:: https://travis-ci.org/tetherless-world/kleio.svg?branch=master
.. |License| image:: http://img.shields.io/badge/license-MIT-brightgreen.svg
.. |Latest Release| image:: https://badge.fury.io/py/kleio.svg
.. |Downloads| image:: https://pypip.in/download/kleio/badge.svg
ok-redis 0.1.2
Object-Key Mapper for Redis
License: MIT

ok |latest-version|
==============================

|build-status| |python-support| |downloads| |license|

Object-Key Mapper for Redis

If you’ve used redis on python, you’ve had to deal with redis keys.
Sometimes, *lots* of redis keys. With so many keys, it’s easy to make
mistakes, especially since keys are just strings. I built ``ok`` so that
I didn’t have to work with strings for redis keys.

Here’s how you use it:

.. code:: python

    import ok
    import redis


    class User(ok.Key):
        fields = ['timeline', 'followers', 'following']


    # Get user mixxorz' timeline
    r = redis.StrictRedis()
    r.zrevrange(User('mixxorz').timeline, 0, 50)
    # ZREVRANGE User:mixxorz:timeline 0 50

Managing your keys just became a lot less fragile.

Installation
------------

Install it from pypi

::

    $ pip install ok-redis

Usage
-----

Access fields.

.. code:: python

    class User(ok.Key):
        fields = ['timeline', 'followers', 'following']


    print(User('mixxorz').timeline)
    # User:mixxorz:timeline

Chain keys.

.. code:: python

    class City(ok.Key):
        fields = ['tweets_hll']


    class Country(ok.Key):
        subkeys = [City]


    print(Country('PH').City('Manila').tweets_hll)
    # Country:PH:City:Manila:tweets

Subkeys can be an absolute or relative path to a key.

.. code:: python

    # mod_one.py
    class Refer(Key):
        fields = ['elements']


    # mod_two.py
    class Parent(Key):
        subkeys = ['..mod_one.Refer']


    print(Parent('foo').Refer('bar').elements)
    # Parent:foo:Refer:bar:elements

The string representation of a `Key` instance is the key, so you can use it like
this:

.. code:: python

    class User(ok.Key):
        pass


    r.get(User('mixxorz'))

But you can also access the key explicitly.

.. code:: python

    User('mixxorz').key
    # >>> User:mixxorz

IDs are optional.

.. code:: python

    class User(ok.Key):
        fields = ['rankings']


    print(User().rankings)
    # User:rankings

IDs don't have to be strings

.. code:: python

    class User(ok.Key)
        pass

    print(User(123))
    # User:123

You can change the string used for the key.

.. code:: python

    class Facebook(ok.Key):
        fields = ['all_posts']
        class_key = 'fb'


    print(Facebook().all_posts)
    # fb:all_posts

License
-------

MIT

.. |latest-version| image:: https://img.shields.io/pypi/v/ok-redis.svg
    :target: https://pypi.python.org/pypi/ok-redis/
    :alt: Latest version
.. |build-status| image:: https://img.shields.io/travis/mixxorz/ok-redis/master.svg
    :target: https://travis-ci.org/mixxorz/ok-redis
    :alt: Build status
.. |python-support| image:: https://img.shields.io/pypi/pyversions/ok-redis.svg
   :target: https://pypi.python.org/pypi/ok-redis
   :alt: Python versions
.. |downloads| image:: https://img.shields.io/pypi/dm/ok-redis.svg
    :target: https://pypi.python.org/pypi/ok-redis/
    :alt: Monthly downloads
.. |license| image:: https://img.shields.io/pypi/l/ok-redis.svg
    :target: https://github.com/behave/ok-redis/blob/master/LICENSE
    :alt: Software license