扩展Yapping和评论管理的工具
eyap的Python项目详细描述
Eyap简介
eyap包是一个扩展的yapping和注释管理 用python编写的系统。基本目标是提供 评论管理系统,可用于各种后端。
快速启动
以下示例来自 `eyap/__init__.py<;https://github.com/emin63/eyap/blob/master/eyap/__init__.py>;`\
使用eyap,您可以选择一个后端来管理您的评论。关键目标 Eyap包的一个特点是,您可以用一种通用的方式编写代码,并且 轻松切换后端。例如,您可以使用一个简单的文件 后端类似于以下内容:
>>> import eyap, tempfile, os, shutil # Import some things used for demo. >>> backend = 'file' # Use a simple file backend for demo. >>> finfo = {'owner': 'emin63', 'realm': tempfile.mkdtemp(), 'topic': 'test'} >>> comment_thread = eyap.Make.comment_thread('file', **finfo) >>> comment_thread.add_comment('Testing things', allow_create=True) >>> comment_thread.add_comment('is great!')
上面的代码将创建一个新的注释线程并向其添加注释 同时还创建线程,如果线程不存在。以后,你可以 通过以下方式访问线程:
>>> print(str(comment_thread.lookup_comments())) # doctest: +ELLIPSIS ======================================== Subject: Testing things ... Timestamp: ... ---------- Testing things ======================================== Subject: is great! ... Timestamp: ... ---------- is great!存在像EYAP这样的东西的主要原因是你 可以在不同的后端使用几乎完全相同的代码。为了 例如,使用“github”而不是“file”,并将realm/owner设置为 在github中组织/回购,同时为 github访问将从github发布或读取问题。
>>> ginfo = {'owner': 'emin63', 'realm': 'eyap', 'topic': 'Describe usage'} >>> g_thread = eyap.Make.comment_thread('github', **ginfo) >>> print(str(g_thread.lookup_comments())) # doctest: +ELLIPSIS ======================================== Subject: We need a simple description of how to u ... Timestamp: 2017-07-19T22:26:51Z ---------- We need a simple description of how to use eyap. ======================================== Subject: Start with top-level README.md ... Timestamp: 2017-07-19T22:22:56Z ---------- Start with top-level README.md ======================================== Subject: All done! ... Timestamp: 2017-07-19T22:26:51Z ---------- All done!
注意,在上面,我们只从github中读取,因为我们没有 提供任何用户名或密码。如果你有用户名和令牌或者 密码,您也可以将评论发布到github。
请不要贴到上述问题;使用您自己的repo进行测试。:)
最后,我们清理基于文件的后端,因为我们不需要它 不再。
>>> shutil.rmtree(finfo['realm']) # Remove the directory to cleanup test. >>> os.path.exists(finfo['realm']) # Verify we cleaned up. False
后端
我们目前有以下后端可用:
file:一个简单的基于文件的后端。github:读/写 对github问题的评论。redis:使用redis存储注释。你 必须安装redis和redis py(例如 pip install redis)使其工作。
欢迎请求添加更多后端。