I’m developing a plugin that checks JSON file for valid format and does some other checks.
But looks like there’re different Python versions for different directories in Sublime Text 3 on Ubuntu 22.04.4 LTS.
I have the following files in my plugin:
WiregockValidator.py (just checks is all text in opened file is a valid JSON):
import sublime
import sublime_plugin
#view.run_command('wiregock')
class WiregockCommand(sublime_plugin.TextCommand):
def run(self, edit):
wiregock_validate(self.view.substr(sublime.Region(0, self.view.size())))
def wiregock_validate(text):
from json import loads
from json.decoder import JSONDecodeError
from logging import getLogger
logger = getLogger(__name__)
js = None
try:
js = loads(text)
except JSONDecodeError as e:
logger.error("Error while parsing JSON:\n{0}\n{1}".format(text, str(e)))
return False
return True
Also I have Main.sublime-menu and Default.sublime-keymap to put in in menu
When I put this 3 files in Packages/User directory it works just fine.
When I put them in Packages/User/WiregockValidator subdirectory it doesn’t even load, menu item appears in menu, but is disabled.
When I put them in Packages/WiregockValidator it doesn’t load as well. When I try to call command, I got an error:
Traceback (most recent call last):
File "/snap/sublime-text/177/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1488, in run_
return self.run(edit)
File "/home/rikki/.config/sublime-text-3/Packages/WiregockValidator.py", line 7, in run
wiregock_validate(self.view.substr(sublime.Region(0, self.view.size())))
File "/home/rikki/.config/sublime-text-3/Packages/WiregockValidator.py", line 11, in wiregock_validate
from json.decoder import JSONDecodeError
ImportError: cannot import name JSONDecodeError
What’s wrong with it? How can Python lose json.decoder just by moving file to another dir?