Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: third_party/twisted_8_1/twisted/python/htmlizer.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/twisted_8_1/twisted/python/hook.py ('k') | third_party/twisted_8_1/twisted/python/lockfile.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/twisted_8_1/twisted/python/htmlizer.py
diff --git a/third_party/twisted_8_1/twisted/python/htmlizer.py b/third_party/twisted_8_1/twisted/python/htmlizer.py
deleted file mode 100644
index bdb31e6fc72ae293240fb0feff006290531a1c6c..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/python/htmlizer.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-#
-import tokenize, cgi, keyword
-import reflect
-
-class TokenPrinter:
-
- currentCol, currentLine = 0, 1
- lastIdentifier = parameters = 0
-
- def __init__(self, writer):
- self.writer = writer
-
- def printtoken(self, type, token, (srow, scol), (erow, ecol), line):
- #print "printtoken(%r,%r,%r,(%r,%r),(%r,%r),%r), row=%r,col=%r" % (
- # self, type, token, srow,scol, erow,ecol, line,
- # self.currentLine, self.currentCol)
- if self.currentLine < srow:
- self.writer('\n'*(srow-self.currentLine))
- self.currentLine, self.currentCol = srow, 0
- self.writer(' '*(scol-self.currentCol))
- if self.lastIdentifier:
- type = "identifier"
- self.parameters = 1
- elif type == tokenize.NAME:
- if keyword.iskeyword(token):
- type = 'keyword'
- else:
- if self.parameters:
- type = 'parameter'
- else:
- type = 'variable'
- else:
- type = tokenize.tok_name.get(type).lower()
- self.writer(token, type)
- self.currentCol = ecol
- self.currentLine += token.count('\n')
- if self.currentLine != erow:
- self.currentCol = 0
- self.lastIdentifier = token in ('def', 'class')
- if token == ':':
- self.parameters = 0
-
-
-class HTMLWriter:
-
- noSpan = []
-
- def __init__(self, writer):
- self.writer = writer
- noSpan = []
- reflect.accumulateClassList(self.__class__, "noSpan", noSpan)
- self.noSpan = noSpan
-
- def write(self, token, type=None):
- token = cgi.escape(token)
- if (type is None) or (type in self.noSpan):
- self.writer(token)
- else:
- self.writer('<span class="py-src-%s">%s</span>' %
- (type, token))
-
-
-class SmallerHTMLWriter(HTMLWriter):
- """HTMLWriter that doesn't generate spans for some junk.
-
- Results in much smaller HTML output.
- """
- noSpan = ["endmarker", "indent", "dedent", "op", "newline", "nl"]
-
-def filter(inp, out, writer=HTMLWriter):
- out.write('<pre>\n')
- printer = TokenPrinter(writer(out.write).write).printtoken
- try:
- tokenize.tokenize(inp.readline, printer)
- except tokenize.TokenError:
- pass
- out.write('</pre>\n')
-
-def main():
- import sys
- filter(open(sys.argv[1]), sys.stdout)
-
-if __name__ == '__main__':
- main()
« no previous file with comments | « third_party/twisted_8_1/twisted/python/hook.py ('k') | third_party/twisted_8_1/twisted/python/lockfile.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698