import fix
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 18 Jun 2010 15:15:07 +0000 (17:15 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 18 Jun 2010 15:15:07 +0000 (17:15 +0200)
apps/catalogue/management/commands/importbooks.py
apps/catalogue/models.py

index cead75f..ee469ba 100644 (file)
@@ -44,7 +44,7 @@ class Command(BaseCommand):
             if not os.path.isdir(dir_name):
                 print self.style.ERROR("%s: Not a directory. Skipping." % dir_name)
             else:
             if not os.path.isdir(dir_name):
                 print self.style.ERROR("%s: Not a directory. Skipping." % dir_name)
             else:
-                for file_name in os.listdir(dir_name):
+                for file_name in sorted(os.listdir(dir_name)):
                     file_path = os.path.join(dir_name, file_name)
                     file_base, ext = os.path.splitext(file_path)
 
                     file_path = os.path.join(dir_name, file_name)
                     file_base, ext = os.path.splitext(file_path)
 
index 90ecb1a..37ea4e8 100644 (file)
@@ -296,7 +296,7 @@ class Book(models.Model):
         book_info = dcparser.parse(xml_file)
 
         if not isinstance(xml_file, File):
         book_info = dcparser.parse(xml_file)
 
         if not isinstance(xml_file, File):
-            xml_file = File(xml_file)
+            xml_file = File(open(xml_file))
 
         try:
             return cls.from_text_and_meta(xml_file, book_info, overwrite)
 
         try:
             return cls.from_text_and_meta(xml_file, book_info, overwrite)