Subversion Repositories programming

Rev

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

Rev 129 Rev 132
Line 133... Line 133...
133
#
133
#
134
# This is an object based representation of a parset, and will verify itself
134
# This is an object based representation of a parset, and will verify itself
135
# and extract itself, if possible.
135
# and extract itself, if possible.
136
################################################################################
136
################################################################################
137
 
137
 
138
import os, glob
138
import os, glob, re
139
 
139
 
140
class parset:
140
class parset:
141
    def __init__(self, par_filename):
141
    def __init__(self, par_filename):
142
        self.parfile = par_filename
142
        self.parfile = par_filename
143
        self.extra_pars = []
143
        self.extra_pars = []
Line 236... Line 236...
236
        # remove all of the extra pars
236
        # remove all of the extra pars
237
        for i in self.extra_pars:
237
        for i in self.extra_pars:
238
            os.remove(i)
238
            os.remove(i)
239
 
239
 
240
        # remove any rars that are associated (leave EVERYTHING else)
240
        # remove any rars that are associated (leave EVERYTHING else)
-
 
241
        # This regex matches both old and new style rar(s).
-
 
242
        regex = re.compile('^.*\.(rar|r\d\d)$')
241
        for i in self.files:
243
        for i in self.files:
242
            if i[-3:] == 'rar':
244
            if regex.match(i):
243
                os.remove(i)
245
                os.remove(i)
244
 
246
 
245
        # remove any .0?? files (from parjoin)
247
        # remove any .0?? files (from parjoin)
246
        if self.used_parjoin:
248
        if self.used_parjoin:
247
            for i in os.listdir(os.getcwd()):
249
            for i in os.listdir(os.getcwd()):
Line 323... Line 325...
323
    par2files += glob.glob('*.PAR2')
325
    par2files += glob.glob('*.PAR2')
324
 
326
 
325
    parsets = []
327
    parsets = []
326
 
328
 
327
    for i in par2files:
329
    for i in par2files:
-
 
330
        try:
328
        filenames = get_par2_filenames(i)
331
            filenames = get_par2_filenames(i)
329
        create_new = True
332
            create_new = True
-
 
333
        except EnvironmentError:
-
 
334
            print 'CORRUPT PARFILE: %s' % (i, )
-
 
335
            continue
330
 
336
 
331
        # if we already have an instance for this set, append
337
        # if we already have an instance for this set, append
332
        # this par file to the extra_pars field
338
        # this par file to the extra_pars field
333
        for j in parsets:
339
        for j in parsets:
334
            if j.files == filenames:
340
            if j.files == filenames: