Пример #1
0
    def get(self):

	lexers = [(lexer[0], lexer[1]) for lexer in get_all_lexers() if lexer[0] in self.targetLexers]
	lexers.sort()

	templateValues = {'pygmentsVersion': pygments.__version__,
			  'lexers': lexers}

	self.response.out.write(template.render('templates/monkeypygment.html', templateValues))
Пример #2
0
def home(request):
    # Fetch all the lexers.  We only need a map of alias => name to build the
    # form, so grab those.  Using a set helps when Pygments has duplicate
    # lexers (that claim to own different file or MIME types), which is a thing
    # that happens apparently.
    lexerset = set()
    for name, aliases, filetypes, mimetypes in pygments.lexers.get_all_lexers():
        lexerset.add((name, aliases[0]))

    # Sort by name
    lexers = list(lexerset)
    lexers.sort(key=lambda lexer: lexer[0].lower())

    return dict(
        #guessed_name=ipmap.get(request.remote_addr, ''),
        lexers=lexers,
    )