python revision 309848
191094Sdes
291094Sdes#------------------------------------------------------------------------------
391094Sdes# $File: python,v 1.29 2016/07/27 09:42:16 rrt Exp $
491094Sdes# python:  file(1) magic for python
591094Sdes#
691094Sdes# Outlook puts """ too for urgent messages
791094Sdes# From: David Necas <yeti@physics.muni.cz>
891094Sdes# often the module starts with a multiline string
991094Sdes0	string/t	"""	Python script text executable
1091094Sdes# MAGIC as specified in Python/import.c (1.5 to 2.7a0 and 3.1a0, assuming
1191094Sdes# that Py_UnicodeFlag is off for Python 2)
1291094Sdes# two bytes of magic followed by "\r\n" in little endian order
1391094Sdes0	belong		0x994e0d0a	python 1.5/1.6 byte-compiled
1491094Sdes0	belong		0x87c60d0a	python 2.0 byte-compiled
1591094Sdes0	belong		0x2aeb0d0a	python 2.1 byte-compiled
1691094Sdes0	belong		0x2ded0d0a	python 2.2 byte-compiled
1791094Sdes0	belong		0x3bf20d0a	python 2.3 byte-compiled
1891094Sdes0	belong		0x6df20d0a	python 2.4 byte-compiled
1991094Sdes0	belong		0xb3f20d0a	python 2.5 byte-compiled
2091094Sdes0	belong		0xd1f20d0a	python 2.6 byte-compiled
2191094Sdes0	belong		0x03f30d0a	python 2.7 byte-compiled
2291094Sdes0	belong		0x3b0c0d0a	python 3.0 byte-compiled
2391094Sdes0	belong		0x4f0c0d0a	python 3.1 byte-compiled
2491094Sdes0	belong		0x6c0c0d0a	python 3.2 byte-compiled
2591094Sdes0	belong		0x9e0c0d0a	python 3.3 byte-compiled
2691094Sdes0	belong		0xee0c0d0a	python 3.4 byte-compiled
2791094Sdes0	belong		0x160d0d0a	python 3.5 byte-compiled
2891094Sdes
2991094Sdes0	search/1/w	#!\ /usr/bin/python	Python script text executable
3091094Sdes!:strength + 15
3191094Sdes!:mime text/x-python
3291094Sdes0	search/1/w	#!\ /usr/local/bin/python	Python script text executable
3391094Sdes!:strength + 15
3491094Sdes!:mime text/x-python
3591094Sdes0	search/1	#!/usr/bin/env\ python	Python script text executable
3691094Sdes!:strength + 15
3791094Sdes!:mime text/x-python
3891094Sdes0	search/10	#!\ /usr/bin/env\ python	Python script text executable
3991094Sdes!:strength + 15
4091094Sdes!:mime text/x-python
4191094Sdes
4291094Sdes
4391094Sdes# from module.submodule import func1, func2
4491094Sdes0	regex	\^from\\s+(\\w|\\.)+\\s+import.*$	Python script text executable
4591094Sdes!:mime text/x-python
4691094Sdes
4791094Sdes# def __init__ (self, ...):
4891094Sdes0	search/4096	def\ __init__
4991094Sdes>&0	search/64 self	Python script text executable
5091094Sdes!:mime text/x-python
5191094Sdes
5291094Sdes# comments
5391094Sdes#0	search/4096	'''
5491094Sdes#>&0	regex	.*'''$	Python script text executable
5591094Sdes#!:mime text/x-python
5691094Sdes
5791094Sdes#0	search/4096	"""
5891094Sdes#>&0	regex	.*"""$	Python script text executable
5991094Sdes#!:mime text/x-python
6091094Sdes
6191094Sdes# try:
6291094Sdes# except: or finally:
6391094Sdes# block
6491094Sdes0	search/4096	try:
6591094Sdes>&0	regex	\^\\s*except.*:	Python script text executable
6691094Sdes!:mime text/x-python
6791094Sdes>&0	search/4096	finally:	Python script text executable
6891094Sdes!:mime text/x-python
6991094Sdes
7091094Sdes# def name(args, args):
7191094Sdes0	regex	 \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
7291094Sdes>&0	regex	\ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable
7391094Sdes!:mime text/x-python
7491094Sdes