python 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. #------------------------------------------------------------------------------
  2. # $File: python,v 1.42 2020/06/04 00:22:50 christos Exp $
  3. # python: file(1) magic for python
  4. #
  5. # Outlook puts """ too for urgent messages
  6. # From: David Necas <yeti@physics.muni.cz>
  7. # often the module starts with a multiline string
  8. 0 string/t """ Python script text executable
  9. # MAGIC as specified in Python/import.c (1.0 to 3.7)
  10. # two bytes of magic followed by "\r\n" in little endian order
  11. 0 belong 0x02099900 python 1.0 byte-compiled
  12. !:mime text/x-bytecode.python
  13. 0 belong 0x03099900 python 1.1/1.2 byte-compiled
  14. !:mime text/x-bytecode.python
  15. 0 belong 0x892e0d0a python 1.3 byte-compiled
  16. !:mime text/x-bytecode.python
  17. 0 belong 0x04170d0a python 1.4 byte-compiled
  18. !:mime text/x-bytecode.python
  19. 0 belong 0x994e0d0a python 1.5 byte-compiled
  20. !:mime text/x-bytecode.python
  21. 0 belong 0xfcc40d0a python 1.6 byte-compiled
  22. !:mime text/x-bytecode.python
  23. 0 belong 0xfdc40d0a python 1.6 byte-compiled
  24. !:mime text/x-bytecode.python
  25. 0 belong 0x87c60d0a python 2.0 byte-compiled
  26. !:mime text/x-bytecode.python
  27. 0 belong 0x88c60d0a python 2.0 byte-compiled
  28. !:mime text/x-bytecode.python
  29. 0 belong 0x2aeb0d0a python 2.1 byte-compiled
  30. !:mime text/x-bytecode.python
  31. 0 belong 0x2beb0d0a python 2.1 byte-compiled
  32. !:mime text/x-bytecode.python
  33. 0 belong 0x2ded0d0a python 2.2 byte-compiled
  34. !:mime text/x-bytecode.python
  35. 0 belong 0x2eed0d0a python 2.2 byte-compiled
  36. !:mime text/x-bytecode.python
  37. 0 belong 0x3bf20d0a python 2.3 byte-compiled
  38. !:mime text/x-bytecode.python
  39. 0 belong 0x3cf20d0a python 2.3 byte-compiled
  40. !:mime text/x-bytecode.python
  41. 0 belong 0x45f20d0a python 2.3 byte-compiled
  42. !:mime text/x-bytecode.python
  43. 0 belong 0x59f20d0a python 2.4 byte-compiled
  44. !:mime text/x-bytecode.python
  45. 0 belong 0x63f20d0a python 2.4 byte-compiled
  46. !:mime text/x-bytecode.python
  47. 0 belong 0x6df20d0a python 2.4 byte-compiled
  48. !:mime text/x-bytecode.python
  49. 0 belong 0x6ef20d0a python 2.4 byte-compiled
  50. !:mime text/x-bytecode.python
  51. 0 belong 0x77f20d0a python 2.5 byte-compiled
  52. !:mime text/x-bytecode.python
  53. 0 belong 0x81f20d0a python 2.5 byte-compiled
  54. !:mime text/x-bytecode.python
  55. 0 belong 0x8bf20d0a python 2.5 byte-compiled
  56. !:mime text/x-bytecode.python
  57. 0 belong 0x8cf20d0a python 2.5 byte-compiled
  58. !:mime text/x-bytecode.python
  59. 0 belong 0x95f20d0a python 2.5 byte-compiled
  60. !:mime text/x-bytecode.python
  61. 0 belong 0x9ff20d0a python 2.5 byte-compiled
  62. !:mime text/x-bytecode.python
  63. 0 belong 0xa9f20d0a python 2.5 byte-compiled
  64. !:mime text/x-bytecode.python
  65. 0 belong 0xb3f20d0a python 2.5 byte-compiled
  66. !:mime text/x-bytecode.python
  67. 0 belong 0xb4f20d0a python 2.5 byte-compiled
  68. !:mime text/x-bytecode.python
  69. 0 belong 0xc7f20d0a python 2.6 byte-compiled
  70. !:mime text/x-bytecode.python
  71. 0 belong 0xd1f20d0a python 2.6 byte-compiled
  72. !:mime text/x-bytecode.python
  73. 0 belong 0xd2f20d0a python 2.6 byte-compiled
  74. !:mime text/x-bytecode.python
  75. 0 belong 0xdbf20d0a python 2.7 byte-compiled
  76. !:mime text/x-bytecode.python
  77. 0 belong 0xe5f20d0a python 2.7 byte-compiled
  78. !:mime text/x-bytecode.python
  79. 0 belong 0xeff20d0a python 2.7 byte-compiled
  80. !:mime text/x-bytecode.python
  81. 0 belong 0xf9f20d0a python 2.7 byte-compiled
  82. !:mime text/x-bytecode.python
  83. 0 belong 0x03f30d0a python 2.7 byte-compiled
  84. !:mime text/x-bytecode.python
  85. 0 belong 0x04f30d0a python 2.7 byte-compiled
  86. !:mime text/x-bytecode.python
  87. 0 belong 0xb80b0d0a python 3.0 byte-compiled
  88. !:mime text/x-bytecode.python
  89. 0 belong 0xc20b0d0a python 3.0 byte-compiled
  90. !:mime text/x-bytecode.python
  91. 0 belong 0xcc0b0d0a python 3.0 byte-compiled
  92. !:mime text/x-bytecode.python
  93. 0 belong 0xd60b0d0a python 3.0 byte-compiled
  94. !:mime text/x-bytecode.python
  95. 0 belong 0xe00b0d0a python 3.0 byte-compiled
  96. !:mime text/x-bytecode.python
  97. 0 belong 0xea0b0d0a python 3.0 byte-compiled
  98. !:mime text/x-bytecode.python
  99. 0 belong 0xf40b0d0a python 3.0 byte-compiled
  100. !:mime text/x-bytecode.python
  101. 0 belong 0xf50b0d0a python 3.0 byte-compiled
  102. !:mime text/x-bytecode.python
  103. 0 belong 0xff0b0d0a python 3.0 byte-compiled
  104. !:mime text/x-bytecode.python
  105. 0 belong 0x090c0d0a python 3.0 byte-compiled
  106. !:mime text/x-bytecode.python
  107. 0 belong 0x130c0d0a python 3.0 byte-compiled
  108. !:mime text/x-bytecode.python
  109. 0 belong 0x1d0c0d0a python 3.0 byte-compiled
  110. !:mime text/x-bytecode.python
  111. 0 belong 0x1f0c0d0a python 3.0 byte-compiled
  112. !:mime text/x-bytecode.python
  113. 0 belong 0x270c0d0a python 3.0 byte-compiled
  114. !:mime text/x-bytecode.python
  115. 0 belong 0x3b0c0d0a python 3.0 byte-compiled
  116. !:mime text/x-bytecode.python
  117. 0 belong 0x450c0d0a python 3.1 byte-compiled
  118. !:mime text/x-bytecode.python
  119. 0 belong 0x4f0c0d0a python 3.1 byte-compiled
  120. !:mime text/x-bytecode.python
  121. 0 belong 0x580c0d0a python 3.2 byte-compiled
  122. !:mime text/x-bytecode.python
  123. 0 belong 0x620c0d0a python 3.2 byte-compiled
  124. !:mime text/x-bytecode.python
  125. 0 belong 0x6c0c0d0a python 3.2 byte-compiled
  126. !:mime text/x-bytecode.python
  127. 0 belong 0x760c0d0a python 3.3 byte-compiled
  128. !:mime text/x-bytecode.python
  129. 0 belong 0x800c0d0a python 3.3 byte-compiled
  130. !:mime text/x-bytecode.python
  131. 0 belong 0x8a0c0d0a python 3.3 byte-compiled
  132. !:mime text/x-bytecode.python
  133. 0 belong 0x940c0d0a python 3.3 byte-compiled
  134. !:mime text/x-bytecode.python
  135. 0 belong 0x9e0c0d0a python 3.3 byte-compiled
  136. !:mime text/x-bytecode.python
  137. 0 belong 0xb20c0d0a python 3.4 byte-compiled
  138. !:mime text/x-bytecode.python
  139. 0 belong 0xbc0c0d0a python 3.4 byte-compiled
  140. !:mime text/x-bytecode.python
  141. 0 belong 0xc60c0d0a python 3.4 byte-compiled
  142. !:mime text/x-bytecode.python
  143. 0 belong 0xd00c0d0a python 3.4 byte-compiled
  144. !:mime text/x-bytecode.python
  145. 0 belong 0xda0c0d0a python 3.4 byte-compiled
  146. !:mime text/x-bytecode.python
  147. 0 belong 0xe40c0d0a python 3.4 byte-compiled
  148. !:mime text/x-bytecode.python
  149. 0 belong 0xee0c0d0a python 3.4 byte-compiled
  150. !:mime text/x-bytecode.python
  151. 0 belong 0xf80c0d0a python 3.5.1- byte-compiled
  152. !:mime text/x-bytecode.python
  153. 0 belong 0x020d0d0a python 3.5.1- byte-compiled
  154. !:mime text/x-bytecode.python
  155. 0 belong 0x0c0d0d0a python 3.5.1- byte-compiled
  156. !:mime text/x-bytecode.python
  157. 0 belong 0x160d0d0a python 3.5.1- byte-compiled
  158. !:mime text/x-bytecode.python
  159. 0 belong 0x170d0d0a python 3.5.2+ byte-compiled
  160. !:mime text/x-bytecode.python
  161. 0 belong 0x200d0d0a python 3.6 byte-compiled
  162. !:mime text/x-bytecode.python
  163. 0 belong 0x210d0d0a python 3.6 byte-compiled
  164. !:mime text/x-bytecode.python
  165. 0 belong 0x2a0d0d0a python 3.6 byte-compiled
  166. !:mime text/x-bytecode.python
  167. 0 belong 0x2b0d0d0a python 3.6 byte-compiled
  168. !:mime text/x-bytecode.python
  169. 0 belong 0x2c0d0d0a python 3.6 byte-compiled
  170. !:mime text/x-bytecode.python
  171. 0 belong 0x2d0d0d0a python 3.6 byte-compiled
  172. !:mime text/x-bytecode.python
  173. 0 belong 0x2f0d0d0a python 3.6 byte-compiled
  174. !:mime text/x-bytecode.python
  175. 0 belong 0x300d0d0a python 3.6 byte-compiled
  176. !:mime text/x-bytecode.python
  177. 0 belong 0x310d0d0a python 3.6 byte-compiled
  178. !:mime text/x-bytecode.python
  179. 0 belong 0x320d0d0a python 3.6 byte-compiled
  180. !:mime text/x-bytecode.python
  181. 0 belong 0x330d0d0a python 3.6 byte-compiled
  182. !:mime text/x-bytecode.python
  183. 0 belong 0x3e0d0d0a python 3.7 byte-compiled
  184. !:mime text/x-bytecode.python
  185. 0 belong 0x3f0d0d0a python 3.7 byte-compiled
  186. !:mime text/x-bytecode.python
  187. 0 belong 0x400d0d0a python 3.7 byte-compiled
  188. !:mime text/x-bytecode.python
  189. 0 belong 0x410d0d0a python 3.7 byte-compiled
  190. !:mime text/x-bytecode.python
  191. 0 belong 0x420d0d0a python 3.7 byte-compiled
  192. !:mime text/x-bytecode.python
  193. 0 belong 0x480d0d0a python 3.8 byte-compiled
  194. !:mime text/x-bytecode.python
  195. 0 belong 0x490d0d0a python 3.8 byte-compiled
  196. !:mime text/x-bytecode.python
  197. 0 belong 0x520d0d0a python 3.8 byte-compiled
  198. !:mime text/x-bytecode.python
  199. 0 belong 0x530d0d0a python 3.8 byte-compiled
  200. !:mime text/x-bytecode.python
  201. 0 belong 0x540d0d0a python 3.8 byte-compiled
  202. !:mime text/x-bytecode.python
  203. 0 belong 0x550d0d0a python 3.8 byte-compiled
  204. !:mime text/x-bytecode.python
  205. 0 belong 0x5c0d0d0a python 3.9 byte-compiled
  206. !:mime text/x-bytecode.python
  207. 0 belong 0x5d0d0d0a python 3.9 byte-compiled
  208. !:mime text/x-bytecode.python
  209. 0 belong 0x5e0d0d0a python 3.9 byte-compiled
  210. !:mime text/x-bytecode.python
  211. 0 belong 0x5f0d0d0a python 3.9 byte-compiled
  212. !:mime text/x-bytecode.python
  213. 0 belong 0x600d0d0a python 3.9 byte-compiled
  214. !:mime text/x-bytecode.python
  215. 0 belong 0x610d0d0a python 3.9 byte-compiled
  216. !:mime text/x-bytecode.python
  217. 0 search/1/w #!\040/usr/bin/python Python script text executable
  218. !:strength + 15
  219. !:mime text/x-script.python
  220. 0 search/1/w #!\040/usr/local/bin/python Python script text executable
  221. !:strength + 15
  222. !:mime text/x-script.python
  223. 0 search/10/w #!\040/usr/bin/env\040python Python script text executable
  224. !:strength + 15
  225. !:mime text/x-script.python
  226. # from module.submodule import func1, func2
  227. 0 search/8192 import
  228. >0 regex \^from[\040\t]+([A-Za-z0-9_]|\\.)+[\040\t]+import.*$ Python script text executable
  229. !:strength + 15
  230. !:mime text/x-script.python
  231. # def __init__ (self, ...):
  232. 0 search/4096 def\ __init__
  233. >&0 search/64 self Python script text executable
  234. !:strength + 15
  235. !:mime text/x-script.python
  236. # if __name__ == "__main__":
  237. 0 search/4096 if\ __name__
  238. >&0 search/64 '__main__' Python script text executable
  239. >&0 search/64 "__main__" Python script text executable
  240. !:strength + 15
  241. !:mime text/x-script.python
  242. # import module [as abrev]
  243. 0 search/8192 import
  244. >0 regex \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
  245. !:mime text/x-script.python
  246. # comments
  247. #0 search/4096 '''
  248. #>&0 regex .*'''$ Python script text executable
  249. #!:mime text/x-script.python
  250. #0 search/4096 """
  251. #>&0 regex .*"""$ Python script text executable
  252. #!:mime text/x-script.python
  253. # try:
  254. # except: or finally:
  255. # block
  256. 0 search/4096 try:
  257. >&0 regex \^[[:space:]]*except.*:$ Python script text executable
  258. !:strength + 15
  259. !:mime text/x-script.python
  260. >&0 search/4096 finally: Python script text executable
  261. !:mime text/x-script.python
  262. # class name[(base classes,)]: [pass]
  263. 0 search/8192 class
  264. >0 regex \^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$ Python script text executable
  265. !:strength + 15
  266. !:mime text/x-script.python
  267. # def name(*args, **kwargs):
  268. 0 search/8192 def\
  269. >0 regex \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
  270. >>&0 regex \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable
  271. !:strength + 15
  272. !:mime text/x-script.python
  273. # https://numpy.org/devdocs/reference/generated/numpy.lib.format.html
  274. 0 string \223NUMPY NumPy data file
  275. !:mime application/x-numpy-data
  276. >6 byte x \b, version %d
  277. >7 byte x \b.%d
  278. #>8 leshort x \b, header length=%d
  279. >10 string x \b, description %s