This file is indexed.

/usr/share/pygfarm/dict.pyg is in pygfarm 2.0.18.3+nmu3.

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

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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# -*-Python-*-
import sys, string
from pygopherd.handlers.pyg import PYGBase
from pygopherd.gopherentry import GopherEntry, getinfoentry
import dictclient

def matchsort(x, y):
    return cmp(x.lower(), y.lower())

class PYGMain(PYGBase):
    def canhandlerequest(self):
        arglist = []
        if self.selectorargs:
            arglist = self.selectorargs.split("/")
        self.dbname = None
        self.dbcommand = None
        self.commandargs = []
        if len(arglist) >= 2:
            self.dbname = arglist[1]
        if len(arglist) >= 3:
            self.dbcommand = arglist[2]
        if len(arglist) >= 4:
            self.commandargs = arglist[3:]
        if self.searchrequest:
            self.commandargs.append(self.searchrequest)

        if self.dbcommand == 'DEFINE':
            self.__class__ = DefineMenu
        elif self.dbcommand == 'DEFINITION':
            self.__class__ = Definition
        elif self.dbcommand == 'MATCH':
            self.__class__ = Match
        elif self.dbcommand == 'MATCHMENU':
            self.__class__ = MatchMenu
        elif self.dbcommand == 'DBINFO':
            self.__class__ = DBInfo
        elif self.dbname:
            self.__class__ = Browse
        else:
            self.__class__ = TopMenu
        return 1
            
class TopMenu(PYGMain):
    def prepare(self):
        self.db = dictclient.Connection()
        self.entries = []

        intro = ["Welcome to the dictionary server!",
                 " ",
                 "To do a quick lookup, use the following search:",
                 " "]

        for item in intro:
            self.entries.append(getinfoentry(item, self.config))

        selector = self.genargsselector("/*/DEFINE")
        entry = GopherEntry(selector, self.config)
        entry.type = '7'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Definition Lookup -- All Databases'
        self.entries.append(entry)

        selector = self.genargsselector("/*/MATCHMENU")
        entry = GopherEntry(selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Advanced Search -- All Databases'
        self.entries.append(entry)

        intro = [" ", "Use the following links to search a particular",
                 "database or to browse ALL the definitions",
                 "in a database!", " "]

        for item in intro:
            self.entries.append(getinfoentry(item, self.config))

        items = self.db.getdbdescs().items()
        items.sort(lambda x, y: cmp(x[1], y[1]))

        for name, desc in items:
            selector = self.genargsselector("/%s" % name)
            entry = GopherEntry(selector, self.config)
            entry.type = '1'
            entry.mimetype = 'application/gopher-menu'
            entry.name = desc
            self.entries.append(entry)

    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Dictionary Search'
        return entry

    def isdir(self):
        return 1

    def getdirlist(self):
        return self.entries

    
class Browse(PYGMain):
    def prepare(self):
        self.entries = []

        intro = ["You can browse the entries in the database by",
                 "selecting the first letter of the item you want.",
                 " "]

        for item in intro:
            self.entries.append(getinfoentry(item, self.config))

        selector = self.genargsselector("/%s/DEFINE" % self.dbname)
        entry = GopherEntry(selector, self.config)
        entry.type = '7'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Search This Database'
        self.entries.append(entry)

        selector = self.genargsselector("/%s/MATCHMENU" % self.dbname)
        entry = GopherEntry(selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Advanced Search for This Database'
        self.entries.append(entry)

        if self.dbname != '*':
            selector = self.genargsselector("/%s/DBINFO" % self.dbname)
            entry = GopherEntry(selector, self.config)
            entry.type = '0'
            entry.mimetype = 'text/plain'
            dictconn = dictclient.Connection()
            entry.name = 'About ' + \
                         dictclient.Database(dictconn, self.dbname).getdescription()
            self.entries.append(entry)

        selector = self.genargsselector("/%s/MATCH/re/^[^a-zA-Z]" % \
                                        self.dbname)
        entry = GopherEntry(selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = "Items that do not begin with a letter"
        self.entries.append(entry)
        
        for letter in string.ascii_uppercase:
            selector = self.genargsselector("/%s/MATCH/re/^[%s%s]" % \
                                            (self.dbname, letter,
                                            letter.lower()))
            entry = GopherEntry(selector, self.config)
            entry.type = '1'
            entry.mimetype = 'application/gopher-menu'
            entry.name = letter
            self.entries.append(entry)

    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Dictionary Database Browse'
        return entry

    def isdir(self):
        return 1

    def getdirlist(self):
        return self.entries

class DefineMenu(PYGMain):
    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Definition Menu for %s' % self.commandargs[0]
        return entry
    
    def prepare(self):
        self.db = dictclient.Connection()
        self.entries = []

        entry = getinfoentry("Definitions for '%s' in database '%s'" % \
                             (self.commandargs[0], self.dbname), self.config)
        self.entries.append(entry)

        defs = self.db.define(self.dbname, self.commandargs[0])

        if len(defs):
            selector = self.genargsselector("/%s/DEFINITION/%s" %
                                            (self.dbname, self.commandargs[0]))
            entry = GopherEntry(selector, self.config)
            entry.type = '0'
            entry.mimetype = 'text/plain'
            entry.name = 'All %d definitions on a single page' % len(defs)
            self.entries.append(entry)
        else:
            entry = getinfoentry("No definitions found.", self.config)
            self.entries.append(entry)

        for i in range(len(defs)):
            selector = self.genargsselector("/%s/DEFINITION/%s" % \
                                            (defs[i].getdb().getname(),
                                             defs[i].getword()))
            entry = GopherEntry(selector, self.config)
            entry.type = '0'
            entry.mimetype = 'text/plain'
            entry.name = "'%s' in %s" % (defs[i].getword(),
                                         defs[i].getdb().getdescription())
            self.entries.append(entry)

        self.entries.append(getinfoentry(" ", self.config))
        self.entries.append(getinfoentry("Definitions for similar words:",
                                         self.config))

        matches = self.db.match(self.dbname, 'lev', self.commandargs[0])
        matchlist = unique([x.getword() for x in matches])
        matchlist.sort(matchsort)

        if not len(matchlist):
            self.entries.append(getinfoentry("No similar definitions found.",
                                             self.config))

        for matchword in matchlist:
            selector = self.genargsselector("/%s/DEFINE/%s" % \
                                            (self.dbname, matchword))
            entry = GopherEntry(selector, self.config)
            entry.type = '1'
            entry.mimetype = 'application/gopher-menu'
            entry.name = matchword
            self.entries.append(entry)

    def isdir(self):
        return 1

    def getdirlist(self):
        return self.entries

class Definition(PYGMain):
    def prepare(self):
        self.db = dictclient.Connection()
        self.definition = ""
        defs = self.db.define(self.dbname, self.commandargs[0])

        if not len(defs):
            self.definition = "No definition found."
            return

        for d in defs:
            self.definition += "DEFINITION of '%s'\nFrom %s\n\n" % \
                               (d.getword(), d.getdb().getdescription())
            self.definition += d.getdefstr()
            self.definition += "\n" + ('-' * 60) + "\n"

        self.definition += "Generated by dict.pyg for Pygopherd by John Goerzen <jgoerzen@complete.org>\n"
        self.definition += "dict.pyg and Pygopherd licensed under the GPL.\n"

    def write(self, wfile):
        wfile.write(self.definition)

    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '0'
        entry.mimetype = 'text/plain'
        entry.name = 'Definition for %s' % self.commandargs[0]
        return entry

class Match(PYGMain):
    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Match menu for %s' % self.commandargs[1]
        return entry

    def prepare(self):
        self.conn = dictclient.Connection()
        self.entries = []

        matches = self.conn.match(self.dbname, self.commandargs[0],
                                  self.commandargs[1])
        if not len(matches):
            self.entries.append(getinfoentry("No matches.",
                                             self.config))
            return

        matchlist = unique([x.getword() for x in matches])
        matchlist.sort(matchsort)

        self.entries.append(getinfoentry("%d matches for '%s' (%s)" % \
                                         (len(matchlist),
                                          self.commandargs[1],
                                          self.commandargs[0]), self.config))
        
        for matchword in matchlist:
            selector = self.genargsselector("/%s/DEFINE/%s" % \
                                            (self.dbname, matchword))
            entry = GopherEntry(selector, self.config)
            entry.type = '1'
            entry.mimetype = 'application/gopher-menu'
            entry.name = matchword
            self.entries.append(entry)

    def isdir(self):
        return 1

    def getdirlist(self):
        return self.entries

class MatchMenu(PYGMain):
    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '1'
        entry.mimetype = 'application/gopher-menu'
        entry.name = 'Advanced Search Options for %s' % self.dbname
        return entry

    def prepare(self):
        self.conn = dictclient.Connection()
        self.entries = []

        self.entries.append(getinfoentry("Advanced Search: " + self.dbname,
                                         self.config))

        for name, desc in self.conn.getstratdescs().items():
            selector = self.genargsselector("/%s/MATCH/%s" % \
                                            (self.dbname, name))
            entry = GopherEntry(selector, self.config)
            entry.type = '7'
            entry.mimetype = 'application/gopher-menu'
            entry.name = 'Search with %s (%s)' % (name, desc)
            self.entries.append(entry)

    def isdir(self):
        return 1

    def getdirlist(self):
        return self.entries

class DBInfo(PYGMain):
    def prepare(self):
        self.conn = dictclient.Connection()
        self.conn.getdbdescs()
        self.db = self.conn.getdbobj(self.dbname)
        self.infotext = self.db.getinfo()

    def write(self, wfile):
        wfile.write("About %s (%s):\n\n" % (self.dbname, self.db.getdescription()))
        wfile.write(self.infotext)

    def getentry(self):
        entry = GopherEntry(self.selector, self.config)
        entry.type = '0'
        entry.mimetype = 'text/plain'
        entry.name = 'Information for %s' % self.dbname
        return entry

def unique(input):
    """Return a list of the elements in input, but without duplicates.
    Performs a case-insensitive check."""
    retval = []
    check  = {}
    for item in input:
        if not check.has_key(item.lower()):
            retval.append(item)
            check[item.lower()] = 1
    return retval