Anonymous avatar Anonymous committed f2a2613

Make the output of `schemamigration` more readable and more
PEP8-compliant, mainly by making lines a little shorter and getting rid
of extraneous whitespace.

Comments (0)

Files changed (2)

south/creator/actions.py

         db.create_table(%(table_name)r, (
             %(field_defs)s
         ))
-        db.send_create_signal(%(app_label)r, [%(model_name)r])'''
+        db.send_create_signal(%(app_label)r, [%(model_name)r])'''[1:] + "\n"
     
     BACKWARDS_TEMPLATE = '''
         # Deleting model '%(model_name)s'
-        db.delete_table(%(table_name)r)'''
+        db.delete_table(%(table_name)r)'''[1:] + "\n"
 
     def __init__(self, model, model_def):
         self.model = model
     
     FORWARDS_TEMPLATE = '''
         # Adding field '%(model_name)s.%(field_name)s'
-        db.add_column(%(table_name)r, %(field_name)r, %(field_def)s, keep_default=False)'''
+        db.add_column(%(table_name)r, %(field_name)r,
+                      %(field_def)s,
+                      keep_default=False)'''[1:] + "\n"
     
     BACKWARDS_TEMPLATE = '''
         # Deleting field '%(model_name)s.%(field_name)s'
-        db.delete_column(%(table_name)r, %(field_column)r)'''
+        db.delete_column(%(table_name)r, %(field_column)r)'''[1:] + "\n"
     
     def __init__(self, model, field, field_def):
         self.model = model
     
     FORWARDS_TEMPLATE = '''
         # Adding unique constraint on '%(model_name)s', fields %(field_names)s
-        db.create_unique(%(table_name)r, %(fields)r)'''
+        db.create_unique(%(table_name)r, %(fields)r)'''[1:] + "\n"
     
     BACKWARDS_TEMPLATE = '''
         # Removing unique constraint on '%(model_name)s', fields %(field_names)s
-        db.delete_unique(%(table_name)r, %(fields)r)'''
+        db.delete_unique(%(table_name)r, %(fields)r)'''[1:] + "\n"
     
     prepend_backwards = True
     
     
     FORWARDS_TEMPLATE = '''
         # Adding index on '%(model_name)s', fields %(field_names)s
-        db.create_index(%(table_name)r, %(fields)r)'''
+        db.create_index(%(table_name)r, %(fields)r)'''[1:] + "\n"
     
     BACKWARDS_TEMPLATE = '''
         # Removing index on '%(model_name)s', fields %(field_names)s
-        db.delete_index(%(table_name)r, %(fields)r)'''
+        db.delete_index(%(table_name)r, %(fields)r)'''[1:] + "\n"
     
     def console_line(self):
         "Returns the string to print on the console, e.g. ' + Added field foo'"
             (%(left_field)r, models.ForeignKey(orm[%(left_model_key)r], null=False)),
             (%(right_field)r, models.ForeignKey(orm[%(right_model_key)r], null=False))
         ))
-        db.create_unique(%(table_name)r, [%(left_column)r, %(right_column)r])'''
+        db.create_unique(%(table_name)r, [%(left_column)r, %(right_column)r])'''[1:] + "\n"
     
     BACKWARDS_TEMPLATE = '''
         # Removing M2M table for field %(field_name)s on '%(model_name)s'
-        db.delete_table('%(table_name)s')'''
+        db.delete_table('%(table_name)s')'''[1:] + "\n"
     
     def __init__(self, model, field):
         self.model = model

south/management/commands/schemamigration.py

 class Migration(SchemaMigration):
 
     def forwards(self, orm):
-        %(forwards)s
-
+%(forwards)s
     def backwards(self, orm):
-        %(backwards)s
-
+%(backwards)s
     models = %(frozen_models)s
 
-    %(complete_apps)s
-"""
+    %(complete_apps)s"""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.