Skip to content
Browse files

Merge pull request #35 from punchagan/master

Get fixture-magic working with Py3.
  • Loading branch information...
2 parents 8a16fe0 + 2f34dbc commit 0f8fe6e1b8ce1ca96ce384ad7c949e778232a50e @davedash committed
View
4 fixture_magic/management/commands/custom_dump.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
import sys
try:
import json
@@ -41,4 +43,4 @@ def handle(self, dump_name, *pks, **options):
data = reorder_json(json.loads(data), dump_settings.get('order', []),
ordering_cond=dump_settings.get('order_cond',{}))
- print json.dumps(data, indent=4)
+ print(json.dumps(data, indent=4))
View
2 fixture_magic/management/commands/dump_object.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
from optparse import make_option
from django.core.exceptions import FieldError, ObjectDoesNotExist
View
8 fixture_magic/management/commands/merge_fixtures.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
try:
import json
except ImportError:
@@ -10,9 +12,9 @@ def write_json(output):
# check our json import supports sorting keys
json.dumps([1], sort_keys=True)
except TypeError:
- print json.dumps(output, indent=4)
+ print(json.dumps(output, indent=4))
else:
- print json.dumps(output, sort_keys=True, indent=4)
+ print(json.dumps(output, sort_keys=True, indent=4))
class Command(BaseCommand):
help = ('Merge a series of fixtures and remove duplicates.')
@@ -27,7 +29,7 @@ def handle(self, *files, **options):
seen = {}
for f in files:
- f = file(f)
+ f = open(f)
data = json.loads(f.read())
for object in data:
key = '%s|%s' % (object['model'], object['pk'])
View
6 fixture_magic/management/commands/reorder_fixtures.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
try:
import json
except ImportError:
@@ -13,6 +15,6 @@ class Command(BaseCommand):
args = '[fixture model ...]'
def handle(self, fixture, *models, **options):
- output = reorder_json(json.loads(file(fixture).read()), models)
+ output = reorder_json(json.loads(open(fixture).read()), models)
- print json.dumps(output, indent=4)
+ print(json.dumps(output, indent=4))
View
2 fixture_magic/utils.py
@@ -28,7 +28,7 @@ def reorder_json(data, models, ordering_cond={}):
else:
others.append(object)
for model in models:
- if ordering_cond.has_key(model):
+ if model in ordering_cond:
bucket[model].sort(key=ordering_cond[model])
output.extend(bucket[model])

0 comments on commit 0f8fe6e

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