This file is indexed.

/usr/share/gEcrit/data/plugins/SpellChecker.py is in gecrit 2.8.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#  Copyright (C) 2011  Groza Cristian
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

#!/usr/bin/python
# -*- coding: utf-8 -*-

#!/usr/bin/python
# -*- coding: utf-8 -*-

import wx
from data.plugins.categories import General
import yapsy.IPlugin

try:
    import enchant
    import enchant.checker.wxSpellCheckerDialog
except:
    print "Spell checker pyenchant is not available."


class SpellCheckDialog(enchant.checker.wxSpellCheckerDialog.wxSpellCheckerDialog):
    def __init__(self, parent):
        self.parent = parent
        enchant.checker.wxSpellCheckerDialog.wxSpellCheckerDialog.__init__(self,self.parent,
                                            -1, title = "Spell Checker")



class SpellChecker(General, yapsy.IPlugin.IPlugin):
    """
    Provides the necessary functions for spellchecking.
    Uses the enchant module.

    """

    def __init__(self):
        """
        __init__

        Initializes the enchant module, sets the language
        dictionary.
        """

        self.name = "Spell Checker"

        try:
            self.dictionary = enchant.Dict()
        except enchant.Error:
            print "The Dictionary could not be identified.\n  Falling back to English."
            self.dictionary = enchant.Dict("en_US")
        self.spell_checker = enchant.checker.SpellChecker(self.dictionary.tag)

    def Init(self, parent):
        self.parent = parent
        self.current_doc = None
        self.last_word = ""

        self.plugins_menu = wx.Menu()
        edit_entry = self.plugins_menu.Append(-1,"Show Spell Checker")

        self.menu_item = self.parent.AddToMenuBar("Spell Checker",
                                                      self.plugins_menu)
        self.parent.BindMenubarEvent(edit_entry, self.ShowMe)

        self.spell_dlg = SpellCheckDialog(self.parent)
        self.spell_dlg.SetSpellChecker(self.spell_checker)
        self.spell_dlg.Bind(wx.EVT_CLOSE, self.HideMe)

    def CheckWord(self, word):
        """
        CheckWord

        Calls enchant to check the suplied argument word.
        """
        return self.dictionary.check(word)

    def GetSuggestion(self, word):
        """
        GetSuggestion

        Calls the enchant library to generate
        spelling suggestion for the suplied argument
        word.
        """
        return self.dictionary.suggest(word)

    def ShowSpellDialog(self, event):
        """"
        ShowSpellDialog

        not implemented
        """
        pass


    def SpellCheck(self, event):
        """
            OnSpellCheck

            Delivers the data to the spell checker, and manages
            the underlineing and clearing of the text.
        """

        st = self.current_doc.WordStartPosition(self.current_doc.GetCurrentPos(), False)
        end = self.current_doc.WordEndPosition(self.current_doc.GetCurrentPos(), False)
        word = self.current_doc.GetTextRange(st, end)
        self.last_word = word


        spelled_ok = self.CheckWord(word)

        if not spelled_ok:
            self.current_doc.StartStyling(st, wx.stc.STC_INDIC0_MASK)
            self.current_doc.SetStyling(end - st, wx.stc.STC_INDIC0_MASK)


        else:
            self.current_doc.StartStyling(st, wx.stc.STC_INDIC0_MASK)
            self.current_doc.SetStyling(end - st, 0)
            self.current_doc.spell_error = False

        event.Skip()


    def NotifyDocumentOpened(self):
        self.current_doc = self.parent.GetCurrentDocument()
        self.current_doc.Bind(wx.stc.EVT_STC_CHARADDED, self.SpellCheck)
    	self.current_doc.IndicatorSetStyle(0, wx.stc.STC_INDIC_SQUIGGLE)
    	self.current_doc.IndicatorSetForeground(0, wx.RED)

    def NotifyNewTabOpened(self):
        self.current_doc = self.parent.GetCurrentDocument()
        self.current_doc.Bind(wx.stc.EVT_STC_CHARADDED, self.SpellCheck)
    	self.current_doc.IndicatorSetStyle(0, wx.stc.STC_INDIC_SQUIGGLE)
    	self.current_doc.IndicatorSetForeground(0, wx.RED)


    def NotifyTabChanged(self):
        self.current_doc = self.parent.GetCurrentDocument()
        self.last_word = ""


    def HideMe(self, event):
        self.spell_dlg.Hide()

    def ShowMe(self, event):
        rng = self.current_doc.GetSelection()
        self.spell_checker.set_text(self.current_doc.GetTextRange(rng[0],rng[1]))
        self.spell_dlg.SetSpellChecker(self.spell_checker)
        self.spell_dlg.Show()