Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

No project description provided

Project description

https://travis-ci.org/gabrielfalcao/gitgraph.svg?branch=master

Instalation

pip install gitgraph

Declaring Subjects

from gitgraph import GitGraph
from gitgraph import Subject

store = GitGraph('my-git-cms')

class Document(Subject):
    indexes = {'title'}
    predicates = (
        ('title', codec.Unicode),
        ('body', codec.Unicode),
        ('created_at', codec.DateTime),
        ('published_at', codec.DateTime),
    )

    incoming = {
        'authored_by': Author,
    }
    outgoing = {
        'contains': Tag,
    }

Create

uuid1 = 'deadbeefdeadbeefdeadbeefdeadbeef'

# providing your own uuid
docs1 = store.create(
    'Document',
    uuid=uuid1,
    title='Essay',
    body='body1',
)

# auto-generated uuid
docs2 = store.create(
    Document,
    title='Blog',
    body='body2',
)

store.commit()

uuid2 = docs2.uuid

Retrieve

One By UUID

# Using the class Document as subject type
docs1 = store.get_subject_by_uuid(Document, uuid1)

# Using the subject label
docs2 = store.get_subject_by_uuid('Document', uuid2)

Many By Indexed Predicate

from gitgraph.query import predicate
# functional
query = lambda title: 'Blog' in title

# DSL
query = predicate('title').contains('Blog')
blog_documents = set(store.match_subjects_by_index(Document, 'title', query))

# With Regex
query = predicate('title').matches('([Bb]log|[Ee]ssa[yi]s?)')
blogs_and_essays = set(store.match_subjects_by_index(Document, 'title', query))

Update

docs1.title = 'new title'

docs2.title = 'documento dois'
docs2.body = '<p>Hello</p>'

store.merge(docs1, docs2)

# recreate the doc1
docs1 = store.create(
    Document,
    uuid=uuid1,
    title='Essay',
    body='body1',
)

Delete

store.delete(docs1)
store.commit()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gitgraph, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size gitgraph-0.1.1.tar.gz (14.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page