-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regexdict project
- Loading branch information
0 parents
commit cd28746
Showing
22 changed files
with
142,689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
#*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# regexdict changelog | ||
|
||
## 2013-03-16 0.1 | ||
|
||
* First public version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include ChangeLog.txt LICENES.txt README.md requirements.txt | ||
recursive-include test *.py *.sh | ||
recursive-include docs *.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# regexdict | ||
|
||
## 关于 | ||
|
||
regexdict 是一个使用正则表达式查询单词的网站,使用mongodb对正则表达式的支持实现,另外附带了一个不使用数据库的python实现。 | ||
|
||
demo: http://dict.re | ||
|
||
## 目录介绍 | ||
|
||
1. ./ChangeLog.txt :变更历史 | ||
1. ./LICENES.txt :协议 | ||
1. ./MANIFEST.in :文件清单,distutils默认只打包指定模块下的.py文件,其它的要在这里指定 | ||
1. ./README.md :项目介绍 | ||
1. ./requirements.txt :项目需要依赖哪些模块 | ||
1. ./setup.py :安装文件 | ||
1. ./docs/ :文档目录 | ||
1. ./docs/analysis.model.md :概要设计文档 | ||
1. ./docs/design.model.md :详细设计文档 | ||
1. ./docs/maintain.md :维护文档 | ||
1. ./src/ :源码目录 | ||
1. ./src/regexdict : 项目代码 | ||
1. ./src/regexdict/stuff :杂项文件,在setup.py里用package_data参数指定 | ||
1. ./test/ :测试目录 | ||
1. ./test/run_all_test.sh :执行test目录下的所有单元测试 | ||
1. ./test/test_regexdict.py :测试示例 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# regexdict 分析文档 | ||
|
||
此处存放项目的概要设计,简单分析,功能列表等初期文档 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# regexdict 设计文档 | ||
|
||
此处存放项目的详细设计文档,主要算法描述等 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# regexdict 维护文档 | ||
|
||
此处存放一些运维文档,比如运维需要做哪些监控,如何重启服务 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bottle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding:utf-8 -*- | ||
import sys | ||
sys.path.append('./src') | ||
from distutils.core import setup | ||
from pyempty import __version__ | ||
|
||
setup(name='pyempty', | ||
version=__version__, | ||
description='empty python project template', | ||
long_description=open("README.md").read(), | ||
author='onlytiancai', | ||
author_email='onlytiancai@gmail.com', | ||
packages=['pyempty'], | ||
package_dir={'pyempty': 'src/pyempty'}, | ||
package_data={'pyempty': ['stuff']}, | ||
license="Public domain", | ||
platforms=["any"], | ||
url='https://github.com/onlytiancai/pyempty') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
__version__ = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/python | ||
#coding=utf-8 | ||
|
||
import mako | ||
import pymongo | ||
import config | ||
import json | ||
import bottle | ||
from bottle import response | ||
|
||
conn = pymongo.Connection(config.MG_HOST, config.MG_PORT) | ||
redict = conn.redict | ||
redict.authenticate(config.MG_USER, config.MG_PASSWORD) | ||
|
||
@bottle.route('/') | ||
@bottle.mako_view("templates/index.html") | ||
def index(): | ||
return dict() | ||
|
||
@bottle.route('/re/:regex') | ||
@bottle.mako_view("templates/redict.html") | ||
def query(regex): | ||
|
||
try: | ||
regex = regex.replace('"', '').replace("'", '') | ||
regex = '^%s$' % regex | ||
collection = redict.words.find({"_id": {"$regex": regex}}).limit(config.LIMIT) | ||
result = [] | ||
for item in collection: | ||
result.append((item['_id'], item['definition'])) | ||
return dict(result=result) | ||
except Exception, e: | ||
print e | ||
return {} | ||
|
||
@bottle.route('/api/re/:regex') | ||
def rapi(regex): | ||
|
||
regex = regex.replace('"', '').replace("'", '') | ||
regex = '^%s$' % regex | ||
try: | ||
collection = redict.words.find({"_id": {"$regex": regex}}).limit(config.LIMIT) | ||
items = [] | ||
for item in collection: | ||
items.append((item['_id'], item['definition'])) | ||
response.content_type = 'application/json' | ||
result = {'code': 1, 'words': items} | ||
except: | ||
response.content_type = 'application/json' | ||
result = {'code': 0, 'words': []} | ||
return json.dumps(result) | ||
|
||
@bottle.route('/static/<filepath:path>') | ||
def static(filepath): | ||
return bottle.static_file(filepath, root='./static/') | ||
|
||
if __name__ == '__main__': | ||
bottle.run(host=config.HOST, port=config.PORT, debug=config.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/python | ||
#coding=utf-8 | ||
|
||
HOST='localhost' | ||
PORT=8000 | ||
|
||
MG_HOST='127.0.0.1' | ||
MG_PORT=27017 | ||
MG_USER='user' | ||
MG_PASSWORD='password' | ||
LIMIT=50 | ||
DEBUG=False |
Oops, something went wrong.