-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-updater.py
102 lines (76 loc) · 2.67 KB
/
package-updater.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os.path as path
import glob
class PackageUpdater :
def __init__( self ):
self.srcPath = "./test1/*"
self.destPath = "./test2/*"
self.fileList = []
self.fileOnlyList = []
self.fileListDest = []
self.fileListSrc = []
self.commonFilesIndex = []
def findAllFiles( self , strPath ):
fileList = glob.glob( strPath )
for i in fileList :
if ( i == "./" or i == "../" ) :
print( i + "is current" )
continue
if path.isdir(i) :
self.findAllFiles( i + "/*" )
elif path.isfile(i) :
self.fileList.append(i);
def printFileList( self ):
self.extractFileNames()
print ( self.fileList )
print ( "\n" )
print ( self.fileOnlyList )
def extractFileNames( self ):
self.fileOnlyList = []
for file in self.fileList :
currFile = path.basename( file )
self.fileOnlyList.append( currFile )
def genDestFileList( self ):
self.fileList = []
self.findAllFiles( self.destPath )
self.fileListDest = self.fileList
def genSrcFileList( self ):
self.fileList = []
self.findAllFiles( self.srcPath )
self.fileListSrc = self.fileList
def genCommonFiles( self ):
self.fileList = self.fileListSrc
self.extractFileNames()
fileListSrc = self.fileOnlyList
self.fileList = self.fileListDest
self.extractFileNames()
fileListDest = self.fileOnlyList
print "Src:"
print self.fileListSrc
print "\n"
print "dest:"
print self.fileListDest
print "\n"
indexDest = 0
indexSrc = 0
for file1 in fileListDest :
indexDest += 1
indexSrc = 0
for file2 in fileListSrc :
indexSrc += 1
if ( self.compareNames( file1, file2 ) == True ):
print ( "Files are equal " + file1 + "=" + file2 )
self.commonFilesIndex.append( { indexDest : indexSrc } )
def compareNames( self , file1 , file2 ):
if ( file1 == file2 ):
return True
else:
return False
def process( self ):
self.genDestFileList()
self.genSrcFileList()
self.genCommonFiles()
print ( self.commonFilesIndex )
def printContext( self ) :
print self.fileList
p = PackageUpdater()
p.process()