py3: tools: 2to3
This commit is contained in:
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user