Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79c05fb

Browse files
committed
minor Python 3 updates
1 parent da5c719 commit 79c05fb

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

django_pyodbc/management/commands/ss_loaddata.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
ss_loaddata management command, we need to keep close track of changes in
4545
django/core/management/commands/loaddata.py.
4646
"""
47+
48+
from __future__ import print_function
49+
4750
import sys
4851
import os
4952
import gzip
@@ -151,7 +154,7 @@ def read(self):
151154

152155
if formats:
153156
if verbosity > 1:
154-
print "Loading '%s' fixtures..." % fixture_name
157+
print("Loading '%s' fixtures..." % fixture_name)
155158
else:
156159
self.enable_forward_ref_checks(cursor)
157160
sys.stderr.write(
@@ -168,7 +171,7 @@ def read(self):
168171

169172
for fixture_dir in fixture_dirs:
170173
if verbosity > 1:
171-
print "Checking %s for fixtures..." % humanize(fixture_dir)
174+
print("Checking %s for fixtures..." % humanize(fixture_dir))
172175

173176
label_found = False
174177
for format in formats:
@@ -180,26 +183,26 @@ def read(self):
180183
file_name = '.'.join([fixture_name, format])
181184

182185
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))
185188
full_path = os.path.join(fixture_dir, file_name)
186189
open_method = compression_types[compression_format]
187190
try:
188191
fixture = open_method(full_path, 'r')
189192
if label_found:
190193
fixture.close()
191194
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))))
194197
transaction.rollback()
195198
transaction.leave_transaction_management()
196199
return
197200
else:
198201
fixture_count += 1
199202
objects_in_fixture = 0
200203
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)))
203206
try:
204207
objects = serializers.deserialize(format, fixture)
205208
for obj in objects:
@@ -239,10 +242,10 @@ def read(self):
239242
transaction.leave_transaction_management()
240243
return
241244

242-
except Exception, e:
245+
except Exception as e:
243246
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)))
246249

247250
self.enable_forward_ref_checks(cursor)
248251

@@ -252,7 +255,7 @@ def read(self):
252255
sequence_sql = connection.ops.sequence_reset_sql(self.style, models)
253256
if sequence_sql:
254257
if verbosity > 1:
255-
print "Resetting sequences"
258+
print("Resetting sequences")
256259
for line in sequence_sql:
257260
cursor.execute(line)
258261

@@ -262,10 +265,10 @@ def read(self):
262265

263266
if object_count == 0:
264267
if verbosity > 1:
265-
print "No fixtures found."
268+
print("No fixtures found.")
266269
else:
267270
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))
269272

270273
# Close the DB connection. This is required as a workaround for an
271274
# edge case in MySQL: if the same connection is used to

0 commit comments

Comments
 (0)