Commits

Chris Mutel committed 45c2413

Fix JSON writing to file bug

  • Participants
  • Parent commits 27d026d

Comments (0)

Files changed (3)

File brightway2/__init__.py

 # -*- coding: utf-8 -*
 from _config import config
-from meta import databases, methods, mapping
+from meta import databases, methods, mapping, reset_meta
 from database import Database
 from method import Method
 from query import Query, Filter, Result

File brightway2/meta.py

 mapping = Mapping()
 databases = Databases()
 methods = Methods()
+
+
+def reset_meta():
+    mapping.__init__()
+    databases.__init__()
+    methods.__init__()

File brightway2/serialization.py

 class JsonWrapper(object):
     @classmethod
     def dump(self, data, file):
-        if anyjson:
-            with open(file, "w") as f:
+        with open(file, "w") as f:
+            if anyjson:
                 f.write(anyjson.serialize(data))
-        else:
-            json.dump(data, file, indent=2)
+            else:
+                json.dump(data, f, indent=2)
 
     @classmethod
     def load(self, file):