def copy(self, src, dest ) : fo = FileOps() src_a = os.path.abspath( src ) dest_a = os.path.abspath( dest ) # print "copy %s %s" % ( src_a, dest_a ) if not os.path.isdir( src_a ): raise ValueError( "the source directory \'%s\' does not exist" % src_a ) if not os.path.isdir( dest_a ): fo.makedir( dest_a ) new_root = os.path.join( dest_a, os.path.basename( src_a )) #print "copy: makedir : %s" % new_root fo.makedir( new_root ) for root, dirs, files in os.walk( src_a ): for d in dirs: # print "copy: makedir : %s" % os.path.join( new_root, d ) fo.makedir( os.path.join( new_root, d )) for f in files: # print "copy: copyfile : %s %s" % ( os.path.join( root, f ), os.path.join( new_root, f )) fo.copyfile( os.path.join( root, f ), os.path.join( new_root, f ))
def compare(self, path1, path2 ): ''' Compare path1 and path2 to see if they are identical ''' matchFails = [] matchCount = 0 fo = FileOps() for lhs, rhs in itertools.izip_longest( self.listAll(path1), self.listAll( path2 ), fillvalue = None ): matchCount = matchCount + 1 if matchCount == 1 : # allow us to compare to trees with different root names # we skip the first match continue if not fo.isEqual( lhs, rhs ) : matchFails.append(( lhs, rhs )) return matchFails