1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*2726a701SXin LI# $File: python,v 1.42 2020/06/04 00:22:50 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*2726a701SXin LI!:mime text/x-bytecode.python 14d38c30c0SXin LI0 belong 0x03099900 python 1.1/1.2 byte-compiled 15*2726a701SXin LI!:mime text/x-bytecode.python 16d38c30c0SXin LI0 belong 0x892e0d0a python 1.3 byte-compiled 17*2726a701SXin LI!:mime text/x-bytecode.python 18d38c30c0SXin LI0 belong 0x04170d0a python 1.4 byte-compiled 19*2726a701SXin LI!:mime text/x-bytecode.python 20d38c30c0SXin LI0 belong 0x994e0d0a python 1.5 byte-compiled 21*2726a701SXin LI!:mime text/x-bytecode.python 22d38c30c0SXin LI0 belong 0xfcc40d0a python 1.6 byte-compiled 23*2726a701SXin LI!:mime text/x-bytecode.python 24d38c30c0SXin LI0 belong 0xfdc40d0a python 1.6 byte-compiled 25*2726a701SXin LI!:mime text/x-bytecode.python 26b6cee71dSXin LI0 belong 0x87c60d0a python 2.0 byte-compiled 27*2726a701SXin LI!:mime text/x-bytecode.python 28d38c30c0SXin LI0 belong 0x88c60d0a python 2.0 byte-compiled 29*2726a701SXin LI!:mime text/x-bytecode.python 30b6cee71dSXin LI0 belong 0x2aeb0d0a python 2.1 byte-compiled 31*2726a701SXin LI!:mime text/x-bytecode.python 32d38c30c0SXin LI0 belong 0x2beb0d0a python 2.1 byte-compiled 33*2726a701SXin LI!:mime text/x-bytecode.python 34b6cee71dSXin LI0 belong 0x2ded0d0a python 2.2 byte-compiled 35*2726a701SXin LI!:mime text/x-bytecode.python 36d38c30c0SXin LI0 belong 0x2eed0d0a python 2.2 byte-compiled 37*2726a701SXin LI!:mime text/x-bytecode.python 38b6cee71dSXin LI0 belong 0x3bf20d0a python 2.3 byte-compiled 39*2726a701SXin LI!:mime text/x-bytecode.python 40d38c30c0SXin LI0 belong 0x3cf20d0a python 2.3 byte-compiled 41*2726a701SXin LI!:mime text/x-bytecode.python 42*2726a701SXin LI0 belong 0x45f20d0a python 2.3 byte-compiled 43*2726a701SXin LI!:mime text/x-bytecode.python 44*2726a701SXin LI0 belong 0x59f20d0a python 2.4 byte-compiled 45*2726a701SXin LI!:mime text/x-bytecode.python 46*2726a701SXin LI0 belong 0x63f20d0a python 2.4 byte-compiled 47*2726a701SXin LI!:mime text/x-bytecode.python 48b6cee71dSXin LI0 belong 0x6df20d0a python 2.4 byte-compiled 49*2726a701SXin LI!:mime text/x-bytecode.python 50d38c30c0SXin LI0 belong 0x6ef20d0a python 2.4 byte-compiled 51*2726a701SXin LI!:mime text/x-bytecode.python 52*2726a701SXin LI0 belong 0x77f20d0a python 2.5 byte-compiled 53*2726a701SXin LI!:mime text/x-bytecode.python 54*2726a701SXin LI0 belong 0x81f20d0a python 2.5 byte-compiled 55*2726a701SXin LI!:mime text/x-bytecode.python 56*2726a701SXin LI0 belong 0x8bf20d0a python 2.5 byte-compiled 57*2726a701SXin LI!:mime text/x-bytecode.python 58*2726a701SXin LI0 belong 0x8cf20d0a python 2.5 byte-compiled 59*2726a701SXin LI!:mime text/x-bytecode.python 60*2726a701SXin LI0 belong 0x95f20d0a python 2.5 byte-compiled 61*2726a701SXin LI!:mime text/x-bytecode.python 62*2726a701SXin LI0 belong 0x9ff20d0a python 2.5 byte-compiled 63*2726a701SXin LI!:mime text/x-bytecode.python 64*2726a701SXin LI0 belong 0xa9f20d0a python 2.5 byte-compiled 65*2726a701SXin LI!:mime text/x-bytecode.python 66b6cee71dSXin LI0 belong 0xb3f20d0a python 2.5 byte-compiled 67*2726a701SXin LI!:mime text/x-bytecode.python 68d38c30c0SXin LI0 belong 0xb4f20d0a python 2.5 byte-compiled 69*2726a701SXin LI!:mime text/x-bytecode.python 70*2726a701SXin LI0 belong 0xc7f20d0a python 2.6 byte-compiled 71*2726a701SXin LI!:mime text/x-bytecode.python 72b6cee71dSXin LI0 belong 0xd1f20d0a python 2.6 byte-compiled 73*2726a701SXin LI!:mime text/x-bytecode.python 74d38c30c0SXin LI0 belong 0xd2f20d0a python 2.6 byte-compiled 75*2726a701SXin LI!:mime text/x-bytecode.python 76*2726a701SXin LI0 belong 0xdbf20d0a python 2.7 byte-compiled 77*2726a701SXin LI!:mime text/x-bytecode.python 78*2726a701SXin LI0 belong 0xe5f20d0a python 2.7 byte-compiled 79*2726a701SXin LI!:mime text/x-bytecode.python 80*2726a701SXin LI0 belong 0xeff20d0a python 2.7 byte-compiled 81*2726a701SXin LI!:mime text/x-bytecode.python 82*2726a701SXin LI0 belong 0xf9f20d0a python 2.7 byte-compiled 83*2726a701SXin LI!:mime text/x-bytecode.python 84b6cee71dSXin LI0 belong 0x03f30d0a python 2.7 byte-compiled 85*2726a701SXin LI!:mime text/x-bytecode.python 86d38c30c0SXin LI0 belong 0x04f30d0a python 2.7 byte-compiled 87*2726a701SXin LI!:mime text/x-bytecode.python 88*2726a701SXin LI0 belong 0xb80b0d0a python 3.0 byte-compiled 89*2726a701SXin LI!:mime text/x-bytecode.python 90*2726a701SXin LI0 belong 0xc20b0d0a python 3.0 byte-compiled 91*2726a701SXin LI!:mime text/x-bytecode.python 92*2726a701SXin LI0 belong 0xcc0b0d0a python 3.0 byte-compiled 93*2726a701SXin LI!:mime text/x-bytecode.python 94*2726a701SXin LI0 belong 0xd60b0d0a python 3.0 byte-compiled 95*2726a701SXin LI!:mime text/x-bytecode.python 96*2726a701SXin LI0 belong 0xe00b0d0a python 3.0 byte-compiled 97*2726a701SXin LI!:mime text/x-bytecode.python 98*2726a701SXin LI0 belong 0xea0b0d0a python 3.0 byte-compiled 99*2726a701SXin LI!:mime text/x-bytecode.python 100*2726a701SXin LI0 belong 0xf40b0d0a python 3.0 byte-compiled 101*2726a701SXin LI!:mime text/x-bytecode.python 102*2726a701SXin LI0 belong 0xf50b0d0a python 3.0 byte-compiled 103*2726a701SXin LI!:mime text/x-bytecode.python 104*2726a701SXin LI0 belong 0xff0b0d0a python 3.0 byte-compiled 105*2726a701SXin LI!:mime text/x-bytecode.python 106*2726a701SXin LI0 belong 0x090c0d0a python 3.0 byte-compiled 107*2726a701SXin LI!:mime text/x-bytecode.python 108*2726a701SXin LI0 belong 0x130c0d0a python 3.0 byte-compiled 109*2726a701SXin LI!:mime text/x-bytecode.python 110*2726a701SXin LI0 belong 0x1d0c0d0a python 3.0 byte-compiled 111*2726a701SXin LI!:mime text/x-bytecode.python 112*2726a701SXin LI0 belong 0x1f0c0d0a python 3.0 byte-compiled 113*2726a701SXin LI!:mime text/x-bytecode.python 114*2726a701SXin LI0 belong 0x270c0d0a python 3.0 byte-compiled 115*2726a701SXin LI!:mime text/x-bytecode.python 116b6cee71dSXin LI0 belong 0x3b0c0d0a python 3.0 byte-compiled 117*2726a701SXin LI!:mime text/x-bytecode.python 118*2726a701SXin LI0 belong 0x450c0d0a python 3.1 byte-compiled 119*2726a701SXin LI!:mime text/x-bytecode.python 120b6cee71dSXin LI0 belong 0x4f0c0d0a python 3.1 byte-compiled 121*2726a701SXin LI!:mime text/x-bytecode.python 122*2726a701SXin LI0 belong 0x580c0d0a python 3.2 byte-compiled 123*2726a701SXin LI!:mime text/x-bytecode.python 124*2726a701SXin LI0 belong 0x620c0d0a python 3.2 byte-compiled 125*2726a701SXin LI!:mime text/x-bytecode.python 126b6cee71dSXin LI0 belong 0x6c0c0d0a python 3.2 byte-compiled 127*2726a701SXin LI!:mime text/x-bytecode.python 128*2726a701SXin LI0 belong 0x760c0d0a python 3.3 byte-compiled 129*2726a701SXin LI!:mime text/x-bytecode.python 130*2726a701SXin LI0 belong 0x800c0d0a python 3.3 byte-compiled 131*2726a701SXin LI!:mime text/x-bytecode.python 132*2726a701SXin LI0 belong 0x8a0c0d0a python 3.3 byte-compiled 133*2726a701SXin LI!:mime text/x-bytecode.python 134*2726a701SXin LI0 belong 0x940c0d0a python 3.3 byte-compiled 135*2726a701SXin LI!:mime text/x-bytecode.python 136b6cee71dSXin LI0 belong 0x9e0c0d0a python 3.3 byte-compiled 137*2726a701SXin LI!:mime text/x-bytecode.python 138*2726a701SXin LI0 belong 0xb20c0d0a python 3.4 byte-compiled 139*2726a701SXin LI!:mime text/x-bytecode.python 140*2726a701SXin LI0 belong 0xbc0c0d0a python 3.4 byte-compiled 141*2726a701SXin LI!:mime text/x-bytecode.python 142*2726a701SXin LI0 belong 0xc60c0d0a python 3.4 byte-compiled 143*2726a701SXin LI!:mime text/x-bytecode.python 144*2726a701SXin LI0 belong 0xd00c0d0a python 3.4 byte-compiled 145*2726a701SXin LI!:mime text/x-bytecode.python 146*2726a701SXin LI0 belong 0xda0c0d0a python 3.4 byte-compiled 147*2726a701SXin LI!:mime text/x-bytecode.python 148*2726a701SXin LI0 belong 0xe40c0d0a python 3.4 byte-compiled 149*2726a701SXin LI!:mime text/x-bytecode.python 150c2931133SXin LI0 belong 0xee0c0d0a python 3.4 byte-compiled 151*2726a701SXin LI!:mime text/x-bytecode.python 152*2726a701SXin LI0 belong 0xf80c0d0a python 3.5.1- byte-compiled 153*2726a701SXin LI!:mime text/x-bytecode.python 154*2726a701SXin LI0 belong 0x020d0d0a python 3.5.1- byte-compiled 155*2726a701SXin LI!:mime text/x-bytecode.python 156*2726a701SXin LI0 belong 0x0c0d0d0a python 3.5.1- byte-compiled 157*2726a701SXin LI!:mime text/x-bytecode.python 158*2726a701SXin LI0 belong 0x160d0d0a python 3.5.1- byte-compiled 159*2726a701SXin LI!:mime text/x-bytecode.python 160*2726a701SXin LI0 belong 0x170d0d0a python 3.5.2+ byte-compiled 161*2726a701SXin LI!:mime text/x-bytecode.python 162*2726a701SXin LI0 belong 0x200d0d0a python 3.6 byte-compiled 163*2726a701SXin LI!:mime text/x-bytecode.python 164*2726a701SXin LI0 belong 0x210d0d0a python 3.6 byte-compiled 165*2726a701SXin LI!:mime text/x-bytecode.python 166*2726a701SXin LI0 belong 0x2a0d0d0a python 3.6 byte-compiled 167*2726a701SXin LI!:mime text/x-bytecode.python 168*2726a701SXin LI0 belong 0x2b0d0d0a python 3.6 byte-compiled 169*2726a701SXin LI!:mime text/x-bytecode.python 170*2726a701SXin LI0 belong 0x2c0d0d0a python 3.6 byte-compiled 171*2726a701SXin LI!:mime text/x-bytecode.python 172*2726a701SXin LI0 belong 0x2d0d0d0a python 3.6 byte-compiled 173*2726a701SXin LI!:mime text/x-bytecode.python 174*2726a701SXin LI0 belong 0x2f0d0d0a python 3.6 byte-compiled 175*2726a701SXin LI!:mime text/x-bytecode.python 176*2726a701SXin LI0 belong 0x300d0d0a python 3.6 byte-compiled 177*2726a701SXin LI!:mime text/x-bytecode.python 178*2726a701SXin LI0 belong 0x310d0d0a python 3.6 byte-compiled 179*2726a701SXin LI!:mime text/x-bytecode.python 180*2726a701SXin LI0 belong 0x320d0d0a python 3.6 byte-compiled 181*2726a701SXin LI!:mime text/x-bytecode.python 18240427ccaSGordon Tetlow0 belong 0x330d0d0a python 3.6 byte-compiled 183*2726a701SXin LI!:mime text/x-bytecode.python 184*2726a701SXin LI0 belong 0x3e0d0d0a python 3.7 byte-compiled 185*2726a701SXin LI!:mime text/x-bytecode.python 186*2726a701SXin LI0 belong 0x3f0d0d0a python 3.7 byte-compiled 187*2726a701SXin LI!:mime text/x-bytecode.python 188*2726a701SXin LI0 belong 0x400d0d0a python 3.7 byte-compiled 189*2726a701SXin LI!:mime text/x-bytecode.python 190*2726a701SXin LI0 belong 0x410d0d0a python 3.7 byte-compiled 191*2726a701SXin LI!:mime text/x-bytecode.python 19248c779cdSXin LI0 belong 0x420d0d0a python 3.7 byte-compiled 193*2726a701SXin LI!:mime text/x-bytecode.python 194*2726a701SXin LI0 belong 0x480d0d0a python 3.8 byte-compiled 195*2726a701SXin LI!:mime text/x-bytecode.python 196*2726a701SXin LI0 belong 0x490d0d0a python 3.8 byte-compiled 197*2726a701SXin LI!:mime text/x-bytecode.python 198*2726a701SXin LI0 belong 0x520d0d0a python 3.8 byte-compiled 199*2726a701SXin LI!:mime text/x-bytecode.python 200*2726a701SXin LI0 belong 0x530d0d0a python 3.8 byte-compiled 201*2726a701SXin LI!:mime text/x-bytecode.python 202*2726a701SXin LI0 belong 0x540d0d0a python 3.8 byte-compiled 203*2726a701SXin LI!:mime text/x-bytecode.python 204*2726a701SXin LI0 belong 0x550d0d0a python 3.8 byte-compiled 205*2726a701SXin LI!:mime text/x-bytecode.python 206*2726a701SXin LI0 belong 0x5c0d0d0a python 3.9 byte-compiled 207*2726a701SXin LI!:mime text/x-bytecode.python 208*2726a701SXin LI0 belong 0x5d0d0d0a python 3.9 byte-compiled 209*2726a701SXin LI!:mime text/x-bytecode.python 210*2726a701SXin LI0 belong 0x5e0d0d0a python 3.9 byte-compiled 211*2726a701SXin LI!:mime text/x-bytecode.python 212*2726a701SXin LI0 belong 0x5f0d0d0a python 3.9 byte-compiled 213*2726a701SXin LI!:mime text/x-bytecode.python 214*2726a701SXin LI0 belong 0x600d0d0a python 3.9 byte-compiled 215*2726a701SXin LI!:mime text/x-bytecode.python 216*2726a701SXin LI0 belong 0x610d0d0a python 3.9 byte-compiled 217*2726a701SXin LI!:mime text/x-bytecode.python 21840427ccaSGordon Tetlow 219*2726a701SXin LI0 search/1/w #!\040/usr/bin/python Python script text executable 2203e41d09dSXin LI!:strength + 15 221*2726a701SXin LI!:mime text/x-script.python 222*2726a701SXin LI0 search/1/w #!\040/usr/local/bin/python Python script text executable 2233e41d09dSXin LI!:strength + 15 224*2726a701SXin LI!:mime text/x-script.python 225*2726a701SXin LI0 search/10/w #!\040/usr/bin/env\040python Python script text executable 2263e41d09dSXin LI!:strength + 15 227*2726a701SXin LI!:mime text/x-script.python 228b6cee71dSXin LI 229b6cee71dSXin LI 230b6cee71dSXin LI# from module.submodule import func1, func2 23148c779cdSXin LI0 search/8192 import 232*2726a701SXin LI>0 regex \^from[\040\t]+([A-Za-z0-9_]|\\.)+[\040\t]+import.*$ Python script text executable 23340427ccaSGordon Tetlow!:strength + 15 234*2726a701SXin 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 240*2726a701SXin 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 247*2726a701SXin 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 252*2726a701SXin LI!:mime text/x-script.python 253b6cee71dSXin LI 254b6cee71dSXin LI# comments 255b6cee71dSXin LI#0 search/4096 ''' 256b6cee71dSXin LI#>&0 regex .*'''$ Python script text executable 257*2726a701SXin LI#!:mime text/x-script.python 258b6cee71dSXin LI 259b6cee71dSXin LI#0 search/4096 """ 260b6cee71dSXin LI#>&0 regex .*"""$ Python script text executable 261*2726a701SXin 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 269*2726a701SXin LI!:mime text/x-script.python 270b6cee71dSXin LI>&0 search/4096 finally: Python script text executable 271*2726a701SXin 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 277*2726a701SXin 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 284*2726a701SXin LI!:mime text/x-script.python 285*2726a701SXin LI 286*2726a701SXin LI# https://numpy.org/devdocs/reference/generated/numpy.lib.format.html 287*2726a701SXin LI0 string \223NUMPY NumPy data file 288*2726a701SXin LI!:mime application/x-numpy-data 289*2726a701SXin LI>6 byte x \b, version %d 290*2726a701SXin LI>7 byte x \b.%d 291*2726a701SXin LI#>8 leshort x \b, header length=%d 292*2726a701SXin LI>10 string x \b, description %s 293