Commits

Andrew Godwin committed d6e3b73

Fix archive loading.

Comments (0)

Files changed (1)

     
     def loadArchives(self):
         self.archives = {}
-        for filename in os.listdir("archives/"):
-            match = re.match(r'^(.+)_(\d\d\d\d\-\d\d\-\d\d_\d?\d\:\d\d)$', filename)
-            if match:
-                name, when = match.groups()
-                try:
-                    when = datetime.datetime.strptime(when, "%Y-%m-%d_%H:%M")
-                except ValueError, e:
-                    logging.log(logging.WARN, "Bad archive filename %s" % filename)
-                    continue
-                if name not in self.archives:
-                    self.archives[name] = {}
-                self.archives[name][when] = filename[:-5]
+        for name in os.listdir("archives/"):
+            if os.path.isdir(os.path.join("archives", name)):
+                for subfilename in os.listdir(os.path.join("archives", name)):
+                    match = re.match(r'^(\d\d\d\d\-\d\d\-\d\d_\d?\d\:\d\d)$', subfilename)
+                    if match:
+                        when = match.groups()[0]
+                        try:
+                            when = datetime.datetime.strptime(when, "%Y-%m-%d_%H:%M")
+                        except ValueError, e:
+                            logging.log(logging.WARN, "Bad archive filename %s" % subfilename)
+                            continue
+                        if name not in self.archives:
+                            self.archives[name] = {}
+                        self.archives[name][when] = "%s/%s" % (name, subfilename)
         logging.log(logging.INFO, "Loaded %s discrete archives." % len(self.archives))
         reactor.callLater(300, self.loadArchives)