1110949Sobrien
2110949Sobrien#------------------------------------------------------------------------------
3234449Sobrien# $File: python,v 1.20 2011/12/13 13:53:14 christos Exp $
4110949Sobrien# python:  file(1) magic for python
5110949Sobrien#
6234449Sobrien# Outlook puts """ too for urgent messages
7110949Sobrien# From: David Necas <yeti@physics.muni.cz>
868349Sobrien# often the module starts with a multiline string
9234449Sobrien0	string/t	"""	Python script text executable
10234449Sobrien# MAGIC as specified in Python/import.c (1.5 to 2.7a0 and 3.1a0, assuming
11234449Sobrien# that Py_UnicodeFlag is off for Python 2)
1268349Sobrien# 20121  ( YEAR - 1995 ) + MONTH  + DAY (little endian followed by "\r\n"
13110949Sobrien0	belong		0x994e0d0a	python 1.5/1.6 byte-compiled
14110949Sobrien0	belong		0x87c60d0a	python 2.0 byte-compiled
15110949Sobrien0	belong		0x2aeb0d0a	python 2.1 byte-compiled
16110949Sobrien0	belong		0x2ded0d0a	python 2.2 byte-compiled
17133359Sobrien0	belong		0x3bf20d0a	python 2.3 byte-compiled
18159764Sobrien0	belong		0x6df20d0a	python 2.4 byte-compiled
19169942Sobrien0	belong		0xb3f20d0a	python 2.5 byte-compiled
20192350Sdelphij0	belong		0xd1f20d0a	python 2.6 byte-compiled
21234449Sobrien0	belong		0x03f30d0a	python 2.7 byte-compiled
22234449Sobrien0	belong		0x3b0c0d0a	python 3.0 byte-compiled
23234449Sobrien0	belong		0x4f0c0d0a	python 3.1 byte-compiled
24234449Sobrien0	belong		0x6c0c0d0a	python 3.2 byte-compiled
25159764Sobrien
26234449Sobrien0	search/1/w	#!\ /usr/bin/python	Python script text executable
27234449Sobrien!:mime text/x-python
28234449Sobrien0	search/1/w	#!\ /usr/local/bin/python	Python script text executable
29234449Sobrien!:mime text/x-python
30234449Sobrien0	search/1	#!/usr/bin/env\ python	Python script text executable
31234449Sobrien!:mime text/x-python
32234449Sobrien0	search/1	#!\ /usr/bin/env\ python	Python script text executable
33234449Sobrien!:mime text/x-python
34192350Sdelphij
35159764Sobrien
36234449Sobrien# from module.submodule import func1, func2
37234449Sobrien0	regex	\^from\\s+(\\w|\\.)+\\s+import.*$	Python script text executable
38234449Sobrien!:mime text/x-python
39234449Sobrien
40234449Sobrien# def __init__ (self, ...):
41234449Sobrien0	search/4096	def\ __init__
42234449Sobrien>&0	search/64 self	Python script text executable
43234449Sobrien!:mime text/x-python
44234449Sobrien
45234449Sobrien# comments
46234449Sobrien0	search/4096	'''
47234449Sobrien>&0	regex	.*'''$	Python script text executable
48234449Sobrien!:mime text/x-python
49234449Sobrien
50234449Sobrien0	search/4096	"""
51234449Sobrien>&0	regex	.*"""$	Python script text executable
52234449Sobrien!:mime text/x-python
53234449Sobrien
54234449Sobrien# try:
55234449Sobrien# except: or finally:
56234449Sobrien# block
57234449Sobrien0	search/4096	try:
58234449Sobrien>&0	regex	\^\\s*except.*:	Python script text executable
59234449Sobrien!:mime text/x-python
60234449Sobrien>&0	search/4096	finally:	Python script text executable
61234449Sobrien!:mime text/x-python
62