add path to save/open json file

This commit is contained in:
jomo
2014-07-27 06:04:31 +02:00
parent d58d975910
commit e9b0ad656b
2 changed files with 4 additions and 5 deletions

View File

@@ -1,7 +1,6 @@
from helpers import *
friends_filename = "plugins/redstoner-utils.py.dir/files/friends.json"
friends = open_json_file(friends_filename, {}) # {Player_UUID:[List_of_friend_uuids]}
friends = open_json_file("friends", {}) # {Player_UUID:[List_of_friend_uuids]}
friend_join_sound = "random.orb"
@@ -18,7 +17,7 @@ def fjm(event): # friend join message
def save_friends(): # saves to friends file
save_json_file(friends_filename, friends)
save_json_file("friends", friends)
def friendmessage(player, message): # sends a message with a prefix

View File

@@ -126,7 +126,7 @@ def open_json_file(filename, default):
"""
data = None
try:
with open(filename) as obj:
with open("plugins/redstoner-utils.py.dir/files/%s.json" % filename) as obj:
data = json_loads(obj.read())
except Exception, e:
error("Failed to read from %s: %s" % (filename, e))
@@ -139,7 +139,7 @@ def save_json_file(filename, obj):
filename is the path + name of the file.
"""
try:
with open(filename, "w") as f:
with open("plugins/redstoner-utils.py.dir/files/%s.json" % filename, "w") as f:
f.write(json_dumps(obj))
except Exception, e:
error("Failed to write to %s: %s" % (filename, e))