1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*43a5ec4eSXin LI# $File: python,v 1.43 2021/05/25 15:12:03 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 10d38c30c0SXin 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 12d38c30c0SXin LI0 belong 0x02099900 python 1.0 byte-compiled 13*43a5ec4eSXin LI!:mime application/x-bytecode.python 14d38c30c0SXin LI0 belong 0x03099900 python 1.1/1.2 byte-compiled 15*43a5ec4eSXin LI!:mime application/x-bytecode.python 16d38c30c0SXin LI0 belong 0x892e0d0a python 1.3 byte-compiled 17*43a5ec4eSXin LI!:mime application/x-bytecode.python 18d38c30c0SXin LI0 belong 0x04170d0a python 1.4 byte-compiled 19*43a5ec4eSXin LI!:mime application/x-bytecode.python 20d38c30c0SXin LI0 belong 0x994e0d0a python 1.5 byte-compiled 21*43a5ec4eSXin LI!:mime application/x-bytecode.python 22d38c30c0SXin LI0 belong 0xfcc40d0a python 1.6 byte-compiled 23*43a5ec4eSXin LI!:mime application/x-bytecode.python 24d38c30c0SXin LI0 belong 0xfdc40d0a python 1.6 byte-compiled 25*43a5ec4eSXin LI!:mime application/x-bytecode.python 26b6cee71dSXin LI0 belong 0x87c60d0a python 2.0 byte-compiled 27*43a5ec4eSXin LI!:mime application/x-bytecode.python 28d38c30c0SXin LI0 belong 0x88c60d0a python 2.0 byte-compiled 29*43a5ec4eSXin LI!:mime application/x-bytecode.python 30b6cee71dSXin LI0 belong 0x2aeb0d0a python 2.1 byte-compiled 31*43a5ec4eSXin LI!:mime application/x-bytecode.python 32d38c30c0SXin LI0 belong 0x2beb0d0a python 2.1 byte-compiled 33*43a5ec4eSXin LI!:mime application/x-bytecode.python 34b6cee71dSXin LI0 belong 0x2ded0d0a python 2.2 byte-compiled 35*43a5ec4eSXin LI!:mime application/x-bytecode.python 36d38c30c0SXin LI0 belong 0x2eed0d0a python 2.2 byte-compiled 37*43a5ec4eSXin LI!:mime application/x-bytecode.python 38b6cee71dSXin LI0 belong 0x3bf20d0a python 2.3 byte-compiled 39*43a5ec4eSXin LI!:mime application/x-bytecode.python 40d38c30c0SXin LI0 belong 0x3cf20d0a python 2.3 byte-compiled 41*43a5ec4eSXin LI!:mime application/x-bytecode.python 422726a701SXin LI0 belong 0x45f20d0a python 2.3 byte-compiled 43*43a5ec4eSXin LI!:mime application/x-bytecode.python 442726a701SXin LI0 belong 0x59f20d0a python 2.4 byte-compiled 45*43a5ec4eSXin LI!:mime application/x-bytecode.python 462726a701SXin LI0 belong 0x63f20d0a python 2.4 byte-compiled 47*43a5ec4eSXin LI!:mime application/x-bytecode.python 48b6cee71dSXin LI0 belong 0x6df20d0a python 2.4 byte-compiled 49*43a5ec4eSXin LI!:mime application/x-bytecode.python 50d38c30c0SXin LI0 belong 0x6ef20d0a python 2.4 byte-compiled 51*43a5ec4eSXin LI!:mime application/x-bytecode.python 522726a701SXin LI0 belong 0x77f20d0a python 2.5 byte-compiled 53*43a5ec4eSXin LI!:mime application/x-bytecode.python 542726a701SXin LI0 belong 0x81f20d0a python 2.5 byte-compiled 55*43a5ec4eSXin LI!:mime application/x-bytecode.python 562726a701SXin LI0 belong 0x8bf20d0a python 2.5 byte-compiled 57*43a5ec4eSXin LI!:mime application/x-bytecode.python 582726a701SXin LI0 belong 0x8cf20d0a python 2.5 byte-compiled 59*43a5ec4eSXin LI!:mime application/x-bytecode.python 602726a701SXin LI0 belong 0x95f20d0a python 2.5 byte-compiled 61*43a5ec4eSXin LI!:mime application/x-bytecode.python 622726a701SXin LI0 belong 0x9ff20d0a python 2.5 byte-compiled 63*43a5ec4eSXin LI!:mime application/x-bytecode.python 642726a701SXin LI0 belong 0xa9f20d0a python 2.5 byte-compiled 65*43a5ec4eSXin LI!:mime application/x-bytecode.python 66b6cee71dSXin LI0 belong 0xb3f20d0a python 2.5 byte-compiled 67*43a5ec4eSXin LI!:mime application/x-bytecode.python 68d38c30c0SXin LI0 belong 0xb4f20d0a python 2.5 byte-compiled 69*43a5ec4eSXin LI!:mime application/x-bytecode.python 702726a701SXin LI0 belong 0xc7f20d0a python 2.6 byte-compiled 71*43a5ec4eSXin LI!:mime application/x-bytecode.python 72b6cee71dSXin LI0 belong 0xd1f20d0a python 2.6 byte-compiled 73*43a5ec4eSXin LI!:mime application/x-bytecode.python 74d38c30c0SXin LI0 belong 0xd2f20d0a python 2.6 byte-compiled 75*43a5ec4eSXin LI!:mime application/x-bytecode.python 762726a701SXin LI0 belong 0xdbf20d0a python 2.7 byte-compiled 77*43a5ec4eSXin LI!:mime application/x-bytecode.python 782726a701SXin LI0 belong 0xe5f20d0a python 2.7 byte-compiled 79*43a5ec4eSXin LI!:mime application/x-bytecode.python 802726a701SXin LI0 belong 0xeff20d0a python 2.7 byte-compiled 81*43a5ec4eSXin LI!:mime application/x-bytecode.python 822726a701SXin LI0 belong 0xf9f20d0a python 2.7 byte-compiled 83*43a5ec4eSXin LI!:mime application/x-bytecode.python 84b6cee71dSXin LI0 belong 0x03f30d0a python 2.7 byte-compiled 85*43a5ec4eSXin LI!:mime application/x-bytecode.python 86d38c30c0SXin LI0 belong 0x04f30d0a python 2.7 byte-compiled 87*43a5ec4eSXin LI!:mime application/x-bytecode.python 882726a701SXin LI0 belong 0xb80b0d0a python 3.0 byte-compiled 89*43a5ec4eSXin LI!:mime application/x-bytecode.python 902726a701SXin LI0 belong 0xc20b0d0a python 3.0 byte-compiled 91*43a5ec4eSXin LI!:mime application/x-bytecode.python 922726a701SXin LI0 belong 0xcc0b0d0a python 3.0 byte-compiled 93*43a5ec4eSXin LI!:mime application/x-bytecode.python 942726a701SXin LI0 belong 0xd60b0d0a python 3.0 byte-compiled 95*43a5ec4eSXin LI!:mime application/x-bytecode.python 962726a701SXin LI0 belong 0xe00b0d0a python 3.0 byte-compiled 97*43a5ec4eSXin LI!:mime application/x-bytecode.python 982726a701SXin LI0 belong 0xea0b0d0a python 3.0 byte-compiled 99*43a5ec4eSXin LI!:mime application/x-bytecode.python 1002726a701SXin LI0 belong 0xf40b0d0a python 3.0 byte-compiled 101*43a5ec4eSXin LI!:mime application/x-bytecode.python 1022726a701SXin LI0 belong 0xf50b0d0a python 3.0 byte-compiled 103*43a5ec4eSXin LI!:mime application/x-bytecode.python 1042726a701SXin LI0 belong 0xff0b0d0a python 3.0 byte-compiled 105*43a5ec4eSXin LI!:mime application/x-bytecode.python 1062726a701SXin LI0 belong 0x090c0d0a python 3.0 byte-compiled 107*43a5ec4eSXin LI!:mime application/x-bytecode.python 1082726a701SXin LI0 belong 0x130c0d0a python 3.0 byte-compiled 109*43a5ec4eSXin LI!:mime application/x-bytecode.python 1102726a701SXin LI0 belong 0x1d0c0d0a python 3.0 byte-compiled 111*43a5ec4eSXin LI!:mime application/x-bytecode.python 1122726a701SXin LI0 belong 0x1f0c0d0a python 3.0 byte-compiled 113*43a5ec4eSXin LI!:mime application/x-bytecode.python 1142726a701SXin LI0 belong 0x270c0d0a python 3.0 byte-compiled 115*43a5ec4eSXin LI!:mime application/x-bytecode.python 116b6cee71dSXin LI0 belong 0x3b0c0d0a python 3.0 byte-compiled 117*43a5ec4eSXin LI!:mime application/x-bytecode.python 1182726a701SXin LI0 belong 0x450c0d0a python 3.1 byte-compiled 119*43a5ec4eSXin LI!:mime application/x-bytecode.python 120b6cee71dSXin LI0 belong 0x4f0c0d0a python 3.1 byte-compiled 121*43a5ec4eSXin LI!:mime application/x-bytecode.python 1222726a701SXin LI0 belong 0x580c0d0a python 3.2 byte-compiled 123*43a5ec4eSXin LI!:mime application/x-bytecode.python 1242726a701SXin LI0 belong 0x620c0d0a python 3.2 byte-compiled 125*43a5ec4eSXin LI!:mime application/x-bytecode.python 126b6cee71dSXin LI0 belong 0x6c0c0d0a python 3.2 byte-compiled 127*43a5ec4eSXin LI!:mime application/x-bytecode.python 1282726a701SXin LI0 belong 0x760c0d0a python 3.3 byte-compiled 129*43a5ec4eSXin LI!:mime application/x-bytecode.python 1302726a701SXin LI0 belong 0x800c0d0a python 3.3 byte-compiled 131*43a5ec4eSXin LI!:mime application/x-bytecode.python 1322726a701SXin LI0 belong 0x8a0c0d0a python 3.3 byte-compiled 133*43a5ec4eSXin LI!:mime application/x-bytecode.python 1342726a701SXin LI0 belong 0x940c0d0a python 3.3 byte-compiled 135*43a5ec4eSXin LI!:mime application/x-bytecode.python 136b6cee71dSXin LI0 belong 0x9e0c0d0a python 3.3 byte-compiled 137*43a5ec4eSXin LI!:mime application/x-bytecode.python 1382726a701SXin LI0 belong 0xb20c0d0a python 3.4 byte-compiled 139*43a5ec4eSXin LI!:mime application/x-bytecode.python 1402726a701SXin LI0 belong 0xbc0c0d0a python 3.4 byte-compiled 141*43a5ec4eSXin LI!:mime application/x-bytecode.python 1422726a701SXin LI0 belong 0xc60c0d0a python 3.4 byte-compiled 143*43a5ec4eSXin LI!:mime application/x-bytecode.python 1442726a701SXin LI0 belong 0xd00c0d0a python 3.4 byte-compiled 145*43a5ec4eSXin LI!:mime application/x-bytecode.python 1462726a701SXin LI0 belong 0xda0c0d0a python 3.4 byte-compiled 147*43a5ec4eSXin LI!:mime application/x-bytecode.python 1482726a701SXin LI0 belong 0xe40c0d0a python 3.4 byte-compiled 149*43a5ec4eSXin LI!:mime application/x-bytecode.python 150c2931133SXin LI0 belong 0xee0c0d0a python 3.4 byte-compiled 151*43a5ec4eSXin LI!:mime application/x-bytecode.python 1522726a701SXin LI0 belong 0xf80c0d0a python 3.5.1- byte-compiled 153*43a5ec4eSXin LI!:mime application/x-bytecode.python 1542726a701SXin LI0 belong 0x020d0d0a python 3.5.1- byte-compiled 155*43a5ec4eSXin LI!:mime application/x-bytecode.python 1562726a701SXin LI0 belong 0x0c0d0d0a python 3.5.1- byte-compiled 157*43a5ec4eSXin LI!:mime application/x-bytecode.python 1582726a701SXin LI0 belong 0x160d0d0a python 3.5.1- byte-compiled 159*43a5ec4eSXin LI!:mime application/x-bytecode.python 1602726a701SXin LI0 belong 0x170d0d0a python 3.5.2+ byte-compiled 161*43a5ec4eSXin LI!:mime application/x-bytecode.python 1622726a701SXin LI0 belong 0x200d0d0a python 3.6 byte-compiled 163*43a5ec4eSXin LI!:mime application/x-bytecode.python 1642726a701SXin LI0 belong 0x210d0d0a python 3.6 byte-compiled 165*43a5ec4eSXin LI!:mime application/x-bytecode.python 1662726a701SXin LI0 belong 0x2a0d0d0a python 3.6 byte-compiled 167*43a5ec4eSXin LI!:mime application/x-bytecode.python 1682726a701SXin LI0 belong 0x2b0d0d0a python 3.6 byte-compiled 169*43a5ec4eSXin LI!:mime application/x-bytecode.python 1702726a701SXin LI0 belong 0x2c0d0d0a python 3.6 byte-compiled 171*43a5ec4eSXin LI!:mime application/x-bytecode.python 1722726a701SXin LI0 belong 0x2d0d0d0a python 3.6 byte-compiled 173*43a5ec4eSXin LI!:mime application/x-bytecode.python 1742726a701SXin LI0 belong 0x2f0d0d0a python 3.6 byte-compiled 175*43a5ec4eSXin LI!:mime application/x-bytecode.python 1762726a701SXin LI0 belong 0x300d0d0a python 3.6 byte-compiled 177*43a5ec4eSXin LI!:mime application/x-bytecode.python 1782726a701SXin LI0 belong 0x310d0d0a python 3.6 byte-compiled 179*43a5ec4eSXin LI!:mime application/x-bytecode.python 1802726a701SXin LI0 belong 0x320d0d0a python 3.6 byte-compiled 181*43a5ec4eSXin LI!:mime application/x-bytecode.python 18240427ccaSGordon Tetlow0 belong 0x330d0d0a python 3.6 byte-compiled 183*43a5ec4eSXin LI!:mime application/x-bytecode.python 1842726a701SXin LI0 belong 0x3e0d0d0a python 3.7 byte-compiled 185*43a5ec4eSXin LI!:mime application/x-bytecode.python 1862726a701SXin LI0 belong 0x3f0d0d0a python 3.7 byte-compiled 187*43a5ec4eSXin LI!:mime application/x-bytecode.python 1882726a701SXin LI0 belong 0x400d0d0a python 3.7 byte-compiled 189*43a5ec4eSXin LI!:mime application/x-bytecode.python 1902726a701SXin LI0 belong 0x410d0d0a python 3.7 byte-compiled 191*43a5ec4eSXin LI!:mime application/x-bytecode.python 19248c779cdSXin LI0 belong 0x420d0d0a python 3.7 byte-compiled 193*43a5ec4eSXin LI!:mime application/x-bytecode.python 1942726a701SXin LI0 belong 0x480d0d0a python 3.8 byte-compiled 195*43a5ec4eSXin LI!:mime application/x-bytecode.python 1962726a701SXin LI0 belong 0x490d0d0a python 3.8 byte-compiled 197*43a5ec4eSXin LI!:mime application/x-bytecode.python 1982726a701SXin LI0 belong 0x520d0d0a python 3.8 byte-compiled 199*43a5ec4eSXin LI!:mime application/x-bytecode.python 2002726a701SXin LI0 belong 0x530d0d0a python 3.8 byte-compiled 201*43a5ec4eSXin LI!:mime application/x-bytecode.python 2022726a701SXin LI0 belong 0x540d0d0a python 3.8 byte-compiled 203*43a5ec4eSXin LI!:mime application/x-bytecode.python 2042726a701SXin LI0 belong 0x550d0d0a python 3.8 byte-compiled 205*43a5ec4eSXin LI!:mime application/x-bytecode.python 2062726a701SXin LI0 belong 0x5c0d0d0a python 3.9 byte-compiled 207*43a5ec4eSXin LI!:mime application/x-bytecode.python 2082726a701SXin LI0 belong 0x5d0d0d0a python 3.9 byte-compiled 209*43a5ec4eSXin LI!:mime application/x-bytecode.python 2102726a701SXin LI0 belong 0x5e0d0d0a python 3.9 byte-compiled 211*43a5ec4eSXin LI!:mime application/x-bytecode.python 2122726a701SXin LI0 belong 0x5f0d0d0a python 3.9 byte-compiled 213*43a5ec4eSXin LI!:mime application/x-bytecode.python 2142726a701SXin LI0 belong 0x600d0d0a python 3.9 byte-compiled 215*43a5ec4eSXin LI!:mime application/x-bytecode.python 2162726a701SXin LI0 belong 0x610d0d0a python 3.9 byte-compiled 217*43a5ec4eSXin LI!:mime application/x-bytecode.python 21840427ccaSGordon Tetlow 2192726a701SXin LI0 search/1/w #!\040/usr/bin/python Python script text executable 2203e41d09dSXin LI!:strength + 15 2212726a701SXin LI!:mime text/x-script.python 2222726a701SXin LI0 search/1/w #!\040/usr/local/bin/python Python script text executable 2233e41d09dSXin LI!:strength + 15 2242726a701SXin LI!:mime text/x-script.python 2252726a701SXin LI0 search/10/w #!\040/usr/bin/env\040python Python script text executable 2263e41d09dSXin LI!:strength + 15 2272726a701SXin LI!:mime text/x-script.python 228b6cee71dSXin LI 229b6cee71dSXin LI 230b6cee71dSXin LI# from module.submodule import func1, func2 23148c779cdSXin LI0 search/8192 import 2322726a701SXin LI>0 regex \^from[\040\t]+([A-Za-z0-9_]|\\.)+[\040\t]+import.*$ Python script text executable 23340427ccaSGordon Tetlow!:strength + 15 2342726a701SXin LI!:mime text/x-script.python 235b6cee71dSXin LI 236b6cee71dSXin LI# def __init__ (self, ...): 237b6cee71dSXin LI0 search/4096 def\ __init__ 238b6cee71dSXin LI>&0 search/64 self Python script text executable 23940427ccaSGordon Tetlow!:strength + 15 2402726a701SXin LI!:mime text/x-script.python 24140427ccaSGordon Tetlow 24240427ccaSGordon Tetlow# if __name__ == "__main__": 24340427ccaSGordon Tetlow0 search/4096 if\ __name__ 24440427ccaSGordon Tetlow>&0 search/64 '__main__' Python script text executable 24540427ccaSGordon Tetlow>&0 search/64 "__main__" Python script text executable 24640427ccaSGordon Tetlow!:strength + 15 2472726a701SXin LI!:mime text/x-script.python 24840427ccaSGordon Tetlow 24940427ccaSGordon Tetlow# import module [as abrev] 25048c779cdSXin LI0 search/8192 import 25148c779cdSXin LI>0 regex \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable 2522726a701SXin LI!:mime text/x-script.python 253b6cee71dSXin LI 254b6cee71dSXin LI# comments 255b6cee71dSXin LI#0 search/4096 ''' 256b6cee71dSXin LI#>&0 regex .*'''$ Python script text executable 2572726a701SXin LI#!:mime text/x-script.python 258b6cee71dSXin LI 259b6cee71dSXin LI#0 search/4096 """ 260b6cee71dSXin LI#>&0 regex .*"""$ Python script text executable 2612726a701SXin LI#!:mime text/x-script.python 262b6cee71dSXin LI 263b6cee71dSXin LI# try: 264b6cee71dSXin LI# except: or finally: 265b6cee71dSXin LI# block 266b6cee71dSXin LI0 search/4096 try: 26740427ccaSGordon Tetlow>&0 regex \^[[:space:]]*except.*:$ Python script text executable 26840427ccaSGordon Tetlow!:strength + 15 2692726a701SXin LI!:mime text/x-script.python 270b6cee71dSXin LI>&0 search/4096 finally: Python script text executable 2712726a701SXin LI!:mime text/x-script.python 272b6cee71dSXin LI 27340427ccaSGordon Tetlow# class name[(base classes,)]: [pass] 27448c779cdSXin LI0 search/8192 class 27548c779cdSXin LI>0 regex \^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$ Python script text executable 27640427ccaSGordon Tetlow!:strength + 15 2772726a701SXin LI!:mime text/x-script.python 27840427ccaSGordon Tetlow 27940427ccaSGordon Tetlow# def name(*args, **kwargs): 28048c779cdSXin LI0 search/8192 def\ 28148c779cdSXin LI>0 regex \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100} 28248c779cdSXin LI>>&0 regex \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable 28340427ccaSGordon Tetlow!:strength + 15 2842726a701SXin LI!:mime text/x-script.python 2852726a701SXin LI 2862726a701SXin LI# https://numpy.org/devdocs/reference/generated/numpy.lib.format.html 2872726a701SXin LI0 string \223NUMPY NumPy data file 2882726a701SXin LI!:mime application/x-numpy-data 2892726a701SXin LI>6 byte x \b, version %d 2902726a701SXin LI>7 byte x \b.%d 2912726a701SXin LI#>8 leshort x \b, header length=%d 2922726a701SXin LI>10 string x \b, description %s 293