<commit_before># -*- coding: utf-8 -*-

"""
What Todo

Plugin for Sublime Text to highlight, jump to and export your TODOs

Copyright (c) 2012 <NAME> - FMCorz.net

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

http://github.com/FMCorz/WhatTodo
"""

import re
from os.path import split
import sublime, sublime_plugin

class WhatTodoJumpCommand(sublime_plugin.TextCommand):

	def run(self, edit, backwards = False):
		wt = WhatTodo(self.view)
		wt.find()
		if not wt.has():
			sublime.status_message('No TODO found in this document')
		else:
			wt = WhatTodo(self.view)
			wt.jump(backwards = backwards)

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoShowCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.highlight()

	def is_enabled(self):
		return not WhatTodo.s().get('auto_display')

	def description(self):
		return None

class WhatTodoHideCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.hide()

	def is_enabled(self):
		wt = WhatTodo(self.view)
		return (not wt.s().get('auto_display') and wt.hasHighlighted())

	def description(self):
		return None

class WhatTodoExportCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.export()

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoOutputExportCommand(sublime_plugin.TextCommand):

	def run(self, edit, text):
		self.view.insert(edit, 0, text)

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoEvent(sublime_plugin.EventListener):

	def on_load(self, view):
		if not WhatTodo.s().get('auto_display'):
			return
		wt = WhatTodo(view)
		if wt.canInSyntax():
			wt.highlight()

	def on_modified(self, view):
		if not WhatTodo.s().get('auto_display'):
			return
		wt = WhatTodo(view)
		if wt.canInSyntax():
			wt.highlight()

class WhatTodo(object):

	lastrun = {}

	def __init__(self, view):
		self.view = view
		self.lastrun.setdefault(view.buffer_id(), 0)

	def canInSyntax(self):
		"""Validates the syntax against the user's preferences"""
		syntax = self.view.settings().get('syntax')
		syntax = split(syntax)[0].replace('Packages/', '')
		allowed = self.s().get('limit_to_syntax')
		if '*' in allowed or syntax in allowed:
			return True
		return False

	def export(self):
		"""Export the TODOs to a new buffer"""
		# Force the find in this thread upon export
		self._find()
		todos = self.extract()
		v = sublime.active_window().new_file()
		v.set_name('TODO export')
		fn = self.view.file_name() or 'Unsaved document'

		s = '%s\n\n' % fn
		for (linenb, todo) in todos:
			s += u"{0:>5}:\t{1}\n".format(linenb, todo)

		kwargs = { "text": s }
		v.run_command('what_todo_output_export', kwargs)

	def extract(self):
		"""Extract the sanitized TODO along with its line number"""
		todos = []
		regions = self.get()
		for region in regions:
			shell_vars = self.shell_variables(region.begin())
			cs = shell_vars.setdefault('TM_COMMENT_START', None).strip()
			line = self.view.substr(self.view.line(region))
			todo = re.sub(r'.*%s\s*TODO\s*' % cs, '', line)
			linenb = self.view.rowcol(region.begin())[0]
			todos.append((linenb, todo))
		return todos

	def has(self):
		"""Return the number of regions"""
		return len(self.get())

	def hasHighlighted(self):
		"""Return if there are highlighted regions"""
		return len(self.view.get_regions('what_todo_highlight')) > 0

	def hide(self):
		"""Hides the TODOs"""
		self.view.erase_regions('what_todo_highlight')

	def highlight(self):
		"""Creates an highlight timeout"""
		self.find()
		callback = lambda: self._highlight()
		sublime.set_timeout(callback, 10)

	def _highlight(self):
		"""Highlight the regions"""
		regions = self.view.get_regions('what_todo')
		self.view.add_regions('what_todo_highlight', regions, self.s().get('scope_name'), '', sublime.DRAW_OUTLINED if self.s().get('draw_outlined') else None)

	def find(self):
		"""Creates a find timeout"""
		callback = lambda: self._find()
		sublime.set_timeout(callback, 10)

	def _find(self):
		"""Find the regions"""
		if self.view.size() > self.s().get('threshold'):
			return
<commit_msg>Disabling outline lead to error<commit_after># -*- coding: utf-8 -*-

"""
What Todo

Plugin for Sublime Text to highlight, jump to and export your TODOs

Copyright (c) 2012 <NAME> - FMCorz.net

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

http://github.com/FMCorz/WhatTodo
"""

import re
from os.path import split
import sublime, sublime_plugin

class WhatTodoJumpCommand(sublime_plugin.TextCommand):

	def run(self, edit, backwards = False):
		wt = WhatTodo(self.view)
		wt.find()
		if not wt.has():
			sublime.status_message('No TODO found in this document')
		else:
			wt = WhatTodo(self.view)
			wt.jump(backwards = backwards)

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoShowCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.highlight()

	def is_enabled(self):
		return not WhatTodo.s().get('auto_display')

	def description(self):
		return None

class WhatTodoHideCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.hide()

	def is_enabled(self):
		wt = WhatTodo(self.view)
		return (not wt.s().get('auto_display') and wt.hasHighlighted())

	def description(self):
		return None

class WhatTodoExportCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		wt = WhatTodo(self.view)
		wt.export()

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoOutputExportCommand(sublime_plugin.TextCommand):

	def run(self, edit, text):
		self.view.insert(edit, 0, text)

	def is_enabled(self):
		return True

	def description(self):
		return None

class WhatTodoEvent(sublime_plugin.EventListener):

	def on_load(self, view):
		if not WhatTodo.s().get('auto_display'):
			return
		wt = WhatTodo(view)
		if wt.canInSyntax():
			wt.highlight()

	def on_modified(self, view):
		if not WhatTodo.s().get('auto_display'):
			return
		wt = WhatTodo(view)
		if wt.canInSyntax():
			wt.highlight()

class WhatTodo(object):

	lastrun = {}

	def __init__(self, view):
		self.view = view
		self.lastrun.setdefault(view.buffer_id(), 0)

	def canInSyntax(self):
		"""Validates the syntax against the user's preferences"""
		syntax = self.view.settings().get('syntax')
		syntax = split(syntax)[0].replace('Packages/', '')
		allowed = self.s().get('limit_to_syntax')
		if '*' in allowed or syntax in allowed:
			return True
		return False

	def export(self):
		"""Export the TODOs to a new buffer"""
		# Force the find in this thread upon export
		self._find()
		todos = self.extract()
		v = sublime.active_window().new_file()
		v.set_name('TODO export')
		fn = self.view.file_name() or 'Unsaved document'

		s = '%s\n\n' % fn
		for (linenb, todo) in todos:
			s += u"{0:>5}:\t{1}\n".format(linenb, todo)

		kwargs = { "text": s }
		v.run_command('what_todo_output_export', kwargs)

	def extract(self):
		"""Extract the sanitized TODO along with its line number"""
		todos = []
		regions = self.get()
		for region in regions:
			shell_vars = self.shell_variables(region.begin())
			cs = shell_vars.setdefault('TM_COMMENT_START', None).strip()
			line = self.view.substr(self.view.line(region))
			todo = re.sub(r'.*%s\s*TODO\s*' % cs, '', line)
			linenb = self.view.rowcol(region.begin())[0]
			todos.append((linenb, todo))
		return todos

	def has(self):
		"""Return the number of regions"""
		return len(self.get())

	def hasHighlighted(self):
		"""Return if there are highlighted regions"""
		return len(self.view.get_regions('what_todo_highlight')) > 0

	def hide(self):
		"""Hides the TODOs"""
		self.view.erase_regions('what_todo_highlight')

	def highlight(self):
		"""Creates an highlight timeout"""
		self.find()
		callback = lambda: self._highlight()
		sublime.set_timeout(callback, 10)

	def _highlight(self):
		"""Highlight the regions"""
		regions = self.view.get_regions('what_todo')
		self.view.add_regions('what_todo_highlight', regions, self.s().get('scope_name'), '', sublime.DRAW_OUTLINED if self.s().get('draw_outlined') else 0)

	def find(self):
		"""Creates a find timeout"""
		callback = lambda: self._find()
		sublime.set_timeout(callback, 10)

	def _find(self):
		"""Find the regions"""
		if self.view.size() > self.s().get('threshold'):
			return

{'fraction_non_alphanumeric': 0.14230544177881801, 'fraction_numerical': 0.004095962551199532, 'mean_word_length': 4.419150285351934, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 11, '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': '4840563', 'n_tokens_mistral': 3313, 'n_tokens_neox': 2955, 'n_words': 732}