1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*d38c30c0SXin LI# $File: python,v 1.37 2019/10/21 19:40:58 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 10*d38c30c0SXin LI# MAGIC as specified in Python/import.c (1.0 to 3.7) 11a5d223e6SXin LI# two bytes of magic followed by "\r\n" in little endian order 12*d38c30c0SXin LI0 belong 0x02099900 python 1.0 byte-compiled 13*d38c30c0SXin LI0 belong 0x03099900 python 1.1/1.2 byte-compiled 14*d38c30c0SXin LI0 belong 0x892e0d0a python 1.3 byte-compiled 15*d38c30c0SXin LI0 belong 0x04170d0a python 1.4 byte-compiled 16*d38c30c0SXin LI0 belong 0x994e0d0a python 1.5 byte-compiled 17*d38c30c0SXin LI0 belong 0xfcc40d0a python 1.6 byte-compiled 18*d38c30c0SXin LI0 belong 0xfdc40d0a python 1.6 byte-compiled 19b6cee71dSXin LI0 belong 0x87c60d0a python 2.0 byte-compiled 20*d38c30c0SXin LI0 belong 0x88c60d0a python 2.0 byte-compiled 21b6cee71dSXin LI0 belong 0x2aeb0d0a python 2.1 byte-compiled 22*d38c30c0SXin LI0 belong 0x2beb0d0a python 2.1 byte-compiled 23b6cee71dSXin LI0 belong 0x2ded0d0a python 2.2 byte-compiled 24*d38c30c0SXin LI0 belong 0x2eed0d0a python 2.2 byte-compiled 25b6cee71dSXin LI0 belong 0x3bf20d0a python 2.3 byte-compiled 26*d38c30c0SXin LI0 belong 0x3cf20d0a python 2.3 byte-compiled 27b6cee71dSXin LI0 belong 0x6df20d0a python 2.4 byte-compiled 28*d38c30c0SXin LI0 belong 0x6ef20d0a python 2.4 byte-compiled 29b6cee71dSXin LI0 belong 0xb3f20d0a python 2.5 byte-compiled 30*d38c30c0SXin LI0 belong 0xb4f20d0a python 2.5 byte-compiled 31b6cee71dSXin LI0 belong 0xd1f20d0a python 2.6 byte-compiled 32*d38c30c0SXin LI0 belong 0xd2f20d0a python 2.6 byte-compiled 33b6cee71dSXin LI0 belong 0x03f30d0a python 2.7 byte-compiled 34*d38c30c0SXin LI0 belong 0x04f30d0a python 2.7 byte-compiled 35b6cee71dSXin LI0 belong 0x3b0c0d0a python 3.0 byte-compiled 36b6cee71dSXin LI0 belong 0x4f0c0d0a python 3.1 byte-compiled 37b6cee71dSXin LI0 belong 0x6c0c0d0a python 3.2 byte-compiled 38b6cee71dSXin LI0 belong 0x9e0c0d0a python 3.3 byte-compiled 39c2931133SXin LI0 belong 0xee0c0d0a python 3.4 byte-compiled 40*d38c30c0SXin LI0 belong 0x160d0d0a python 3.5.2- byte-compiled 41*d38c30c0SXin LI0 belong 0x170d0d0a python 3.5.3+ byte-compiled 4240427ccaSGordon Tetlow0 belong 0x330d0d0a python 3.6 byte-compiled 4348c779cdSXin LI0 belong 0x420d0d0a python 3.7 byte-compiled 4440427ccaSGordon Tetlow 45b6cee71dSXin LI 46b6cee71dSXin LI0 search/1/w #!\ /usr/bin/python Python script text executable 473e41d09dSXin LI!:strength + 15 48b6cee71dSXin LI!:mime text/x-python 49b6cee71dSXin LI0 search/1/w #!\ /usr/local/bin/python Python script text executable 503e41d09dSXin LI!:strength + 15 51b6cee71dSXin LI!:mime text/x-python 52b6cee71dSXin LI0 search/1 #!/usr/bin/env\ python Python script text executable 533e41d09dSXin LI!:strength + 15 54b6cee71dSXin LI!:mime text/x-python 559ce06829SXin LI0 search/10 #!\ /usr/bin/env\ python Python script text executable 563e41d09dSXin LI!:strength + 15 57b6cee71dSXin LI!:mime text/x-python 58b6cee71dSXin LI 59b6cee71dSXin LI 60b6cee71dSXin LI# from module.submodule import func1, func2 6148c779cdSXin LI0 search/8192 import 6248c779cdSXin LI>0 regex \^from[\040\t\f\r\n]+([A-Za-z0-9_]|\\.)+[\040\t\f\r\n]+import.*$ Python script text executable 6340427ccaSGordon Tetlow!:strength + 15 64b6cee71dSXin LI!:mime text/x-python 65b6cee71dSXin LI 66b6cee71dSXin LI# def __init__ (self, ...): 67b6cee71dSXin LI0 search/4096 def\ __init__ 68b6cee71dSXin LI>&0 search/64 self Python script text executable 6940427ccaSGordon Tetlow!:strength + 15 7040427ccaSGordon Tetlow!:mime text/x-python 7140427ccaSGordon Tetlow 7240427ccaSGordon Tetlow# if __name__ == "__main__": 7340427ccaSGordon Tetlow0 search/4096 if\ __name__ 7440427ccaSGordon Tetlow>&0 search/64 '__main__' Python script text executable 7540427ccaSGordon Tetlow>&0 search/64 "__main__" Python script text executable 7640427ccaSGordon Tetlow!:strength + 15 7740427ccaSGordon Tetlow!:mime text/x-python 7840427ccaSGordon Tetlow 7940427ccaSGordon Tetlow# import module [as abrev] 8048c779cdSXin LI0 search/8192 import 8148c779cdSXin LI>0 regex \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable 82b6cee71dSXin LI!:mime text/x-python 83b6cee71dSXin LI 84b6cee71dSXin LI# comments 85b6cee71dSXin LI#0 search/4096 ''' 86b6cee71dSXin LI#>&0 regex .*'''$ Python script text executable 87b6cee71dSXin LI#!:mime text/x-python 88b6cee71dSXin LI 89b6cee71dSXin LI#0 search/4096 """ 90b6cee71dSXin LI#>&0 regex .*"""$ Python script text executable 91b6cee71dSXin LI#!:mime text/x-python 92b6cee71dSXin LI 93b6cee71dSXin LI# try: 94b6cee71dSXin LI# except: or finally: 95b6cee71dSXin LI# block 96b6cee71dSXin LI0 search/4096 try: 9740427ccaSGordon Tetlow>&0 regex \^[[:space:]]*except.*:$ Python script text executable 9840427ccaSGordon Tetlow!:strength + 15 99b6cee71dSXin LI!:mime text/x-python 100b6cee71dSXin LI>&0 search/4096 finally: Python script text executable 101b6cee71dSXin LI!:mime text/x-python 102b6cee71dSXin LI 10340427ccaSGordon Tetlow# class name[(base classes,)]: [pass] 10448c779cdSXin LI0 search/8192 class 10548c779cdSXin LI>0 regex \^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$ Python script text executable 10640427ccaSGordon Tetlow!:strength + 15 10740427ccaSGordon Tetlow!:mime text/x-python 10840427ccaSGordon Tetlow 10940427ccaSGordon Tetlow# def name(*args, **kwargs): 11048c779cdSXin LI0 search/8192 def\ 11148c779cdSXin LI>0 regex \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100} 11248c779cdSXin LI>>&0 regex \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable 11340427ccaSGordon Tetlow!:strength + 15 114b6cee71dSXin LI!:mime text/x-python 115