Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb35cf3d

Browse files
committed
Use easy_install for distribution
--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401021
1 parent99cc08b commitb35cf3d

File tree

6 files changed

+63
-19
lines changed

6 files changed

+63
-19
lines changed

‎setup_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromdistutils.coreimportsetup
1+
fromsetuptoolsimportsetup
22
importos
33

44
long_description="""HTML parser designed to follow the WHATWG HTML5
@@ -34,5 +34,7 @@
3434
fornameinos.listdir(os.path.join('src','html5lib'))
3535
ifos.path.isdir(os.path.join('src','html5lib',name))and
3636
notname.startswith('.')],
37-
package_dir= {'html5lib':'src/html5lib'}
37+
package_dir= {'html5lib':'src/html5lib'},
38+
test_suite="tests.buildTestSuite",
39+
tests_require= ['simplejson']
3840
)

‎tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fromruntestsimportbuildTestSuite

‎tests/runtests.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
importglob
44
importunittest
55

6+
#Allow us to import the parent module
7+
os.chdir(os.path.split(os.path.abspath(__file__))[0])
8+
sys.path.insert(0,os.path.abspath(os.curdir))
9+
sys.path.insert(0,os.path.abspath(os.pardir))
10+
11+
612
defbuildTestSuite():
713
suite=unittest.TestSuite()
814
fortestcaseinglob.glob('test_*.py'):
@@ -15,11 +21,4 @@ def main():
1521
ifnotresults.wasSuccessful():sys.exit(1)
1622

1723
if__name__=="__main__":
18-
#Allow us to import the parent module
19-
#RELEASE remove
20-
sys.path.insert(0,os.path.abspath(os.path.join(__file__,'../../src')))
21-
#END RELEASE
22-
os.chdir(os.path.split(os.path.abspath(__file__))[0])
23-
sys.path.insert(0,os.path.abspath(os.pardir))
24-
2524
main()

‎tests/support.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
importhtml5lib
1010
fromhtml5libimporthtml5parser,treebuilders
1111

12+
#Define the location of the tests as this changes in release versions
13+
#RELEASE remove
14+
test_dir=os.path.join(os.path.pardir,os.path.pardir,'testdata')
15+
#END RELEASE
16+
#RELEASE add
17+
#test_dir = './testdata'
18+
#END RELEASE
19+
1220
try:
1321
importsimplejson
1422
except:
@@ -59,7 +67,7 @@ def load(f):
5967
pass
6068

6169
defhtml5lib_test_files(subdirectory,files='*.dat'):
62-
returnglob.glob(os.path.join(os.path.pardir,os.path.pardir,'testdata',subdirectory,files))
70+
returnglob.glob(os.path.join(test_dir,subdirectory,files))
6371

6472
classDefaultDict(dict):
6573
def__init__(self,default,*args,**kwargs):

‎tests/test_encoding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importos
22
importunittest
3-
fromsupportimporthtml5lib_test_files,TestData
3+
fromsupportimporthtml5lib_test_files,TestData,test_dir
44

55
fromhtml5libimportinputstream
66

@@ -23,7 +23,7 @@ def encodingTest(self, data=test['data'], encoding=test['encoding']):
2323
try:
2424
importchardet
2525
deftest_chardet(self):
26-
data=open("../../testdata/encoding/chardet/test_big5.txt").read()
26+
data=open(os.path.join(test_dir,"/chardet/test_big5.txt")).read()
2727
encoding=inputstream.HTMLInputStream(data).charEncoding
2828
assertencoding.lower()=="big5"
2929
setattr(Html5EncodingTestCase,'test_chardet',test_chardet)

‎utils/package.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
classPackage(object):
1616

17-
def__init__(self,inDir,outDir,version=0,status=4,installDir="~"):
17+
def__init__(self,inDir,outDir,version="0",status=4,installDir="~"):
1818
#List of files to remove on exit
1919
self.version=str(version)
2020
self.status=str(status)
@@ -28,20 +28,46 @@ def __init__(self, inDir, outDir, version=0, status=4, installDir="~"):
2828

2929
defrunall(self):
3030
self.getFileList()
31+
self.copyTestData()
3132
self.copy()
3233
self.makeSetupFile()
3334
self.preprocess()
34-
ifself.test():
35-
self.makeZipFile()
36-
self.cleanup()
35+
#if self.test():
36+
self.makeZipFile()
37+
#self.cleanup()
3738

3839

3940
defgetExcludeList(self):
4041
rv= []
4142
foriteminexclude:
4243
rv.append(item.replace("__basedir__",self.inDir))
4344
returnrv
44-
45+
46+
defcopyTestData(self):
47+
outDir="tests/testdata"
48+
try:
49+
os.mkdir(outDir)
50+
exceptOSError:
51+
#the directory already exists
52+
pass
53+
inBaseDir=os.path.abspath(os.path.join(self.inDir,"../testdata"))
54+
dirWalker=os.walk(inBaseDir)
55+
for (curDir,dirs,files)indirWalker:
56+
outDir=os.path.join(self.inDir,"tests","testdata",curDir[len(inBaseDir)+1:])
57+
fordirindirs[:]:
58+
ifself.excludeItem(curDir,dir):
59+
dirs.remove(dir)
60+
else:
61+
try:
62+
os.mkdir(os.path.join(outDir,dir))
63+
exceptOSError:
64+
#the directory already exists
65+
pass
66+
forfninfiles[:]:
67+
ifnotself.excludeItem(curDir,fn):
68+
newFn=os.path.join(outDir,fn)
69+
shutil.copy(os.path.join(curDir,fn),newFn)
70+
self.cleanupFiles.append(newFn)
4571
defgetFileList(self):
4672
"""Get a list of files to copy"""
4773
fileList= []
@@ -95,7 +121,6 @@ def copy(self):
95121
self.outFiles.append(outPath)
96122
ifos.path.isdir(inPath):
97123
try:
98-
99124
os.mkdir(outPath)
100125
exceptOSError:
101126
#File may already exist
@@ -191,4 +216,13 @@ def add(self, line):
191216
defmove(self,line):
192217
self.outPath=os.path.abspath(os.path.join(self.inDir,
193218
line[line.find("move")+4:].strip(),
194-
self.outPath[len(self.inDir)+1:]))
219+
self.outPath[len(self.inDir)+1:]))
220+
dirName=os.path.dirname(self.outPath)
221+
ifnotos.path.exists(dirName):
222+
dirsToCreate= []
223+
whilenotos.path.exists(dirName):
224+
dirsToCreate.append(dirName)
225+
dirName=os.path.dirname(dirName)
226+
227+
foritemindirsToCreate[::-1]:
228+
os.mkdir(item)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp