PageRenderTime 224ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/geshi/geshi/python.php

https://github.com/digitarald/redracer
PHP | 231 lines | 149 code | 6 blank | 76 comment | 0 complexity | 0c643873afcf6ce3ce53448278671a4b MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0, BSD-3-Clause, Apache-2.0
  1. <?php
  2. /*************************************************************************************
  3. * python.php
  4. * ----------
  5. * Author: Roberto Rossi (rsoftware@altervista.org)
  6. * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter)
  7. * Release Version: 1.0.8
  8. * Date Started: 2004/08/30
  9. *
  10. * Python language file for GeSHi.
  11. *
  12. * CHANGES
  13. * -------
  14. * 2005/05/26
  15. * - Modifications by Tim (tim@skreak.com): added more keyword categories, tweaked colors
  16. * 2004/11/27 (1.0.1)
  17. * - Added support for multiple object splitters
  18. * 2004/08/30 (1.0.0)
  19. * - First Release
  20. *
  21. * TODO (updated 2004/11/27)
  22. * -------------------------
  23. *
  24. *************************************************************************************
  25. *
  26. * This file is part of GeSHi.
  27. *
  28. * GeSHi is free software; you can redistribute it and/or modify
  29. * it under the terms of the GNU General Public License as published by
  30. * the Free Software Foundation; either version 2 of the License, or
  31. * (at your option) any later version.
  32. *
  33. * GeSHi is distributed in the hope that it will be useful,
  34. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. * GNU General Public License for more details.
  37. *
  38. * You should have received a copy of the GNU General Public License
  39. * along with GeSHi; if not, write to the Free Software
  40. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  41. *
  42. ************************************************************************************/
  43. $language_data = array (
  44. 'LANG_NAME' => 'Python',
  45. 'COMMENT_SINGLE' => array(1 => '#'),
  46. 'COMMENT_MULTI' => array(),
  47. 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  48. //Longest quotemarks ALWAYS first
  49. 'QUOTEMARKS' => array('"""', '"', "'"),
  50. 'ESCAPE_CHAR' => '\\',
  51. 'KEYWORDS' => array(
  52. /*
  53. ** Set 1: reserved words
  54. ** http://python.org/doc/current/ref/keywords.html
  55. */
  56. 1 => array(
  57. 'and', 'del', 'for', 'is', 'raise', 'assert', 'elif', 'from', 'lambda', 'return', 'break',
  58. 'else', 'global', 'not', 'try', 'class', 'except', 'if', 'or', 'while', 'continue', 'exec',
  59. 'import', 'pass', 'yield', 'def', 'finally', 'in', 'print'
  60. ),
  61. /*
  62. ** Set 2: builtins
  63. ** http://python.org/doc/current/lib/built-in-funcs.html
  64. */
  65. 2 => array(
  66. '__import__', 'abs', 'basestring', 'bool', 'callable', 'chr', 'classmethod', 'cmp',
  67. 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile',
  68. 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help',
  69. 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals',
  70. 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
  71. 'raw_input', 'reduce', 'reload', 'reversed', 'round', 'set', 'setattr', 'slice',
  72. 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode',
  73. 'vars', 'xrange', 'zip',
  74. // Built-in constants: http://python.org/doc/current/lib/node35.html
  75. 'False', 'True', 'None', 'NotImplemented', 'Ellipsis',
  76. // Built-in Exceptions: http://python.org/doc/current/lib/module-exceptions.html
  77. 'Exception', 'StandardError', 'ArithmeticError', 'LookupError', 'EnvironmentError',
  78. 'AssertionError', 'AttributeError', 'EOFError', 'FloatingPointError', 'IOError',
  79. 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'MemoryError', 'NameError',
  80. 'NotImplementedError', 'OSError', 'OverflowError', 'ReferenceError', 'RuntimeError',
  81. 'StopIteration', 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError',
  82. 'UnboundlocalError', 'UnicodeError', 'UnicodeEncodeError', 'UnicodeDecodeError',
  83. 'UnicodeTranslateError', 'ValueError', 'WindowsError', 'ZeroDivisionError', 'Warning',
  84. 'UserWarning', 'DeprecationWarning', 'PendingDeprecationWarning', 'SyntaxWarning',
  85. 'RuntimeWarning', 'FutureWarning',
  86. // self: this is a common python convention (but not a reserved word)
  87. 'self'
  88. ),
  89. /*
  90. ** Set 3: standard library
  91. ** http://python.org/doc/current/lib/modindex.html
  92. */
  93. 3 => array(
  94. '__builtin__', '__future__', '__main__', '_winreg', 'aifc', 'AL', 'al', 'anydbm',
  95. 'array', 'asynchat', 'asyncore', 'atexit', 'audioop', 'base64', 'BaseHTTPServer',
  96. 'Bastion', 'binascii', 'binhex', 'bisect', 'bsddb', 'bz2', 'calendar', 'cd', 'cgi',
  97. 'CGIHTTPServer', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop',
  98. 'collections', 'colorsys', 'commands', 'compileall', 'compiler',
  99. 'ConfigParser', 'Cookie', 'cookielib', 'copy', 'copy_reg', 'cPickle', 'crypt',
  100. 'cStringIO', 'csv', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'DEVICE',
  101. 'difflib', 'dircache', 'dis', 'distutils', 'dl', 'doctest', 'DocXMLRPCServer', 'dumbdbm',
  102. 'dummy_thread', 'dummy_threading', 'email', 'encodings', 'errno', 'exceptions', 'fcntl',
  103. 'filecmp', 'fileinput', 'FL', 'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl',
  104. 'fpformat', 'ftplib', 'gc', 'gdbm', 'getopt', 'getpass', 'gettext', 'GL', 'gl', 'glob',
  105. 'gopherlib', 'grp', 'gzip', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib',
  106. 'HTMLParser', 'httplib', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp', 'inspect',
  107. 'itertools', 'jpeg', 'keyword', 'linecache', 'locale', 'logging', 'mailbox', 'mailcap',
  108. 'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'MimeWriter', 'mimify',
  109. 'mmap', 'msvcrt', 'multifile', 'mutex', 'netrc', 'new', 'nis', 'nntplib', 'operator',
  110. 'optparse', 'os', 'ossaudiodev', 'parser', 'pdb', 'pickle', 'pickletools', 'pipes',
  111. 'pkgutil', 'platform', 'popen2', 'poplib', 'posix', 'posixfile', 'pprint', 'profile',
  112. 'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'Queue', 'quopri', 'random',
  113. 're', 'readline', 'repr', 'resource', 'rexec', 'rfc822', 'rgbimg', 'rlcompleter',
  114. 'robotparser', 'sched', 'ScrolledText', 'select', 'sets', 'sgmllib', 'sha', 'shelve',
  115. 'shlex', 'shutil', 'signal', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'site', 'smtpd',
  116. 'smtplib', 'sndhdr', 'socket', 'SocketServer', 'stat', 'statcache', 'statvfs', 'string',
  117. 'StringIO', 'stringprep', 'struct', 'subprocess', 'sunau', 'SUNAUDIODEV', 'sunaudiodev',
  118. 'symbol', 'sys', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios',
  119. 'test', 'textwrap', 'thread', 'threading', 'time', 'timeit', 'Tix', 'Tkinter', 'token',
  120. 'tokenize', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib2',
  121. 'urllib', 'urlparse', 'user', 'UserDict', 'UserList', 'UserString', 'uu', 'warnings',
  122. 'wave', 'weakref', 'webbrowser', 'whichdb', 'whrandom', 'winsound', 'xdrlib', 'xml',
  123. 'xmllib', 'xmlrpclib', 'zipfile', 'zipimport', 'zlib'
  124. ),
  125. /*
  126. ** Set 4: special methods
  127. ** http://python.org/doc/current/ref/specialnames.html
  128. */
  129. 4 => array(
  130. /*
  131. // Iterator types: http://python.org/doc/current/lib/typeiter.html
  132. '__iter__', 'next',
  133. // String types: http://python.org/doc/current/lib/string-methods.html
  134. 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs',
  135. 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle',
  136. 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust',
  137. 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title',
  138. 'translate', 'upper', 'zfill',
  139. */
  140. // Basic customization: http://python.org/doc/current/ref/customization.html
  141. '__new__', '__init__', '__del__', '__repr__', '__str__',
  142. '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__cmp__', '__rcmp__',
  143. '__hash__', '__nonzero__', '__unicode__', '__dict__',
  144. // Attribute access: http://python.org/doc/current/ref/attribute-access.html
  145. '__setattr__', '__delattr__', '__getattr__', '__getattribute__', '__get__', '__set__',
  146. '__delete__', '__slots__',
  147. // Class creation, callable objects
  148. '__metaclass__', '__call__',
  149. // Container types: http://python.org/doc/current/ref/sequence-types.html
  150. '__len__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__contains__',
  151. '__getslice__', '__setslice__', '__delslice__',
  152. // Numeric types: http://python.org/doc/current/ref/numeric-types.html
  153. '__abs__','__add__','__and__','__coerce__','__div__','__divmod__','__float__',
  154. '__hex__','__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__',
  155. '__ior__','__ixor__', '__ilshift__','__irshift__','__invert__','__int__',
  156. '__long__','__lshift__',
  157. '__mod__','__mul__','__neg__','__oct__','__or__','__pos__','__pow__',
  158. '__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__',
  159. '__rshift__','__rsub__','__rmul__','__rand__','__rxor__','__ror__',
  160. '__sub__','__xor__'
  161. )
  162. ),
  163. 'SYMBOLS' => array(
  164. '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?', '`'
  165. ),
  166. 'CASE_SENSITIVE' => array(
  167. GESHI_COMMENTS => false,
  168. 1 => true,
  169. 2 => true,
  170. 3 => true,
  171. 4 => true
  172. ),
  173. 'STYLES' => array(
  174. 'KEYWORDS' => array(
  175. 1 => 'color: #ff7700;font-weight:bold;', // Reserved
  176. 2 => 'color: #008000;', // Built-ins + self
  177. 3 => 'color: #dc143c;', // Standard lib
  178. 4 => 'color: #0000cd;' // Special methods
  179. ),
  180. 'COMMENTS' => array(
  181. 1 => 'color: #808080; font-style: italic;',
  182. 'MULTI' => 'color: #808080; font-style: italic;'
  183. ),
  184. 'ESCAPE_CHAR' => array(
  185. 0 => 'color: #000099; font-weight: bold;'
  186. ),
  187. 'BRACKETS' => array(
  188. 0 => 'color: black;'
  189. ),
  190. 'STRINGS' => array(
  191. 0 => 'color: #483d8b;'
  192. ),
  193. 'NUMBERS' => array(
  194. 0 => 'color: #ff4500;'
  195. ),
  196. 'METHODS' => array(
  197. 1 => 'color: black;'
  198. ),
  199. 'SYMBOLS' => array(
  200. 0 => 'color: #66cc66;'
  201. ),
  202. 'REGEXPS' => array(
  203. ),
  204. 'SCRIPT' => array(
  205. )
  206. ),
  207. 'URLS' => array(
  208. 1 => '',
  209. 2 => '',
  210. 3 => '',
  211. 4 => ''
  212. ),
  213. 'OOLANG' => true,
  214. 'OBJECT_SPLITTERS' => array(
  215. 1 => '.'
  216. ),
  217. 'REGEXPS' => array(
  218. ),
  219. 'STRICT_MODE_APPLIES' => GESHI_NEVER,
  220. 'SCRIPT_DELIMITERS' => array(
  221. ),
  222. 'HIGHLIGHT_STRICT_BLOCK' => array(
  223. )
  224. );
  225. ?>