Skip to main content

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.

Source Distribution

gitgraph-0.1.1.tar.gz (14.9 kB view details)

Uploaded Source

File details

Details for the file gitgraph-0.1.1.tar.gz.

File metadata

  • Download URL: gitgraph-0.1.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gitgraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f58de52505320fd168ed403fbabe7e2644aded4a4afeb85f954d0d9e60b0bb9b
MD5 e293821b705c15e561cad7dccc66bb23
BLAKE2b-256 1d082ede6dffcde2e364a62a1458a548c5bc8b1ddc4699230801b4f9d8685648

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page