xref: /freebsd/contrib/file/magic/Magdir/python (revision 40427cca7a9ae77b095936fb1954417c290cfb17)
1b6cee71dSXin LI
2b6cee71dSXin LI#------------------------------------------------------------------------------
3*40427ccaSGordon Tetlow# $File: python,v 1.34 2017/08/14 07:40:38 christos Exp $
4b6cee71dSXin LI# python:  file(1) magic for python
5b6cee71dSXin LI#
6b6cee71dSXin LI# Outlook puts """ too for urgent messages
7b6cee71dSXin LI# From: David Necas <yeti@physics.muni.cz>
8b6cee71dSXin LI# often the module starts with a multiline string
9b6cee71dSXin LI0	string/t	"""	Python script text executable
10b6cee71dSXin LI# MAGIC as specified in Python/import.c (1.5 to 2.7a0 and 3.1a0, assuming
11b6cee71dSXin LI# that Py_UnicodeFlag is off for Python 2)
12a5d223e6SXin LI# two bytes of magic followed by "\r\n" in little endian order
13b6cee71dSXin LI0	belong		0x994e0d0a	python 1.5/1.6 byte-compiled
14b6cee71dSXin LI0	belong		0x87c60d0a	python 2.0 byte-compiled
15b6cee71dSXin LI0	belong		0x2aeb0d0a	python 2.1 byte-compiled
16b6cee71dSXin LI0	belong		0x2ded0d0a	python 2.2 byte-compiled
17b6cee71dSXin LI0	belong		0x3bf20d0a	python 2.3 byte-compiled
18b6cee71dSXin LI0	belong		0x6df20d0a	python 2.4 byte-compiled
19b6cee71dSXin LI0	belong		0xb3f20d0a	python 2.5 byte-compiled
20b6cee71dSXin LI0	belong		0xd1f20d0a	python 2.6 byte-compiled
21b6cee71dSXin LI0	belong		0x03f30d0a	python 2.7 byte-compiled
22b6cee71dSXin LI0	belong		0x3b0c0d0a	python 3.0 byte-compiled
23b6cee71dSXin LI0	belong		0x4f0c0d0a	python 3.1 byte-compiled
24b6cee71dSXin LI0	belong		0x6c0c0d0a	python 3.2 byte-compiled
25b6cee71dSXin LI0	belong		0x9e0c0d0a	python 3.3 byte-compiled
26c2931133SXin LI0	belong		0xee0c0d0a	python 3.4 byte-compiled
27*40427ccaSGordon Tetlow0	belong		0x160d0d0a	python 3.5.1- byte-compiled
28*40427ccaSGordon Tetlow0	belong		0x170d0d0a	python 3.5.2+ byte-compiled
29*40427ccaSGordon Tetlow0	belong		0x330d0d0a	python 3.6 byte-compiled
30*40427ccaSGordon Tetlow0	belong		0x3e0d0d0a	python 3.7 byte-compiled
31*40427ccaSGordon Tetlow
32b6cee71dSXin LI
33b6cee71dSXin LI0	search/1/w	#!\ /usr/bin/python	Python script text executable
343e41d09dSXin LI!:strength + 15
35b6cee71dSXin LI!:mime text/x-python
36b6cee71dSXin LI0	search/1/w	#!\ /usr/local/bin/python	Python script text executable
373e41d09dSXin LI!:strength + 15
38b6cee71dSXin LI!:mime text/x-python
39b6cee71dSXin LI0	search/1	#!/usr/bin/env\ python	Python script text executable
403e41d09dSXin LI!:strength + 15
41b6cee71dSXin LI!:mime text/x-python
429ce06829SXin LI0	search/10	#!\ /usr/bin/env\ python	Python script text executable
433e41d09dSXin LI!:strength + 15
44b6cee71dSXin LI!:mime text/x-python
45b6cee71dSXin LI
46b6cee71dSXin LI
47b6cee71dSXin LI# from module.submodule import func1, func2
48*40427ccaSGordon Tetlow0	regex		\^from[\040\t\f\r\n]+([A-Za-z0-9_]|\\.)+[\040\t\f\r\n]+import.*$	Python script text executable
49*40427ccaSGordon Tetlow!:strength + 15
50b6cee71dSXin LI!:mime text/x-python
51b6cee71dSXin LI
52b6cee71dSXin LI# def __init__ (self, ...):
53b6cee71dSXin LI0	search/4096	def\ __init__
54b6cee71dSXin LI>&0	search/64 self	Python script text executable
55*40427ccaSGordon Tetlow!:strength + 15
56*40427ccaSGordon Tetlow!:mime text/x-python
57*40427ccaSGordon Tetlow
58*40427ccaSGordon Tetlow# if __name__ == "__main__":
59*40427ccaSGordon Tetlow0 search/4096 if\ __name__
60*40427ccaSGordon Tetlow>&0 search/64 '__main__'	Python script text executable
61*40427ccaSGordon Tetlow>&0 search/64 "__main__"	Python script text executable
62*40427ccaSGordon Tetlow!:strength + 15
63*40427ccaSGordon Tetlow!:mime text/x-python
64*40427ccaSGordon Tetlow
65*40427ccaSGordon Tetlow# import module [as abrev]
66*40427ccaSGordon Tetlow0	regex	\^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
67b6cee71dSXin LI!:mime text/x-python
68b6cee71dSXin LI
69b6cee71dSXin LI# comments
70b6cee71dSXin LI#0	search/4096	'''
71b6cee71dSXin LI#>&0	regex	.*'''$	Python script text executable
72b6cee71dSXin LI#!:mime text/x-python
73b6cee71dSXin LI
74b6cee71dSXin LI#0	search/4096	"""
75b6cee71dSXin LI#>&0	regex	.*"""$	Python script text executable
76b6cee71dSXin LI#!:mime text/x-python
77b6cee71dSXin LI
78b6cee71dSXin LI# try:
79b6cee71dSXin LI# except: or finally:
80b6cee71dSXin LI# block
81b6cee71dSXin LI0	search/4096	try:
82*40427ccaSGordon Tetlow>&0	regex	\^[[:space:]]*except.*:$	Python script text executable
83*40427ccaSGordon Tetlow!:strength + 15
84b6cee71dSXin LI!:mime text/x-python
85b6cee71dSXin LI>&0	search/4096	finally:	Python script text executable
86b6cee71dSXin LI!:mime text/x-python
87b6cee71dSXin LI
88*40427ccaSGordon Tetlow# class name[(base classes,)]: [pass]
89*40427ccaSGordon Tetlow0	regex	\^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$		Python script text executable
90*40427ccaSGordon Tetlow!:strength + 15
91*40427ccaSGordon Tetlow!:mime text/x-python
92*40427ccaSGordon Tetlow
93*40427ccaSGordon Tetlow# def name(*args, **kwargs):
94*40427ccaSGordon Tetlow0	regex	 \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
95*40427ccaSGordon Tetlow>&0	regex	 \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable
96*40427ccaSGordon Tetlow!:strength + 15
97b6cee71dSXin LI!:mime text/x-python
98