xref: /freebsd/contrib/file/magic/Magdir/python (revision 48c779cdecb5f803e5fe5d761987e976ca9609db)
1b6cee71dSXin LI
2b6cee71dSXin LI#------------------------------------------------------------------------------
3*48c779cdSXin LI# $File: python,v 1.36 2019/04/09 18:28:25 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
2740427ccaSGordon Tetlow0	belong		0x160d0d0a	python 3.5.1- byte-compiled
2840427ccaSGordon Tetlow0	belong		0x170d0d0a	python 3.5.2+ byte-compiled
2940427ccaSGordon Tetlow0	belong		0x330d0d0a	python 3.6 byte-compiled
30*48c779cdSXin LI0	belong		0x420d0d0a	python 3.7 byte-compiled
3140427ccaSGordon 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*48c779cdSXin LI0	search/8192	import
49*48c779cdSXin LI>0	regex		\^from[\040\t\f\r\n]+([A-Za-z0-9_]|\\.)+[\040\t\f\r\n]+import.*$	Python script text executable
5040427ccaSGordon Tetlow!:strength + 15
51b6cee71dSXin LI!:mime text/x-python
52b6cee71dSXin LI
53b6cee71dSXin LI# def __init__ (self, ...):
54b6cee71dSXin LI0	search/4096	def\ __init__
55b6cee71dSXin LI>&0	search/64 self	Python script text executable
5640427ccaSGordon Tetlow!:strength + 15
5740427ccaSGordon Tetlow!:mime text/x-python
5840427ccaSGordon Tetlow
5940427ccaSGordon Tetlow# if __name__ == "__main__":
6040427ccaSGordon Tetlow0 search/4096 if\ __name__
6140427ccaSGordon Tetlow>&0 search/64 '__main__'	Python script text executable
6240427ccaSGordon Tetlow>&0 search/64 "__main__"	Python script text executable
6340427ccaSGordon Tetlow!:strength + 15
6440427ccaSGordon Tetlow!:mime text/x-python
6540427ccaSGordon Tetlow
6640427ccaSGordon Tetlow# import module [as abrev]
67*48c779cdSXin LI0	search/8192	import
68*48c779cdSXin LI>0	regex	\^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
69b6cee71dSXin LI!:mime text/x-python
70b6cee71dSXin LI
71b6cee71dSXin LI# comments
72b6cee71dSXin LI#0	search/4096	'''
73b6cee71dSXin LI#>&0	regex	.*'''$	Python script text executable
74b6cee71dSXin LI#!:mime text/x-python
75b6cee71dSXin LI
76b6cee71dSXin LI#0	search/4096	"""
77b6cee71dSXin LI#>&0	regex	.*"""$	Python script text executable
78b6cee71dSXin LI#!:mime text/x-python
79b6cee71dSXin LI
80b6cee71dSXin LI# try:
81b6cee71dSXin LI# except: or finally:
82b6cee71dSXin LI# block
83b6cee71dSXin LI0	search/4096	try:
8440427ccaSGordon Tetlow>&0	regex	\^[[:space:]]*except.*:$	Python script text executable
8540427ccaSGordon Tetlow!:strength + 15
86b6cee71dSXin LI!:mime text/x-python
87b6cee71dSXin LI>&0	search/4096	finally:	Python script text executable
88b6cee71dSXin LI!:mime text/x-python
89b6cee71dSXin LI
9040427ccaSGordon Tetlow# class name[(base classes,)]: [pass]
91*48c779cdSXin LI0	search/8192	class
92*48c779cdSXin LI>0	regex	\^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$		Python script text executable
9340427ccaSGordon Tetlow!:strength + 15
9440427ccaSGordon Tetlow!:mime text/x-python
9540427ccaSGordon Tetlow
9640427ccaSGordon Tetlow# def name(*args, **kwargs):
97*48c779cdSXin LI0	search/8192	def\
98*48c779cdSXin LI>0	regex	 \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
99*48c779cdSXin LI>>&0	regex	 \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable
10040427ccaSGordon Tetlow!:strength + 15
101b6cee71dSXin LI!:mime text/x-python
102