Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improved error reporting when fixture files are provided in an unknow…

…n serialization format.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4829 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 750ea554c12b34f7b68653488f345f4066191e08 1 parent 8a0b3ed
Russell Keith-Magee authored March 27, 2007

Showing 1 changed file with 16 additions and 8 deletions. Show diff stats Hide diff stats

  1. 24  django/core/management.py
24  django/core/management.py
@@ -1355,18 +1355,26 @@ def load_data(fixture_labels, verbosity=1):
1355 1355
     
1356 1356
     app_fixtures = [os.path.join(os.path.dirname(app.__file__),'fixtures') for app in get_apps()]
1357 1357
     for fixture_label in fixture_labels:
  1358
+        parts = fixture_label.split('.')
  1359
+        if len(parts) == 1:
  1360
+            fixture_name = fixture_label
  1361
+            formats = serializers.get_serializer_formats()
  1362
+        else:
  1363
+            fixture_name, format = '.'.join(parts[:-1]), parts[-1]
  1364
+            if format in serializers.get_serializer_formats():
  1365
+                formats = [format]
  1366
+            else:
  1367
+                formats = []
  1368
+                
1358 1369
         if verbosity > 0:
1359  
-            print "Loading '%s' fixtures..." % fixture_label
  1370
+            if formats:
  1371
+                print "Loading '%s' fixtures..." % fixture_name
  1372
+            else:
  1373
+                print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format)
  1374
+            
1360 1375
         for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']:
1361 1376
             if verbosity > 1:
1362 1377
                 print "Checking %s for fixtures..." % humanize(fixture_dir)
1363  
-            parts = fixture_label.split('.')
1364  
-            if len(parts) == 1:
1365  
-                fixture_name = fixture_label
1366  
-                formats = serializers.get_serializer_formats()
1367  
-            else:
1368  
-                fixture_name, format = '.'.join(parts[:-1]), parts[-1]
1369  
-                formats = [format]
1370 1378
 
1371 1379
             label_found = False
1372 1380
             for format in formats:

0 notes on commit 750ea55

Please sign in to comment.
Something went wrong with that request. Please try again.