xref: /freebsd/contrib/file/magic/Magdir/python (revision b6cee71de37d56e36dbc118e2d9b03e7cece5709)
1*b6cee71dSXin LI
2*b6cee71dSXin LI#------------------------------------------------------------------------------
3*b6cee71dSXin LI# $File: python,v 1.25 2014/05/06 16:08:32 christos Exp $
4*b6cee71dSXin LI# python:  file(1) magic for python
5*b6cee71dSXin LI#
6*b6cee71dSXin LI# Outlook puts """ too for urgent messages
7*b6cee71dSXin LI# From: David Necas <yeti@physics.muni.cz>
8*b6cee71dSXin LI# often the module starts with a multiline string
9*b6cee71dSXin LI0	string/t	"""	Python script text executable
10*b6cee71dSXin LI# MAGIC as specified in Python/import.c (1.5 to 2.7a0 and 3.1a0, assuming
11*b6cee71dSXin LI# that Py_UnicodeFlag is off for Python 2)
12*b6cee71dSXin LI# 20121  ( YEAR - 1995 ) + MONTH  + DAY (little endian followed by "\r\n"
13*b6cee71dSXin LI0	belong		0x994e0d0a	python 1.5/1.6 byte-compiled
14*b6cee71dSXin LI0	belong		0x87c60d0a	python 2.0 byte-compiled
15*b6cee71dSXin LI0	belong		0x2aeb0d0a	python 2.1 byte-compiled
16*b6cee71dSXin LI0	belong		0x2ded0d0a	python 2.2 byte-compiled
17*b6cee71dSXin LI0	belong		0x3bf20d0a	python 2.3 byte-compiled
18*b6cee71dSXin LI0	belong		0x6df20d0a	python 2.4 byte-compiled
19*b6cee71dSXin LI0	belong		0xb3f20d0a	python 2.5 byte-compiled
20*b6cee71dSXin LI0	belong		0xd1f20d0a	python 2.6 byte-compiled
21*b6cee71dSXin LI0	belong		0x03f30d0a	python 2.7 byte-compiled
22*b6cee71dSXin LI0	belong		0x3b0c0d0a	python 3.0 byte-compiled
23*b6cee71dSXin LI0	belong		0x4f0c0d0a	python 3.1 byte-compiled
24*b6cee71dSXin LI0	belong		0x6c0c0d0a	python 3.2 byte-compiled
25*b6cee71dSXin LI0	belong		0x9e0c0d0a	python 3.3 byte-compiled
26*b6cee71dSXin LI
27*b6cee71dSXin LI0	search/1/w	#!\ /usr/bin/python	Python script text executable
28*b6cee71dSXin LI!:mime text/x-python
29*b6cee71dSXin LI0	search/1/w	#!\ /usr/local/bin/python	Python script text executable
30*b6cee71dSXin LI!:mime text/x-python
31*b6cee71dSXin LI0	search/1	#!/usr/bin/env\ python	Python script text executable
32*b6cee71dSXin LI!:mime text/x-python
33*b6cee71dSXin LI0	search/1	#!\ /usr/bin/env\ python	Python script text executable
34*b6cee71dSXin LI!:mime text/x-python
35*b6cee71dSXin LI
36*b6cee71dSXin LI
37*b6cee71dSXin LI# from module.submodule import func1, func2
38*b6cee71dSXin LI0	regex	\^from\\s+(\\w|\\.)+\\s+import.*$	Python script text executable
39*b6cee71dSXin LI!:mime text/x-python
40*b6cee71dSXin LI
41*b6cee71dSXin LI# def __init__ (self, ...):
42*b6cee71dSXin LI0	search/4096	def\ __init__
43*b6cee71dSXin LI>&0	search/64 self	Python script text executable
44*b6cee71dSXin LI!:mime text/x-python
45*b6cee71dSXin LI
46*b6cee71dSXin LI# comments
47*b6cee71dSXin LI#0	search/4096	'''
48*b6cee71dSXin LI#>&0	regex	.*'''$	Python script text executable
49*b6cee71dSXin LI#!:mime text/x-python
50*b6cee71dSXin LI
51*b6cee71dSXin LI#0	search/4096	"""
52*b6cee71dSXin LI#>&0	regex	.*"""$	Python script text executable
53*b6cee71dSXin LI#!:mime text/x-python
54*b6cee71dSXin LI
55*b6cee71dSXin LI# try:
56*b6cee71dSXin LI# except: or finally:
57*b6cee71dSXin LI# block
58*b6cee71dSXin LI0	search/4096	try:
59*b6cee71dSXin LI>&0	regex	\^\\s*except.*:	Python script text executable
60*b6cee71dSXin LI!:mime text/x-python
61*b6cee71dSXin LI>&0	search/4096	finally:	Python script text executable
62*b6cee71dSXin LI!:mime text/x-python
63*b6cee71dSXin LI
64*b6cee71dSXin LI# def name(args, args):
65*b6cee71dSXin LI0	regex	 \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
66*b6cee71dSXin LI>&0	regex	\ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable
67*b6cee71dSXin LI!:mime text/x-python
68