- iofile = IOFile.from_filename(file_path)
- basename, ext = file_path.rsplit('.', 1)
- if os.path.isdir(basename):
- for att_name in os.listdir(basename):
- iofile.attachments[att_name] = IOFile.from_filename(
- os.path.join(basename, att_name))
- lesson = Lesson.publish(iofile)
+ iofile = IOFile.from_filename(os.path.join(self.curdir, file_path))
+ iofile.attachments = attachments
+ return Lesson.publish(iofile, ignore_incomplete)
+
+ @staticmethod
+ def all_attachments(path):
+ files = {}
+
+ def read_dir(path):
+ for name in os.listdir(path):
+ fullname = os.path.join(path, name)
+ if os.path.isdir(fullname):
+ read_dir(fullname)
+ else:
+ f = IOFile.from_filename(fullname)
+ files[name] = f
+ files.setdefault(name.replace(" ", ""), f)
+
+ read_dir(path)
+ return files
+