Hey everyone,
I am new to plugin development and trying to validate some details. It’s a learning project. My whole idea to mark out all invalid data as per my validation. Here is my code
import sublime, sublime_plugin
import logging
import os
import urllib
import urllib2
import json
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
user = os.environ.get('USER')
log_file = "/Users/$USER/Desktop/fuck.txt".replace("$USER",str(user))
logging.basicConfig(filename=log_file,level=logging.DEBUG)
region = sublime.Region(0, self.view.size())
logging.debug('Beautifying Entire File')
rawcode = self.view.substr(region)
str_rawcode = str(rawcode)
headers = {'content-type': "application/json"}
request = urllib2.Request("http://localhost:8080/validation/client-spec/",str_rawcode,headers)
response = urllib2.urlopen(request)
html = response.read()
logging.info(" respose info ::")
logging.info(html)
json_data = json.loads(html)
for key,value in json_data.iteritems():
logging.info("key: {key} | value: {value}".format(key=key, value=value))
if value=="invalid":
content = self.view.substr(sublime.Region(0, self.view.size()))
begin = content.find(key)
if begin == -1:
return
end = begin + len(key)
target_region = sublime.Region(begin, end)
self.view.sel().clear()
self.view.add_regions('sublimelinter-annotations.error-gutter-marks',target_region,scope='sublimelinter.mark.annotations.error', icon='dot', flags=sublime.INHIBIT_WORD_COMPLETIONS)
When I execute command view.run_command('example')
I get following error. Please help me out. I am using sublime 2.
File "./learn.py", line 34, in run
self.view.add_regions('sublimelinter-annotations.error-gutter-marks',target_region,scope='sublimelinter.mark.annotations.error', icon='dot', flags=sublime.INHIBIT_WORD_COMPLETIONS)
Boost.Python.ArgumentError: Python argument types in
View.add_regions(View, Edit, str, Region)
did not match C++ signature:
add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)
add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)