-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
48 lines (39 loc) · 1.24 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#coding=utf-8
import web, datetime
import os
db = web.database(dbn='sqlite', db='blog.db', driver="sqlite3")
def get_posts():
return db.select('entries', order='id DESC')
def get_post(id):
try:
return db.select('entries', where='id=$id', vars=locals())[0]
except IndexError:
return None
def new_post(title, text):
db.insert('entries', title=title, content=text, posted_on=datetime.datetime.utcnow())
def del_post(id):
db.delete('entries', where="id=$id", vars=locals())
def update_post(id, title, text):
db.update('entries', where="id=$id", vars=locals(),
title=title, content=text)
def list_dir(dir):
'''找出目录下的所有文件夹'''
list = os.listdir(dir)
list_name = []
for line in list:
path_name = os.path.join(dir, line)
if os.path.isdir(path_name):
if path_name.find('.') < 0:
list_name.append(line)
return list_name
def get_svn_list():
lists = list_dir("/Users/MacPro_huyubing");
svn_list = {
"test-svn1" : {
"class": "1",
"remarks": "note test-svn1"},
"test-svn2" : {
"class": "2",
"remarks": "some remarks string"}}
print svn_list
return lists