py3: tools: 2to3

This commit is contained in:
looooo
2018-05-18 16:01:34 +02:00
committed by wmayer
parent ec22a90789
commit 25bd2d2ab1
21 changed files with 491 additions and 488 deletions

View File

@@ -35,26 +35,26 @@ def cpall(dirFrom, dirTo):
"""
global dcount, fcount
for file in os.listdir(dirFrom): # for files/dirs here
print file
print(file)
pathFrom = os.path.join(dirFrom, file)
pathTo = os.path.join(dirTo, file) # extend both paths
if not os.path.isdir(pathFrom): # copy simple files
try:
if verbose > 1: print 'copying', pathFrom, 'to', pathTo
if verbose > 1: print('copying', pathFrom, 'to', pathTo)
cpfile(pathFrom, pathTo)
fcount = fcount+1
except:
print 'Error copying', pathFrom, to, pathTo, '--skipped'
print sys.exc_type, sys.exc_value
print('Error copying', pathFrom, to, pathTo, '--skipped')
print(sys.exc_type, sys.exc_value)
else:
if verbose: print 'copying dir', pathFrom, 'to', pathTo
if verbose: print ('copying dir', pathFrom, 'to', pathTo)
try:
os.mkdir(pathTo) # make new subdir
cpall(pathFrom, pathTo) # recur into subdirs
dcount = dcount+1
except:
print 'Error creating', pathTo, '--skipped'
print sys.exc_type, sys.exc_value
print('Error creating', pathTo, '--skipped')
print(sys.exc_type, sys.exc_value)
def SetUpFilter(MatchList):
RegList = []
@@ -73,27 +73,27 @@ def cpallWithFilter(dirFrom, dirTo,MatchList):
for matchpat in MatchList:
if(re.match(matchpat,file)):
hitt = 1
print 'Refuse: '+file
print('Refuse: '+file)
if hitt == 0:
pathFrom = os.path.join(dirFrom, file)
pathTo = os.path.join(dirTo, file) # extend both paths
if not os.path.isdir(pathFrom): # copy simple files
try:
if verbose > 1: print 'copying', pathFrom, 'to', pathTo
if verbose > 1: print('copying', pathFrom, 'to', pathTo)
cpfile(pathFrom, pathTo)
fcount = fcount+1
except:
print 'Error copying', pathFrom, to, pathTo, '--skipped'
print sys.exc_type, sys.exc_value
print('Error copying', pathFrom, to, pathTo, '--skipped')
print(sys.exc_type, sys.exc_value)
else:
if verbose: print 'copying dir', pathFrom, 'to', pathTo
if verbose: print('copying dir', pathFrom, 'to', pathTo)
try:
os.mkdir(pathTo) # make new subdir
cpallWithFilter(pathFrom, pathTo,MatchList) # recur into subdirs
dcount = dcount+1
except:
print 'Error creating', pathTo, '--skipped'
print sys.exc_type, sys.exc_value
print('Error creating', pathTo, '--skipped')
print(sys.exc_type, sys.exc_value)
################################################################
# Use: "python rmall.py directoryPath directoryPath..."