From a0c8d26cd9dc9cb1bbaa0cae8cd5214ad5513c0a Mon Sep 17 00:00:00 2001 From: Peter Gerdes Date: Tue, 30 Jul 2019 20:22:05 -0400 Subject: [PATCH] Fixed both utf-8 issue and non-existant objects --- boundkeys.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/boundkeys.py b/boundkeys.py index d60ce6f..571936e 100644 --- a/boundkeys.py +++ b/boundkeys.py @@ -8,7 +8,7 @@ import json import re import collections - +import sys class BoundKeysCommand(sublime_plugin.TextCommand): def removeComments(self, text): @@ -233,7 +233,7 @@ def run(self, edit): continue zip = zipfile.ZipFile(fullPath, "r") jsonObj = self.jsonify( - str(zip.open(fileZipPath, "r").read(), "utf-8") + str(zip.open(fileZipPath, "r").read(), sys.getfilesystemencoding()) ) zip.close() except IOError: @@ -301,12 +301,13 @@ def run(self, edit): jsonObj = self.jsonify( str(zip.open(zipName, "r").read(), "utf-8") ) - userKeys[lastPath] = {} - userKeys[lastPath]["name"] = name - userKeys[lastPath]["loc_key"] = pathName - userKeys[lastPath]["object"] = jsonObj - userKeys[lastPath]["path"] = fullPath - userKeys[lastPath]["zipName"] = zipName + if jsonObj: + userKeys[lastPath] = {} + userKeys[lastPath]["name"] = name + userKeys[lastPath]["loc_key"] = pathName + userKeys[lastPath]["object"] = jsonObj + userKeys[lastPath]["path"] = fullPath + userKeys[lastPath]["zipName"] = zipName zip.close() except IOError: print("File not found: %s" % fullPath) @@ -333,7 +334,7 @@ def run(self, edit): if lastPath in subKeys or lastPath in userKeys: continue try: - jsonObj = self.jsonify(open(filePath, "r").read()) + jsonObj = self.jsonify(open(filePath, "r", encoding='utf-8').read()) except IOError: errorLoading.append(filePath) if jsonObj: