Subversion Repositories programming

Rev

Rev 116 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 116 Rev 118
Line 117... Line 117...
117
    if( dir[0] == '/' ):
117
    if( dir[0] == '/' ):
118
        return dir
118
        return dir
119
 
119
 
120
    return os.path.join(SORT_DIR, dir)
120
    return os.path.join(SORT_DIR, dir)
121
 
121
 
122
def printfailed(moved, failed):
122
def printfailed(moved, failed, cwd):
123
    """printfailed(moved, failed):
123
    """printfailed(moved, failed, cwd):
124
 
124
 
125
    moved is an INTEGER number representing the number of files successfully moved
125
    moved is an INTEGER number representing the number of files successfully moved
126
    failed is a LIST of the filenames which could not be moved"""
126
    failed is a LIST of the filenames which could not be moved
-
 
127
    cwd is a STRING containing the current working directory"""
127
    if( len(failed) > 0 and moved > 0 ):
128
    if( len(failed) > 0 and moved > 0 ):
128
        print '================================================================================'
129
        print '================================================================================'
129
 
130
 
130
    if( len(failed) > 0 and moved == 0 ):
131
    if( len(failed) > 0 and moved == 0 ):
131
        printwdheader(os.path.split(failed[0])[0])
132
        printwdheader(cwd)
132
 
133
 
133
    for f in failed:
134
    for f in failed:
134
        print "Failed to move %s" % f
135
        print "Failed to move %s" % f
135
 
136
 
136
    if( len(failed) == 0 and moved == 0 ):
137
    if( len(failed) == 0 and moved == 0 ):
Line 142... Line 143...
142
    """Prints out a header telling the user we're working in the directory
143
    """Prints out a header telling the user we're working in the directory
143
    passed as an argument"""
144
    passed as an argument"""
144
    print 'Working in directory: %s' % dir
145
    print 'Working in directory: %s' % dir
145
    print '================================================================================'
146
    print '================================================================================'
146
 
147
 
147
def printmove(num, file, dstdir):
148
def printmove(num, file, dstdir, cwd):
148
    if( num == 1 ):
149
    if( num == 1 ):
149
        printwdheader(os.path.split(file)[0])
150
        printwdheader(cwd)
150
 
151
 
151
    print "Moved %s to %s!" % (file, dstdir)
152
    print "Moved %s to %s!" % (file, dstdir)
152
 
153
 
153
def mainloop(dir, dict):
154
def mainloop(dir, dict):
154
    """mainloop(dir, dict):
155
    """mainloop(dir, dict):
Line 174... Line 175...
174
 
175
 
175
            if( ret == False ):
176
            if( ret == False ):
176
                failed.append(f)
177
                failed.append(f)
177
            else:
178
            else:
178
                moved = moved + 1
179
                moved = moved + 1
179
                printmove(moved, f, dstdir)
180
                printmove(moved, f, dstdir, cwd)
180
 
181
 
181
    printfailed(moved, failed)
182
    printfailed(moved, failed, cwd)
182
 
183
 
183
    # Call ourself recursively on the subdirectories
184
    # Call ourself recursively on the subdirectories
184
    for s in subdirs:
185
    for s in subdirs:
185
        mainloop(s, dict)
186
        mainloop(s, dict)
186
 
187