没有项目描述

gitgraph的Python项目详细描述


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

安装

pip install gitgraph

申报对象

fromgitgraphimportGitGraphfromgitgraphimportSubjectstore=GitGraph('my-git-cms')classDocument(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,}

创建

uuid1='deadbeefdeadbeefdeadbeefdeadbeef'# providing your own uuiddocs1=store.create('Document',uuid=uuid1,title='Essay',body='body1',)# auto-generated uuiddocs2=store.create(Document,title='Blog',body='body2',)store.commit()uuid2=docs2.uuid

检索

一个由uuid

# Using the class Document as subject typedocs1=store.get_subject_by_uuid(Document,uuid1)# Using the subject labeldocs2=store.get_subject_by_uuid('Document',uuid2)

多按索引谓词

fromgitgraph.queryimportpredicate# functionalquery=lambdatitle:'Blog'intitle# DSLquery=predicate('title').contains('Blog')blog_documents=set(store.match_subjects_by_index(Document,'title',query))# With Regexquery=predicate('title').matches('([Bb]log|[Ee]ssa[yi]s?)')blogs_and_essays=set(store.match_subjects_by_index(Document,'title',query))

更新

docs1.title='new title'docs2.title='documento dois'docs2.body='<p>Hello</p>'store.merge(docs1,docs2)# recreate the doc1docs1=store.create(Document,uuid=uuid1,title='Essay',body='body1',)

删除

store.delete(docs1)store.commit()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
将PHP生成的公钥转换为Java公钥   java在服务中启动可取消的后台任务   java我能做这个通用的事情吗?   java Axis 1.4.1版在IBM上的部署为8.5版   java如何进行同步web服务调用   java从Spring控制器中的多个select获取值   java如何在JFrame中声明类(包含sapache Poi)的对象   jaxb反序列化XML以在Java中动态创建类   java如何为部署在Google云上的应用程序实现Google OAuth?   java我想了解libgdx的资产管理器   Java整数溢出   Windows任务管理器javaw。exe内存与Java任务控制   java如何让Android等待?