44
44
ss_loaddata management command, we need to keep close track of changes in
45
45
django/core/management/commands/loaddata.py.
46
46
"""
47
+
48
+ from __future__ import print_function
49
+
47
50
import sys
48
51
import os
49
52
import gzip
@@ -151,7 +154,7 @@ def read(self):
151
154
152
155
if formats :
153
156
if verbosity > 1 :
154
- print "Loading '%s' fixtures..." % fixture_name
157
+ print ( "Loading '%s' fixtures..." % fixture_name )
155
158
else :
156
159
self .enable_forward_ref_checks (cursor )
157
160
sys .stderr .write (
@@ -168,7 +171,7 @@ def read(self):
168
171
169
172
for fixture_dir in fixture_dirs :
170
173
if verbosity > 1 :
171
- print "Checking %s for fixtures..." % humanize (fixture_dir )
174
+ print ( "Checking %s for fixtures..." % humanize (fixture_dir ) )
172
175
173
176
label_found = False
174
177
for format in formats :
@@ -180,26 +183,26 @@ def read(self):
180
183
file_name = '.' .join ([fixture_name , format ])
181
184
182
185
if verbosity > 1 :
183
- print "Trying %s for %s fixture '%s'..." % \
184
- (humanize (fixture_dir ), file_name , fixture_name )
186
+ print ( "Trying %s for %s fixture '%s'..." % \
187
+ (humanize (fixture_dir ), file_name , fixture_name ))
185
188
full_path = os .path .join (fixture_dir , file_name )
186
189
open_method = compression_types [compression_format ]
187
190
try :
188
191
fixture = open_method (full_path , 'r' )
189
192
if label_found :
190
193
fixture .close ()
191
194
self .enable_forward_ref_checks (cursor )
192
- print self .style .ERROR ("Multiple fixtures named '%s' in %s. Aborting." %
193
- (fixture_name , humanize (fixture_dir )))
195
+ print ( self .style .ERROR ("Multiple fixtures named '%s' in %s. Aborting." %
196
+ (fixture_name , humanize (fixture_dir ))))
194
197
transaction .rollback ()
195
198
transaction .leave_transaction_management ()
196
199
return
197
200
else :
198
201
fixture_count += 1
199
202
objects_in_fixture = 0
200
203
if verbosity > 0 :
201
- print "Installing %s fixture '%s' from %s." % \
202
- (format , fixture_name , humanize (fixture_dir ))
204
+ print ( "Installing %s fixture '%s' from %s." % \
205
+ (format , fixture_name , humanize (fixture_dir )))
203
206
try :
204
207
objects = serializers .deserialize (format , fixture )
205
208
for obj in objects :
@@ -239,10 +242,10 @@ def read(self):
239
242
transaction .leave_transaction_management ()
240
243
return
241
244
242
- except Exception , e :
245
+ except Exception as e :
243
246
if verbosity > 1 :
244
- print "No %s fixture '%s' in %s." % \
245
- (format , fixture_name , humanize (fixture_dir ))
247
+ print ( "No %s fixture '%s' in %s." % \
248
+ (format , fixture_name , humanize (fixture_dir )))
246
249
247
250
self .enable_forward_ref_checks (cursor )
248
251
@@ -252,7 +255,7 @@ def read(self):
252
255
sequence_sql = connection .ops .sequence_reset_sql (self .style , models )
253
256
if sequence_sql :
254
257
if verbosity > 1 :
255
- print "Resetting sequences"
258
+ print ( "Resetting sequences" )
256
259
for line in sequence_sql :
257
260
cursor .execute (line )
258
261
@@ -262,10 +265,10 @@ def read(self):
262
265
263
266
if object_count == 0 :
264
267
if verbosity > 1 :
265
- print "No fixtures found."
268
+ print ( "No fixtures found." )
266
269
else :
267
270
if verbosity > 0 :
268
- print "Installed %d object(s) from %d fixture(s)" % (object_count , fixture_count )
271
+ print ( "Installed %d object(s) from %d fixture(s)" % (object_count , fixture_count ) )
269
272
270
273
# Close the DB connection. This is required as a workaround for an
271
274
# edge case in MySQL: if the same connection is used to
0 commit comments