forked from liuhf1980/pythonAutoYes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.py
More file actions
74 lines (61 loc) · 1.84 KB
/
Model.py
File metadata and controls
74 lines (61 loc) · 1.84 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
__author__ = 'xueyan'
#coding:utf-8
import os,csv,xlrd
import sys
BASE_DIR=os.path.dirname(os.path.dirname(__file__))
sys.path.append(BASE_DIR)
import xml.dom.minidom
class Config(object):
def __init__(self):
pass
@staticmethod
def data_dirs():
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DATA_DIRS = (
os.path.join(BASE_DIR, 'Data-Driven'),
)
d='/'.join(DATA_DIRS)
return d
class DataHelper(object):
def __init__(self):
pass
def getList(self):
list=[['','',u'请您填写手机/邮箱/用户名'],['admin','',u'请您填写密码'],['admin','admin',u'请输入验证码']]
return list
def readFile(self,index):
f=open(Config.data_dirs()+'/system.txt','r')
d=f.readlines()
f.close()
return d[index]
def readCsv(self,value1,value2):
rows=[]
data_file=open(Config.data_dirs()+'/system.csv')
reader=csv.reader(data_file)
next(reader,None)
for row in reader:
rows.append(row)
return ''.join(rows[value1][value2]).decode('gb2312')
def readExcel(self,rowValue,colValue):
book=xlrd.open_workbook(Config.data_dirs()+'/system.xlsx')
# xls = ExcelWrite.Workbook()
sheet=book.sheet_by_index(0)
return sheet.cell_value(rowValue,colValue)
def readExcels(self):
rows=[]
book=xlrd.open_workbook(Config.data_dirs()+'/system.xlsx')
sheet=book.sheet_by_index(0)
for row in range(1,sheet.nrows):
rows.append(list(sheet.row_values(row,0,sheet.ncols)))
return rows
def getXmlData(self,value):
dom=xml.dom.minidom.parse(Config.data_dirs()+"/system.xml")
db=dom.documentElement
name=db.getElementsByTagName(value)
nameValue=name[0]
return nameValue.firstChild.data
def getXmlUser(self,parent,child):
dom=xml.dom.minidom.parse(Config.data_dirs()+"/system.xml")
db=dom.documentElement
itemlist=db.getElementsByTagName(parent)
item=itemlist[0]
return item.getAttribute(child)