<commit_before>from queue import Queue
import re
import sublime

from lint.highlight import Highlight
import lint.persist as persist
import lint.util as util

syntax_re = re.compile(r'/([^/]+)\.tmLanguage$')

class Tracker(type):
	def __init__(cls, name, bases, attrs):
		persist.add_language(cls, name, attrs)

class Linter(metaclass=Tracker):
	language = ''
	cmd = ()
	regex = ''
	multiline = False
	flags = 0
	tab_size = 1
	
	scope = 'keyword'
	selector = None
	outline = True
	needs_api = False

	errors = None
	highlight = None

	def __init__(self, view, syntax, filename=None):
		self.view = view
		self.syntax = syntax
		self.filename = filename

		if self.regex:
			if self.multiline:
				self.flags |= re.MULTILINE

			self.regex = re.compile(self.regex, self.flags)

		self.highlight = Highlight(scope=self.scope)

	@property
	def settings(self):
		return self.__class__.lint_settings

	@classmethod
	def assign(cls, view):
		'''
		find a linter for a specified view if possible, then add it to our mapping of view <--> lint class and return it
		each view has its own linter to make it feasible for linters to store persistent data about a view
		'''
		try:
			vid = view.id()
		except RuntimeError:
			pass

		settings = view.settings()
		syn = settings.get('syntax')
		if not syn:
			cls.remove(vid)
			return

		match = syntax_re.search(syn)

		if match:
			syntax, = match.groups()
		else:
			syntax = syn<commit_msg>print message and fallback on regex errors<commit_after>from queue import Queue
import re
import sublime

from lint.highlight import Highlight
import lint.persist as persist
import lint.util as util

syntax_re = re.compile(r'/([^/]+)\.tmLanguage$')

class Tracker(type):
	def __init__(cls, name, bases, attrs):
		persist.add_language(cls, name, attrs)

class Linter(metaclass=Tracker):
	language = ''
	cmd = ()
	regex = ''
	multiline = False
	flags = 0
	tab_size = 1
	
	scope = 'keyword'
	selector = None
	outline = True
	needs_api = False

	errors = None
	highlight = None

	def __init__(self, view, syntax, filename=None):
		self.view = view
		self.syntax = syntax
		self.filename = filename

		if self.regex:
			if self.multiline:
				self.flags |= re.MULTILINE

			try:
				self.regex = re.compile(self.regex, self.flags)
			except:
				persist.debug('Error compiling regex for {}'.format(self.language))

		self.highlight = Highlight(scope=self.scope)

	@property
	def settings(self):
		return self.__class__.lint_settings

	@classmethod
	def assign(cls, view):
		'''
		find a linter for a specified view if possible, then add it to our mapping of view <--> lint class and return it
		each view has its own linter to make it feasible for linters to store persistent data about a view
		'''
		try:
			vid = view.id()
		except RuntimeError:
			pass

		settings = view.settings()
		syn = settings.get('syntax')
		if not syn:
			cls.remove(vid)
			return

		match = syntax_re.search(syn)

		if match:
			syntax, = match.groups()
		else:
			syntax = syn
{'fraction_non_alphanumeric': 0.10485762144053601, 'fraction_numerical': 0.001340033500837521, 'mean_word_length': 3.565749235474006, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7269598', 'n_tokens_mistral': 1112, 'n_tokens_neox': 972, 'n_words': 314}