openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

python.php (10079B)


      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.20
      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 
     44 $language_data = array (
     45 	'LANG_NAME' => 'Python',
     46 	'COMMENT_SINGLE' => array(1 => '#'),
     47 	'COMMENT_MULTI' => array(),
     48 	'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
     49 	'QUOTEMARKS' => array('"', "'", '"""'),
     50 	'ESCAPE_CHAR' => '\\',
     51 	'KEYWORDS' => array(
     52 
     53 		/*
     54 		** Set 1: reserved words
     55 		** http://python.org/doc/current/ref/keywords.html
     56 		*/
     57 		1 => array(
     58 			'and', 'del', 'for', 'is', 'raise', 'assert', 'elif', 'from', 'lambda', 'return', 'break',
     59 			'else', 'global', 'not', 'try', 'class', 'except', 'if', 'or', 'while', 'continue', 'exec',
     60 			'import', 'pass', 'yield', 'def', 'finally', 'in', 'print'
     61 			),
     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', 'repr', '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 			),
     91 
     92 		/*
     93 		** Set 3: standard library
     94 		** http://python.org/doc/current/lib/modindex.html
     95 		*/
     96 		3 => array(
     97 			'__builtin__', '__future__', '__main__', '_winreg', 'aifc', 'AL', 'al', 'anydbm',
     98 			'array', 'asynchat', 'asyncore', 'atexit', 'audioop', 'base64', 'BaseHTTPServer',
     99 			'Bastion', 'binascii', 'binhex', 'bisect', 'bsddb', 'bz2', 'calendar', 'cd', 'cgi',
    100 			'CGIHTTPServer', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop',
    101 			'collections', 'colorsys', 'commands', 'compileall', 'compiler', 'compiler',
    102 			'ConfigParser', 'Cookie', 'cookielib', 'copy', 'copy_reg', 'cPickle', 'crypt',
    103 			'cStringIO', 'csv', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'DEVICE',
    104 			'difflib', 'dircache', 'dis', 'distutils', 'dl', 'doctest', 'DocXMLRPCServer', 'dumbdbm',
    105 			'dummy_thread', 'dummy_threading', 'email', 'encodings', 'errno', 'exceptions', 'fcntl',
    106 			'filecmp', 'fileinput', 'FL', 'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl',
    107 			'fpformat', 'ftplib', 'gc', 'gdbm', 'getopt', 'getpass', 'gettext', 'GL', 'gl', 'glob',
    108 			'gopherlib', 'grp', 'gzip', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib',
    109 			'HTMLParser', 'httplib', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp', 'inspect',
    110 			'itertools', 'jpeg', 'keyword', 'linecache', 'locale', 'logging', 'mailbox', 'mailcap',
    111 			'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'MimeWriter', 'mimify',
    112 			'mmap', 'msvcrt', 'multifile', 'mutex', 'netrc', 'new', 'nis', 'nntplib', 'operator',
    113 			'optparse', 'os', 'ossaudiodev', 'parser', 'pdb', 'pickle', 'pickletools', 'pipes',
    114 			'pkgutil', 'platform', 'popen2', 'poplib', 'posix', 'posixfile', 'pprint', 'profile',
    115 			'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'Queue', 'quopri', 'random',
    116 			're', 'readline', 'repr', 'resource', 'rexec', 'rfc822', 'rgbimg', 'rlcompleter',
    117 			'robotparser', 'sched', 'ScrolledText', 'select', 'sets', 'sgmllib', 'sha', 'shelve',
    118 			'shlex', 'shutil', 'signal', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'site', 'smtpd',
    119 			'smtplib', 'sndhdr', 'socket', 'SocketServer', 'stat', 'statcache', 'statvfs', 'string',
    120 			'StringIO', 'stringprep', 'struct', 'subprocess', 'sunau', 'SUNAUDIODEV', 'sunaudiodev',
    121 			'symbol', 'sys', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios',
    122 			'test', 'textwrap', 'thread', 'threading', 'time', 'timeit', 'Tix', 'Tkinter', 'token',
    123 			'tokenize', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib2',
    124 			'urllib', 'urlparse', 'user', 'UserDict', 'UserList', 'UserString', 'uu', 'warnings',
    125 			'wave', 'weakref', 'webbrowser', 'whichdb', 'whrandom', 'winsound', 'xdrlib', 'xml',
    126 			'xmllib', 'xmlrpclib', 'zipfile', 'zipimport', 'zlib'
    127 			),
    128 
    129 		/*
    130 		** Set 4: special methods
    131 		** http://python.org/doc/current/ref/specialnames.html
    132 		*/
    133 		4 => array(
    134 			/*
    135 			// Iterator types: http://python.org/doc/current/lib/typeiter.html
    136 			'__iter__', 'next',
    137 			// String types: http://python.org/doc/current/lib/string-methods.html
    138 			'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs',
    139 			'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle',
    140 			'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust',
    141 			'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title',
    142 			'translate', 'upper', 'zfill',
    143 			*/
    144 			// Basic customization: http://python.org/doc/current/ref/customization.html
    145 			'__new__', '__init__', '__del__', '__repr__', '__str__', 
    146 			'__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__cmp__', '__rcmp__',
    147 			'__hash__', '__nonzero__', '__unicode__', '__dict__',
    148 			// Attribute access: http://python.org/doc/current/ref/attribute-access.html
    149 			'__setattr__', '__delattr__', '__getattr__', '__getattribute__', '__get__', '__set__',
    150 			'__delete__', '__slots__',
    151 			// Class creation, callable objects
    152 			'__metaclass__', '__call__', 
    153 			// Container types: http://python.org/doc/current/ref/sequence-types.html
    154 			'__len__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__contains__',
    155 			'__getslice__', '__setslice__', '__delslice__',
    156 			// Numeric types: http://python.org/doc/current/ref/numeric-types.html
    157 			'__abs__','__add__','__and__','__coerce__','__div__','__divmod__','__float__',
    158 			'__hex__','__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__',
    159 			'__ior__','__ixor__', '__ilshift__','__irshift__','__invert__','__int__',
    160 			'__long__','__lshift__',
    161 			'__mod__','__mul__','__neg__','__oct__','__or__','__pos__','__pow__',
    162 			'__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__',
    163 			'__rshift__','__rsub__','__rmul__','__repr__','__rand__','__rxor__','__ror__',
    164 			'__sub__','__xor__'
    165 			)
    166 
    167 		),
    168 	'SYMBOLS' => array(
    169 			'(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?', '`'
    170 		),
    171 	'CASE_SENSITIVE' => array(
    172 		GESHI_COMMENTS => true,
    173 		1 => true,
    174         2 => true,
    175         3 => true,
    176         4 => true
    177 		),
    178 	'STYLES' => array(
    179 		'KEYWORDS' => array(
    180 			1 => 'color: #ff7700;font-weight:bold;',	// Reserved
    181 			2 => 'color: #008000;',						// Built-ins + self
    182 			3 => 'color: #dc143c;',						// Standard lib
    183 			4 => 'color: #0000cd;'						// Special methods
    184 			),
    185 		'COMMENTS' => array(
    186 			1 => 'color: #808080; font-style: italic;',
    187 			'MULTI' => 'color: #808080; font-style: italic;'
    188 			),
    189 		'ESCAPE_CHAR' => array(
    190 			0 => 'color: #000099; font-weight: bold;'
    191 			),
    192 		'BRACKETS' => array(
    193 			0 => 'color: black;'
    194 			),
    195 		'STRINGS' => array(
    196 			0 => 'color: #483d8b;'
    197 			),
    198 		'NUMBERS' => array(
    199 			0 => 'color: #ff4500;'
    200 			),
    201 		'METHODS' => array(
    202 			1 => 'color: black;'
    203 			),
    204 		'SYMBOLS' => array(
    205 			0 => 'color: #66cc66;'
    206 			),
    207 		'REGEXPS' => array(
    208 			),
    209 		'SCRIPT' => array(
    210 			)
    211 		),
    212 	'URLS' => array(
    213 		),
    214 	'OOLANG' => true,
    215 	'OBJECT_SPLITTERS' => array(
    216 		1 => '.'
    217 		),
    218 	'REGEXPS' => array(
    219 		),
    220 	'STRICT_MODE_APPLIES' => GESHI_NEVER,
    221 	'SCRIPT_DELIMITERS' => array(
    222 		),
    223 	'HIGHLIGHT_STRICT_BLOCK' => array(
    224 		)
    225 );
    226 
    227 ?>