A tumblelog CMS built on AJAX, PHP and MySQL.

python.php 9.8KB

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