Commits

Andrew Godwin committed 8a7e0cd

Fix #188: Allow people to use .pyc files for migrations

Comments (0)

Files changed (1)

     """
     Returns a list of migration file names for the given app.
     """
-    return sorted([
-        filename[:-3]
+    if getattr(settings, "SOUTH_USE_PYC", False):
+        allowed_extensions = (".pyc", ".py")
+        ignored_files = ("__init__.pyc", "__init__.py")
+    else:
+        allowed_extensions = (".py",)
+        ignored_files = ("__init__.py",)
+    
+    return sorted(set([
+        os.path.splitext(filename)[0]
         for filename in os.listdir(os.path.dirname(app.__file__))
-        if filename.endswith(".py") and filename != "__init__.py" and not filename.startswith(".")
-    ])
+        if os.path.splitext(filename)[1] in allowed_extensions and filename not in ignored_files and not filename.startswith(".")
+    ]))
 
 
 def get_migration_classes(app):