PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/_piecrust/libs/Geshi/geshi/python.php

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