summaryrefslogtreecommitdiff
path: root/helpers.py
diff options
context:
space:
mode:
authorDico200 <dico.karssiens@gmail.com>2015-05-18 23:00:54 +0200
committerDico200 <dico.karssiens@gmail.com>2015-05-18 23:00:54 +0200
commit057b404b03d2998daf2b970766efebefbd6a5fa8 (patch)
treeee3717a719bf106390362c86e046be86524ff030 /helpers.py
parentdd1f0b8356408bc2ac01652365d9ecaacfec31ba (diff)
Small change to open_json_file()
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/helpers.py b/helpers.py
index 17952d1..6d64755 100644
--- a/helpers.py
+++ b/helpers.py
@@ -180,24 +180,23 @@ def known_player(player):
return player.hasPlayedBefore()
-def open_json_file(filename, default):
+def open_json_file(filename, default = None):
"""
opens the given json file and returns an object or returns None on error
- filename is the path + name of the file.
+ filename is only the name of the file without .json appended.
"""
- data = None
try:
with open("plugins/redstoner-utils.py.dir/files/%s.json" % filename) as obj:
- data = json_loads(obj.read())
+ default = json_loads(obj.read())
except Exception, e:
error("Failed to read from %s: %s" % (filename, e))
- return (default if data is None else data)
+ return default
def save_json_file(filename, obj):
"""
saves the given object as json into filename
- filename is the path + name of the file.
+ filename is only the name of the file without .json appended.
"""
try:
with open("plugins/redstoner-utils.py.dir/files/%s.json" % filename, "w") as f: