Aymeric Augustin avatar Aymeric Augustin committed 91e9fd7

Use print function.

Comments (0)

Files changed (21)

south/creator/actions.py

 blocks into the forwards() and backwards() methods, in the right place.
 """
 
+from __future__ import print_function
+
 import sys
 
 from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT
             field_def[2]['default'] = repr("")
             return
         # Oh dear. Ask them what to do.
-        print " ? The field '%s.%s' does not have a default specified, yet is NOT NULL." % (
+        print(" ? The field '%s.%s' does not have a default specified, yet is NOT NULL." % (
             self.model._meta.object_name,
             field.name,
-        )
-        print " ? Since you are %s, you MUST specify a default" % self.null_reason
-        print " ? value to use for existing rows. Would you like to:"
-        print " ?  1. Quit now, and add a default to the field in models.py"
-        print " ?  2. Specify a one-off value to use for existing columns now"
+        ))
+        print(" ? Since you are %s, you MUST specify a default" % self.null_reason)
+        print(" ? value to use for existing rows. Would you like to:")
+        print(" ?  1. Quit now, and add a default to the field in models.py")
+        print(" ?  2. Specify a one-off value to use for existing columns now")
         if self.allow_third_null_option:
-            print " ?  3. Disable the backwards migration by raising an exception."
+            print(" ?  3. Disable the backwards migration by raising an exception.")
         while True:
             choice = raw_input(" ? Please select a choice: ")
             if choice == "1":
             elif choice == "3" and self.allow_third_null_option:
                 break
             else:
-                print " ! Invalid choice."
+                print(" ! Invalid choice.")
         if choice == "2":
             self.add_one_time_default(field, field_def)
         elif choice == "3":
 
     def add_one_time_default(self, field, field_def):
         # OK, they want to pick their own one-time default. Who are we to refuse?
-        print " ? Please enter Python code for your one-off default value."
-        print " ? The datetime module is available, so you can do e.g. datetime.date.today()"
+        print(" ? Please enter Python code for your one-off default value.")
+        print(" ? The datetime module is available, so you can do e.g. datetime.date.today()")
         while True:
             code = raw_input(" >>> ")
             if not code:
-                print " ! Please enter some code, or 'exit' (with no quotes) to exit."
+                print(" ! Please enter some code, or 'exit' (with no quotes) to exit.")
             elif code == "exit":
                 sys.exit(1)
             else:
                 try:
                     result = eval(code, {}, {"datetime": datetime_utils})
                 except (SyntaxError, NameError) as e:
-                    print " ! Invalid input: %s" % e
+                    print(" ! Invalid input: %s" % e)
                 else:
                     break
         # Right, add the default in.

south/creator/changes.py

 commandline, or by using autodetection, etc.
 """
 
+from __future__ import print_function
+
 from django.db import models
 from django.contrib.contenttypes.generic import GenericRelation
 from django.utils.datastructures import SortedDict
             try:
                 model_name, field_name = field_desc.split(".")
             except (TypeError, ValueError):
-                print "%r is not a valid field description." % field_desc
+                print("%r is not a valid field description." % field_desc)
             model = models.get_model(self.migrations.app_label(), model_name)
             yield ("AddIndex", {
                 "model": model,

south/creator/freezer.py

 Handles freezing of models into FakeORMs.
 """
 
+from __future__ import print_function
+
 import sys
 
 from django.db import models
                 missing_fields = True
                 model_class = model_classes[key]
                 field_class = model_class._meta.get_field_by_name(field_name)[0]
-                print " ! Cannot freeze field '%s.%s'" % (key, field_name)
-                print " ! (this field has class %s.%s)" % (field_class.__class__.__module__, field_class.__class__.__name__)
+                print(" ! Cannot freeze field '%s.%s'" % (key, field_name))
+                print(" ! (this field has class %s.%s)" % (field_class.__class__.__module__, field_class.__class__.__name__))
     if missing_fields:
-        print ""
-        print " ! South cannot introspect some fields; this is probably because they are custom"
-        print " ! fields. If they worked in 0.6 or below, this is because we have removed the"
-        print " ! models parser (it often broke things)."
-        print " ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork"
+        print("")
+        print(" ! South cannot introspect some fields; this is probably because they are custom")
+        print(" ! fields. If they worked in 0.6 or below, this is because we have removed the")
+        print(" ! models parser (it often broke things).")
+        print(" ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork")
         sys.exit(1)
     
     return model_defs

south/db/firebird.py

 # firebird
 
+from __future__ import print_function
+
 import datetime
 
 from django.db import connection, models
 
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for alter_column() due to dynamic DDL, sorry'
+                print('   - no dry run output for alter_column() due to dynamic DDL, sorry')
             return
 
 
                 try:
                     self.execute("ALTER TABLE %s %s;" % (self.quote_name(table_name), sql), values)
                 except DatabaseError as e:
-                    print e
+                    print(e)
 
 
         # Execute extra sql, which don't need ALTER TABLE statement

south/db/generic.py

+from __future__ import print_function
+
 import re
 import sys
 
         
         cursor = self._get_connection().cursor()
         if self.debug:
-            print "   = %s" % sql, params
+            print("   = %s" % sql, params)
 
         if self.dry_run:
             return []
         try:
             cursor.execute(sql, params)
         except DatabaseError as e:
-            print >> sys.stderr, 'FATAL ERROR - The following SQL query failed: %s' % sql
-            print >> sys.stderr, 'The error was: %s' % e
+            print('FATAL ERROR - The following SQL query failed: %s' % sql, file=sys.stderr)
+            print('The error was: %s' % e, file=sys.stderr)
             raise
 
         try:
         """
 
         if len(table_name) > 63:
-            print "   ! WARNING: You have a table name longer than 63 characters; this will not fully work on PostgreSQL or MySQL."
+            print("   ! WARNING: You have a table name longer than 63 characters; this will not fully work on PostgreSQL or MySQL.")
 
         # avoid default values in CREATE TABLE statements (#925)
         for field_name, field in fields:
         
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for alter_column() due to dynamic DDL, sorry'
+                print('   - no dry run output for alter_column() due to dynamic DDL, sorry')
             return
 
         # hook for the field to do any resolution prior to it's attributes being queried
         # Dry runs mean we can't do anything.
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for delete_unique_column() due to dynamic DDL, sorry'
+                print('   - no dry run output for delete_unique_column() due to dynamic DDL, sorry')
             return
 
         constraints = list(self._constraints_affecting_columns(table_name, columns))
         """
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry'
+                print('   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry')
             return  # We can't look at the DB to get the constraints
         constraints = self._find_foreign_constraints(table_name, column)
         if not constraints:
         Generates a create index statement on 'table_name' for a list of 'column_names'
         """
         if not column_names:
-            print "No column names supplied on which to create an index"
+            print("No column names supplied on which to create an index")
             return ''
 
         connection = self._get_connection()
         # Dry runs mean we can't do anything.
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for delete_primary_key() due to dynamic DDL, sorry'
+                print('   - no dry run output for delete_primary_key() due to dynamic DDL, sorry')
             return
         
         constraints = list(self._constraints_affecting_columns(table_name, None, type="PRIMARY KEY"))
         """
         
         if self.debug:
-            print " - Sending post_syncdb signal for %s: %s" % (app_label, model_names)
+            print(" - Sending post_syncdb signal for %s: %s" % (app_label, model_names))
         
         app = models.get_app(app_label)
         if not app:

south/db/oracle.py

+from __future__ import print_function
+
 import os.path
 import sys
 import re
         
         if self.dry_run:
             if self.debug:
-                print '   - no dry run output for alter_column() due to dynamic DDL, sorry'
+                print('   - no dry run output for alter_column() due to dynamic DDL, sorry')
             return
 
         qn = self.quote_name(table_name)

south/db/postgresql_psycopg2.py

+from __future__ import print_function
+
 import uuid
 from django.db.backends.util import truncate_name
 from south.db import generic
             generic.DatabaseOperations.rename_table(self, old_table_name + "_id_seq", table_name + "_id_seq")
         except:
             if self.debug:
-                print "   ~ No such sequence (ignoring error)"
+                print("   ~ No such sequence (ignoring error)")
             self.rollback_transaction()
         else:
             self.commit_transaction()
             generic.DatabaseOperations.rename_table(self, old_table_name + "_pkey", table_name + "_pkey")
         except:
             if self.debug:
-                print "   ~ No such primary key (ignoring error)"
+                print("   ~ No such primary key (ignoring error)")
             self.rollback_transaction()
         else:
             self.commit_transaction()

south/exceptions.py

+from __future__ import print_function
+
 from traceback import format_exception
 
 class SouthError(RuntimeError):
         self.depends_on = depends_on
 
     def __str__(self):
-        print "Migration '%(migration)s' depends on unknown migration '%(depends_on)s'." % self.__dict__
+        print("Migration '%(migration)s' depends on unknown migration '%(depends_on)s'." % self.__dict__)
 
 
 class DependsOnUnmigratedApplication(SouthError):

south/management/commands/convert_to_south.py

 Quick conversion command module.
 """
 
+from __future__ import print_function
+
 from optparse import make_option
 import sys
 
         
         # Make sure we have an app
         if not app:
-            print "Please specify an app to convert."
+            print("Please specify an app to convert.")
             return
         
         # See if the app exists
         try:
             app_module = models.get_app(app)
         except ImproperlyConfigured:
-            print "There is no enabled application matching '%s'." % app
+            print("There is no enabled application matching '%s'." % app)
             return
         
         # Try to get its list of models
         model_list = models.get_models(app_module)
         if not model_list:
-            print "This application has no models; this command is for applications that already have models syncdb'd."
-            print "Make some models, and then use ./manage.py schemamigration %s --initial instead." % app
+            print("This application has no models; this command is for applications that already have models syncdb'd.")
+            print("Make some models, and then use ./manage.py schemamigration %s --initial instead." % app)
             return
         
         # Ask South if it thinks it's already got migrations
         except NoMigrations:
             pass
         else:
-            print "This application is already managed by South."
+            print("This application is already managed by South.")
             return
         
         # Finally! It seems we've got a candidate, so do the two-command trick
             delete_ghosts=options.get("delete_ghosts", False),
         )
         
-        print 
-        print "App '%s' converted. Note that South assumed the application's models matched the database" % app
-        print "(i.e. you haven't changed it since last syncdb); if you have, you should delete the %s/migrations" % app
-        print "directory, revert models.py so it matches the database, and try again."
+        print() 
+        print("App '%s' converted. Note that South assumed the application's models matched the database" % app)
+        print("(i.e. you haven't changed it since last syncdb); if you have, you should delete the %s/migrations" % app)
+        print("directory, revert models.py so it matches the database, and try again.")

south/management/commands/datamigration.py

 Data migration creation command
 """
 
+from __future__ import print_function
+
 import sys
 import os
 import re
         
         # - is a special name which means 'print to stdout'
         if name == "-":
-            print file_contents
+            print(file_contents)
         # Write the migration file if the name isn't -
         else:
             fp = open(os.path.join(migrations.migrations_dir(), new_filename), "w")
             fp.write(file_contents)
             fp.close()
-            print >>sys.stderr, "Created %s." % new_filename
+            print("Created %s." % new_filename, file=sys.stderr)
     
     def calc_frozen_apps(self, migrations, freeze_list):
         """
         """
         Prints the error, and exits with the given code.
         """
-        print >>sys.stderr, message
+        print(message, file=sys.stderr)
         sys.exit(code)
 
 

south/management/commands/graphmigrations.py

 Outputs a graphviz dot file of the dependencies.
 """
 
+from __future__ import print_function
+
 from optparse import make_option
 import re
 import textwrap
         color_index = 0
         wrapper = textwrap.TextWrapper(width=40)
         
-        print "digraph G {"
+        print("digraph G {")
         
         # Group each app in a subgraph
         for migrations in all_migrations():
-            print "  subgraph %s {" % migrations.app_label()
-            print "    node [color=%s];" % colors[color_index]
+            print("  subgraph %s {" % migrations.app_label())
+            print("    node [color=%s];" % colors[color_index])
             for migration in migrations:
                 # Munge the label - text wrap and change _ to spaces
                 label = "%s - %s" % (
                         migration.app_label(), migration.name())
                 label = re.sub(r"_+", " ", label)
                 label=  "\\n".join(wrapper.wrap(label))
-                print '    "%s.%s" [label="%s"];' % (
-                        migration.app_label(), migration.name(), label)
-            print "  }"
+                print('    "%s.%s" [label="%s"];' % (
+                        migration.app_label(), migration.name(), label))
+            print("  }")
             color_index = (color_index + 1) % len(colors)
 
         # For every migration, print its links.
                     # But the more interesting edges are those between apps
                     if other.app_label() != migration.app_label():
                         attrs = "[style=bold]"
-                    print '  "%s.%s" -> "%s.%s" %s;' % (
+                    print('  "%s.%s" -> "%s.%s" %s;' % (
                         other.app_label(), other.name(),
                         migration.app_label(), migration.name(),
                         attrs
-                    )
+                    ))
             
-        print "}";
+        print("}");

south/management/commands/migrate.py

 Migrate management command.
 """
 
+from __future__ import print_function
+
 import os.path, re, sys
 from optparse import make_option
 
             try:
                 apps = [Migrations(app)]
             except NoMigrations:
-                print "The app '%s' does not appear to use migrations." % app
-                print "./manage.py migrate " + self.args
+                print("The app '%s' does not appear to use migrations." % app)
+                print("./manage.py migrate " + self.args)
                 return
         else:
             apps = list(migration.all_migrations())
         applied_migrations = applied_migrations.using(database)
     applied_migration_names = ['%s.%s' % (mi.app_name,mi.migration) for mi in applied_migrations]
 
-    print
+    print()
     for app in apps:
-        print " " + app.app_label()
+        print(" " + app.app_label())
         # Get the migrations object
         for migration in app:
             if migration.app_label() + "." + migration.name() in applied_migration_names:
                 applied_migration = applied_migrations.get(app_name=migration.app_label(), migration=migration.name())
-                print format_migration_list_item(migration.name(), applied=applied_migration.applied, **options)
+                print(format_migration_list_item(migration.name(), applied=applied_migration.applied, **options))
             else:
-                print format_migration_list_item(migration.name(), applied=False, **options)
-        print
+                print(format_migration_list_item(migration.name(), applied=False, **options))
+        print()
 
 def show_migration_changes(apps):
     """
         grep "ing " migrations/*.py
     """
     for app in apps:
-        print app.app_label()
+        print(app.app_label())
         # Get the migrations objects
         migrations = [migration for migration in app]
         # we use reduce to compare models in pairs, not to generate a value
     def field_name(models, model, field):
         return '%s.%s' % (model_name(models, model), field)
         
-    print "  " + migration2.name()
+    print("  " + migration2.name())
     
     models1 = migration1.migration_class().models
     models2 = migration2.migration_class().models
     # find new models
     for model in models2.keys():
         if not model in models1.keys():
-            print '    added model %s' % model_name(models2, model)
+            print('    added model %s' % model_name(models2, model))
  
     # find removed models
     for model in models1.keys():
         if not model in models2.keys():
-            print '    removed model %s' % model_name(models1, model)
+            print('    removed model %s' % model_name(models1, model))
             
     # compare models
     for model in models1:
             # find added fields
             for field in models2[model]:
                 if not field in models1[model]:
-                    print '    added field %s' % field_name(models2, model, field)
+                    print('    added field %s' % field_name(models2, model, field))
 
             # find removed fields
             for field in models1[model]:
                 if not field in models2[model]:
-                    print '    removed field %s' % field_name(models1, model, field)
+                    print('    removed field %s' % field_name(models1, model, field))
                 
             # compare fields
             for field in models1[model]:
                     
                     # if a field has become a class, or vice versa
                     if type(field_value1) != type(field_value2):
-                        print '    type of %s changed from %s to %s' % (
-                            name, field_value1, field_value2)
+                        print('    type of %s changed from %s to %s' % (
+                            name, field_value1, field_value2))
                     
                     # if class
                     elif isinstance(field_value1, dict):
                         type2, attr_list2, field_attrs2 = models2[model][field]
                         
                         if type1 != type2:
-                            print '    %s type changed from %s to %s' % (
-                                name, type1, type2)
+                            print('    %s type changed from %s to %s' % (
+                                name, type1, type2))
     
                         if attr_list1 != []:
-                            print '    %s list %s is not []' % (
-                                name, attr_list1)
+                            print('    %s list %s is not []' % (
+                                name, attr_list1))
                         if attr_list2 != []:
-                            print '    %s list %s is not []' % (
-                                name, attr_list2)    
+                            print('    %s list %s is not []' % (
+                                name, attr_list2))    
                         if attr_list1 != attr_list2:
-                            print '    %s list changed from %s to %s' % (
-                                name, attr_list1, attr_list2)                
+                            print('    %s list changed from %s to %s' % (
+                                name, attr_list1, attr_list2))                
                                         
                         # find added field attributes
                         for attr in field_attrs2:
                             if not attr in field_attrs1:
-                                print '    added %s attribute %s=%s' % (
-                                    name, attr, field_attrs2[attr])
+                                print('    added %s attribute %s=%s' % (
+                                    name, attr, field_attrs2[attr]))
                                 
                         # find removed field attributes
                         for attr in field_attrs1:
                             if not attr in field_attrs2:
-                                print '    removed attribute %s(%s=%s)' % (
-                                    name, attr, field_attrs1[attr])
+                                print('    removed attribute %s(%s=%s)' % (
+                                    name, attr, field_attrs1[attr]))
                             
                         # compare field attributes
                         for attr in field_attrs1:
                                 value1 = field_attrs1[attr]
                                 value2 = field_attrs2[attr]
                                 if value1 != value2:
-                                    print '    %s attribute %s changed from %s to %s' % (
-                                        name, attr, value1, value2)
+                                    print('    %s attribute %s changed from %s to %s' % (
+                                        name, attr, value1, value2))
     
     return migration2

south/management/commands/schemamigration.py

 Startmigration command, version 2.
 """
 
+from __future__ import print_function
+
 import sys
 import os
 import re
             elif empty:
                 change_source = None
             else:
-                print >>sys.stderr, "You have not passed any of --initial, --auto, --empty, --add-model, --add-field or --add-index."
+                print("You have not passed any of --initial, --auto, --empty, --add-model, --add-field or --add-index.", file=sys.stderr)
                 sys.exit(1)
 
         # Validate this so we can access the last migration without worrying
                     action = action_class(**params)
                     action.add_forwards(forwards_actions)
                     action.add_backwards(backwards_actions)
-                    print >>sys.stderr, action.console_line()
+                    print(action.console_line(), file=sys.stderr)
         
         # Nowt happen? That's not good for --auto.
         if auto and not forwards_actions:
         if update:
             last_migration = migrations[-1]
             if MigrationHistory.objects.filter(applied__isnull=False, app_name=app, migration=last_migration.name()):
-                print >>sys.stderr, "Migration to be updated, %s, is already applied, rolling it back now..." % last_migration.name()
+                print("Migration to be updated, %s, is already applied, rolling it back now..." % last_migration.name(), file=sys.stderr)
                 migrate_app(migrations, 'current-1', verbosity=verbosity)
             for ext in ('py', 'pyc'):
                 old_filename = "%s.%s" % (os.path.join(migrations.migrations_dir(), last_migration.filename), ext)
 
         # - is a special name which means 'print to stdout'
         if name == "-":
-            print file_contents
+            print(file_contents)
         # Write the migration file if the name isn't -
         else:
             fp = open(os.path.join(migrations.migrations_dir(), new_filename), "w")
             fp.close()
             verb = 'Updated' if update else 'Created'
             if empty:
-                print >>sys.stderr, "%s %s. You must now edit this migration and add the code for each direction." % (verb, new_filename)
+                print("%s %s. You must now edit this migration and add the code for each direction." % (verb, new_filename), file=sys.stderr)
             else:
-                print >>sys.stderr, "%s %s. You can now apply this migration with: ./manage.py migrate %s" % (verb, new_filename, app)
+                print("%s %s. You can now apply this migration with: ./manage.py migrate %s" % (verb, new_filename, app), file=sys.stderr)
 
 
 MIGRATION_TEMPLATE = """# -*- coding: utf-8 -*-

south/management/commands/startmigration.py

 Now-obsolete startmigration command.
 """
 
+from __future__ import print_function
+
 from optparse import make_option
 
 from django.core.management.base import BaseCommand
     
     def handle(self, app=None, name="", added_model_list=None, added_field_list=None, initial=False, freeze_list=None, auto=False, stdout=False, added_index_list=None, **options):
         
-        print "The 'startmigration' command is now deprecated; please use the new 'schemamigration' and 'datamigration' commands."
+        print("The 'startmigration' command is now deprecated; please use the new 'schemamigration' and 'datamigration' commands.")

south/management/commands/syncdb.py

 Overridden syncdb command
 """
 
+from __future__ import print_function
+
 import sys
 from optparse import make_option
 
         
         # Run syncdb on only the ones needed
         if verbosity:
-            print "Syncing..."
+            print("Syncing...")
         
         old_installed, settings.INSTALLED_APPS = settings.INSTALLED_APPS, apps_needing_sync
         old_app_store, cache.app_store = cache.app_store, SortedDict([
         # Migrate if needed
         if options.get('migrate', True):
             if verbosity:
-                print "Migrating..."
+                print("Migrating...")
             management.call_command('migrate', **options)
         
         # Be obvious about what we did
         if verbosity:
-            print "\nSynced:\n > %s" % "\n > ".join(apps_needing_sync)
+            print("\nSynced:\n > %s" % "\n > ".join(apps_needing_sync))
         
         if options.get('migrate', True):
             if verbosity:
-                print "\nMigrated:\n - %s" % "\n - ".join(apps_migrated)
+                print("\nMigrated:\n - %s" % "\n - ".join(apps_migrated))
         else:
             if verbosity:
-                print "\nNot synced (use migrations):\n - %s" % "\n - ".join(apps_migrated)
-                print "(use ./manage.py migrate to migrate these)"
+                print("\nNot synced (use migrations):\n - %s" % "\n - ".join(apps_migrated))
+                print("(use ./manage.py migrate to migrate these)")

south/migration/__init__.py

 Main migration logic.
 """
 
+from __future__ import print_function
+
 import sys
 
 from django.core.exceptions import ImproperlyConfigured
             if checking not in done:
                 # That's bad. Error.
                 if verbosity:
-                    print (" ! Migration %s should not have been applied "
-                           "before %s but was." % (last, checking))
+                    print((" ! Migration %s should not have been applied "
+                           "before %s but was." % (last, checking)))
                 result.append((last, checking))
             else:
                 to_check.extend(checking.dependencies)
     
     # If there aren't any, quit quizically
     if not migrations:
-        print "? You have no migrations for the '%s' app. You might want some." % app_label
+        print("? You have no migrations for the '%s' app. You might want some." % app_label)
         return
     
     # Load the entire dependency graph
         if applied.count() > 1:
             previous_migration = applied[applied.count() - 2]
             if verbosity:
-                print 'previous_migration: %s (applied: %s)' % (previous_migration.migration, previous_migration.applied)
+                print('previous_migration: %s (applied: %s)' % (previous_migration.migration, previous_migration.applied))
             target_name = previous_migration.migration
         else:
             if verbosity:
-                print 'previous_migration: zero'
+                print('previous_migration: zero')
             target_name = 'zero'
     elif target_name == 'current+1':
         try:
     target = migrations.guess_migration(target_name)
     if verbosity:
         if target_name not in ('zero', None) and target.name() != target_name:
-            print " - Soft matched migration %s to %s." % (target_name,
-                                                           target.name())
-        print "Running migrations for %s:" % app_label
+            print(" - Soft matched migration %s to %s." % (target_name,
+                                                           target.name()))
+        print("Running migrations for %s:" % app_label)
     
     # Get the forwards and reverse dependencies for this target
     direction, problems, workplan = get_direction(target, applied_all, migrations,
     else:
         if verbosity:
             # Say there's nothing.
-            print '- Nothing to migrate.'
+            print('- Nothing to migrate.')
         # If we have initial data enabled, and we're at the most recent
         # migration, do initial data.
         # Note: We use a fake Forwards() migrator here. It's never used really.

south/migration/base.py

+from __future__ import print_function
+
 from collections import deque
 import datetime
 import os
         # Make the directory if it's not already there
         if not os.path.isdir(migrations_dir):
             if verbose:
-                print "Creating migrations directory at '%s'..." % migrations_dir
+                print("Creating migrations directory at '%s'..." % migrations_dir)
             os.mkdir(migrations_dir)
         # Same for __init__.py
         init_path = os.path.join(migrations_dir, "__init__.py")
         if not os.path.isfile(init_path):
             # Touch the init py file
             if verbose:
-                print "Creating __init__.py in '%s'..." % migrations_dir
+                print("Creating __init__.py in '%s'..." % migrations_dir)
             open(init_path, "w").close()
     
     def migrations_dir(self):

south/migration/migrators.py

+from __future__ import print_function
+
 from copy import copy, deepcopy
 from cStringIO import StringIO
 import datetime
 
     def print_title(self, target):
         if self.verbosity:
-            print self.title(target)
+            print(self.title(target))
         
     @staticmethod
     def status(target):
     def print_status(self, migration):
         status = self.status(migration)
         if self.verbosity and status:
-            print status
+            print(status)
 
     @staticmethod
     def orm(migration):
         except:
             south.db.db.rollback_transaction()
             if not south.db.db.has_ddl_transactions:
-                print self.run_migration_error(migration)
-            print "Error in migration: %s" % migration
+                print(self.run_migration_error(migration))
+            print("Error in migration: %s" % migration)
             raise
         else:
             try:
                 south.db.db.commit_transaction()
             except:
-                print "Error during commit in migration: %s" % migration
+                print("Error during commit in migration: %s" % migration)
                 raise
                 
 
     def _run_migration(self, migration):
         if migration.no_dry_run():
             if self.verbosity:
-                print " - Migration '%s' is marked for no-dry-run." % migration
+                print(" - Migration '%s' is marked for no-dry-run." % migration)
             return
         south.db.db.dry_run = True
         # preserve the constraint cache as it can be mutated by the dry run
 class FakeMigrator(MigratorWrapper):
     def run(self, migration):
         if self.verbosity:
-            print '   (faked)'
+            print('   (faked)')
 
     def send_ran_migration(self, *args, **kwargs):
         pass
             return
         # Load initial data, if we ended up at target
         if self.verbosity:
-            print " - Loading initial data for %s." % target.app_label()
+            print(" - Loading initial data for %s." % target.app_label())
         # Override Django's get_apps call temporarily to only load from the
         # current app
         old_get_apps = models.get_apps

south/modelsinspector.py

 rather than direct inspection of models.py.
 """
 
+from __future__ import print_function
+
 import datetime
 import re
 import decimal
         # Does it define a south_field_triple method?
         if hasattr(field, "south_field_triple"):
             if NOISY:
-                print " ( Nativing field: %s" % field.name
+                print(" ( Nativing field: %s" % field.name)
             field_defs[field.name] = field.south_field_triple()
         # Can we introspect it?
         elif can_introspect(field):
         # Shucks, no definition!
         else:
             if NOISY:
-                print " ( Nodefing field: %s" % field.name
+                print(" ( Nodefing field: %s" % field.name)
             field_defs[field.name] = None
     
     # If they've used the horrific hack that is order_with_respect_to, deal with
 Roughly emulates the real Django ORM, to a point.
 """
 
+from __future__ import print_function
+
 import inspect
 
 from django.db import models
                 if name == "SouthFieldClass":
                     raise ValueError("Cannot import the required field '%s'" % value)
                 else:
-                    print "WARNING: Cannot import '%s'" % value
+                    print("WARNING: Cannot import '%s'" % value)
         
         # Use ModelsLocals to make lookups work right for CapitalisedModels
         fake_locals = ModelsLocals(fake_locals)

south/tests/__init__.py

+from __future__ import print_function
 
 #import unittest
 import os
                     testfunc(self)
                 else:
                     # The skip exceptions are not available either...
-                    print "Skipping", testfunc.__name__,"--", message
+                    print("Skipping", testfunc.__name__,"--", message)
             return wrapper
         return decorator
 
             @wraps(testfunc)
             def wrapper(self):
                 if condition:
-                    print "Skipping", testfunc.__name__,"--", message
+                    print("Skipping", testfunc.__name__,"--", message)
                 else:
                     # Apply method
                     testfunc(self)
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.