* os.path.split ve range() ile ilgili hatalari duzelt ve debug loglari ekle

This commit is contained in:
Eray Özkural
2005-06-24 15:52:55 +00:00
parent 916bf4535a
commit a256bc0a7d
3 changed files with 18 additions and 5 deletions
+3
View File
@@ -117,10 +117,13 @@ class ArchiveZip(ArchiveBase):
if archiveRoot!='':
# change archiveRoot
if util.subpath(archiveRoot, fileName):
print '!', archiveRoot, fileName
fileName = util.removepathprefix(archiveRoot, fileName)
print '*', fileName
else:
continue # don't extract if not under
ofile = os.path.join(targetDir, fileName)
print 'ofile ', ofile
# a directory is present. lets continue
if ofile[len(ofile)-1]=='/':
+1 -1
View File
@@ -46,7 +46,7 @@ def install(package_fn):
# unzip package in place
ui.info('Extracting files\n')
#package.extract_dir_flat('install', config.destdir)
package.extract_dir_flat('install', config.destdir)
# update databases
+14 -4
View File
@@ -49,9 +49,11 @@ def same(l):
def prefix(a, b):
"check if sequence a is a prefix of sequence b"
print 'PREFIX', a, b
if len(a)>len(b):
return False
for i in range(0,len(a)-1):
for i in range(0,len(a)):
print 'checking', a[i], b[i]
if a[i]!=b[i]:
return False
return True
@@ -63,13 +65,21 @@ def remove_prefix(a,b):
# path functions
def splitpath(a):
"""split path into components and return as a list
os.path.split doesn't do what I want"""
l = a.split(os.path.sep)
if l[len(l)-1]=='':
l.pop()
return l
# I'm not sure how necessary this is. Ahem.
def commonprefix(l):
"""an improved version of os.path.commonprefix,
returns a list of path components"""
common = []
comps = map(os.path.split, l)
for i in range(0, min(len,l)-1):
comps = map(splitpath, l)
for i in range(0, min(len,l)):
compi = map(lambda x: x[i], comps) # get ith slice
if same(compi):
common.append(compi[0])
@@ -78,7 +88,7 @@ def commonprefix(l):
# but this one is necessary
def subpath(a, b):
"find if path a is before b in the directory tree"
return prefix(os.path.split(a), os.path.split(b))
return prefix(splitpath(a), splitpath(b))
def removepathprefix(a, b):
"remove path prefix a from p, finding the pathname rooted at a"