def getFirstFile self fileMask dates list files like patriots_gamma_16

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def getFirstFile(self, fileMask):
dates = list()
# files like = patriots_gamma_160109_1400.zip
mask = re.compile(fileMask+'([0-9]{2})([0-9]{2})([0-9]{2})_([0-9]{2})([0-9]{2}).zip')
for filename in os.listdir(self.dataFilePath):
fl = mask.match(filename)
if (fl):
dt = d.datetime(2000+int(fl.group(1)), int(fl.group(2)), int(fl.group(3)), int(fl.group(4)), int(fl.group(5)))
dates.append(dt)
if (not dates): return None
mindate = min(dates)
return fileMask+mindate.strftime('%y%m%d_%H%M')+'.zip