HyFetch 1.5.0a3__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (567) hide show
  1. HyFetch-1.5.0a3.data/scripts/neowofetch +15954 -0
  2. HyFetch-1.5.0a3.dist-info/LICENSE.md +21 -0
  3. HyFetch-1.5.0a3.dist-info/METADATA +705 -0
  4. HyFetch-1.5.0a3.dist-info/RECORD +567 -0
  5. HyFetch-1.5.0a3.dist-info/WHEEL +5 -0
  6. HyFetch-1.5.0a3.dist-info/entry_points.txt +2 -0
  7. HyFetch-1.5.0a3.dist-info/top_level.txt +4 -0
  8. docs/hyfetch.1 +73 -0
  9. docs/neofetch.1 +476 -0
  10. hyfetch/__init__.py +9 -0
  11. hyfetch/__main__.py +9 -0
  12. hyfetch/__version__.py +1 -0
  13. hyfetch/color_scale.py +76 -0
  14. hyfetch/color_util.py +251 -0
  15. hyfetch/constants.py +53 -0
  16. hyfetch/data/font_logos.json +121 -0
  17. hyfetch/distros/__init__.py +20 -0
  18. hyfetch/distros/adelie.py +23 -0
  19. hyfetch/distros/aeros.py +29 -0
  20. hyfetch/distros/afterglow.py +22 -0
  21. hyfetch/distros/aix.py +27 -0
  22. hyfetch/distros/almalinux.py +27 -0
  23. hyfetch/distros/alpine.py +27 -0
  24. hyfetch/distros/alpine_small.py +13 -0
  25. hyfetch/distros/alter.py +27 -0
  26. hyfetch/distros/amazon.py +26 -0
  27. hyfetch/distros/amogos.py +26 -0
  28. hyfetch/distros/anarchy.py +35 -0
  29. hyfetch/distros/android.py +25 -0
  30. hyfetch/distros/android_small.py +13 -0
  31. hyfetch/distros/antergos.py +26 -0
  32. hyfetch/distros/antix.py +20 -0
  33. hyfetch/distros/aosc_os.py +24 -0
  34. hyfetch/distros/aperio_gnu_linux.py +11 -0
  35. hyfetch/distros/aperture.py +27 -0
  36. hyfetch/distros/apricity.py +25 -0
  37. hyfetch/distros/arch.py +26 -0
  38. hyfetch/distros/arch_old.py +23 -0
  39. hyfetch/distros/arch_small.py +14 -0
  40. hyfetch/distros/archbox.py +26 -0
  41. hyfetch/distros/archcraft.py +27 -0
  42. hyfetch/distros/archcraft_ascii.py +27 -0
  43. hyfetch/distros/archcraft_minimal.py +27 -0
  44. hyfetch/distros/archlabs.py +28 -0
  45. hyfetch/distros/archmerge.py +27 -0
  46. hyfetch/distros/archstrike.py +24 -0
  47. hyfetch/distros/arcolinux.py +27 -0
  48. hyfetch/distros/arcolinux_small.py +18 -0
  49. hyfetch/distros/arselinux.py +23 -0
  50. hyfetch/distros/artix.py +27 -0
  51. hyfetch/distros/artix_small.py +20 -0
  52. hyfetch/distros/arya.py +22 -0
  53. hyfetch/distros/asahi.py +25 -0
  54. hyfetch/distros/asteroidos.py +24 -0
  55. hyfetch/distros/astos.py +30 -0
  56. hyfetch/distros/astra_linux.py +29 -0
  57. hyfetch/distros/athena.py +31 -0
  58. hyfetch/distros/azos.py +24 -0
  59. hyfetch/distros/bedrock.py +24 -0
  60. hyfetch/distros/biglinux.py +31 -0
  61. hyfetch/distros/bitrig.py +24 -0
  62. hyfetch/distros/blackarch.py +28 -0
  63. hyfetch/distros/blackpanther.py +30 -0
  64. hyfetch/distros/blag.py +24 -0
  65. hyfetch/distros/blankon.py +24 -0
  66. hyfetch/distros/bluelight.py +26 -0
  67. hyfetch/distros/bodhi.py +25 -0
  68. hyfetch/distros/bonsai.py +23 -0
  69. hyfetch/distros/bsd.py +26 -0
  70. hyfetch/distros/bunsenlabs.py +27 -0
  71. hyfetch/distros/cachyos.py +29 -0
  72. hyfetch/distros/calculate.py +27 -0
  73. hyfetch/distros/calinixos.py +33 -0
  74. hyfetch/distros/calinixos_small.py +23 -0
  75. hyfetch/distros/carbs.py +25 -0
  76. hyfetch/distros/cbl_mariner.py +25 -0
  77. hyfetch/distros/celos.py +27 -0
  78. hyfetch/distros/center.py +20 -0
  79. hyfetch/distros/centos.py +26 -0
  80. hyfetch/distros/centos_small.py +14 -0
  81. hyfetch/distros/chakra.py +25 -0
  82. hyfetch/distros/chaletos.py +27 -0
  83. hyfetch/distros/chapeau.py +25 -0
  84. hyfetch/distros/chimera.py +25 -0
  85. hyfetch/distros/chonkysealos.py +28 -0
  86. hyfetch/distros/chrom.py +25 -0
  87. hyfetch/distros/cleanjaro.py +19 -0
  88. hyfetch/distros/cleanjaro_small.py +14 -0
  89. hyfetch/distros/clear_linux_os.py +27 -0
  90. hyfetch/distros/clearos.py +27 -0
  91. hyfetch/distros/clover.py +27 -0
  92. hyfetch/distros/cobalt.py +23 -0
  93. hyfetch/distros/condres.py +24 -0
  94. hyfetch/distros/container_linux_by_coreos.py +27 -0
  95. hyfetch/distros/crux.py +25 -0
  96. hyfetch/distros/crux_small.py +14 -0
  97. hyfetch/distros/crystal_linux.py +27 -0
  98. hyfetch/distros/cucumber.py +27 -0
  99. hyfetch/distros/cutefishos.py +16 -0
  100. hyfetch/distros/cuteos.py +22 -0
  101. hyfetch/distros/cyberos.py +22 -0
  102. hyfetch/distros/dahlia.py +25 -0
  103. hyfetch/distros/darkos.py +28 -0
  104. hyfetch/distros/darwin.py +24 -0
  105. hyfetch/distros/debian.py +24 -0
  106. hyfetch/distros/debian_small.py +13 -0
  107. hyfetch/distros/deepin.py +25 -0
  108. hyfetch/distros/desaos.py +23 -0
  109. hyfetch/distros/devuan.py +22 -0
  110. hyfetch/distros/dietpi.py +26 -0
  111. hyfetch/distros/digital_unix.py +16 -0
  112. hyfetch/distros/distro_detector.py +1518 -0
  113. hyfetch/distros/dracos.py +20 -0
  114. hyfetch/distros/dragonfly.py +22 -0
  115. hyfetch/distros/dragonfly_old.py +24 -0
  116. hyfetch/distros/dragonfly_small.py +14 -0
  117. hyfetch/distros/drauger.py +23 -0
  118. hyfetch/distros/droidian.py +22 -0
  119. hyfetch/distros/elementary.py +24 -0
  120. hyfetch/distros/elementary_small.py +13 -0
  121. hyfetch/distros/elive.py +25 -0
  122. hyfetch/distros/encryptos.py +20 -0
  123. hyfetch/distros/endeavouros.py +22 -0
  124. hyfetch/distros/endeavouros_small.py +14 -0
  125. hyfetch/distros/endless.py +27 -0
  126. hyfetch/distros/enso.py +27 -0
  127. hyfetch/distros/eurolinux.py +25 -0
  128. hyfetch/distros/evolutionos.py +25 -0
  129. hyfetch/distros/eweos.py +22 -0
  130. hyfetch/distros/exherbo.py +29 -0
  131. hyfetch/distros/exodia_predator_os.py +31 -0
  132. hyfetch/distros/fedora.py +26 -0
  133. hyfetch/distros/fedora_kinoite.py +25 -0
  134. hyfetch/distros/fedora_old.py +24 -0
  135. hyfetch/distros/fedora_sericea.py +24 -0
  136. hyfetch/distros/fedora_silverblue.py +24 -0
  137. hyfetch/distros/fedora_small.py +16 -0
  138. hyfetch/distros/fedora_unicode.py +25 -0
  139. hyfetch/distros/femboyos.py +27 -0
  140. hyfetch/distros/feren.py +23 -0
  141. hyfetch/distros/finnix.py +24 -0
  142. hyfetch/distros/floflis.py +26 -0
  143. hyfetch/distros/freebsd.py +22 -0
  144. hyfetch/distros/freebsd_small.py +13 -0
  145. hyfetch/distros/freemint.py +22 -0
  146. hyfetch/distros/frugalware.py +30 -0
  147. hyfetch/distros/funtoo.py +17 -0
  148. hyfetch/distros/galliumos.py +26 -0
  149. hyfetch/distros/garuda.py +26 -0
  150. hyfetch/distros/garuda_small.py +12 -0
  151. hyfetch/distros/gentoo.py +25 -0
  152. hyfetch/distros/gentoo_small.py +14 -0
  153. hyfetch/distros/ghostbsd.py +20 -0
  154. hyfetch/distros/glaucus.py +19 -0
  155. hyfetch/distros/gnewsense.py +19 -0
  156. hyfetch/distros/gnome.py +28 -0
  157. hyfetch/distros/gnu.py +25 -0
  158. hyfetch/distros/gobolinux.py +13 -0
  159. hyfetch/distros/grapheneos.py +30 -0
  160. hyfetch/distros/grombyang.py +25 -0
  161. hyfetch/distros/guix.py +17 -0
  162. hyfetch/distros/guix_small.py +14 -0
  163. hyfetch/distros/haiku.py +21 -0
  164. hyfetch/distros/haiku_small.py +15 -0
  165. hyfetch/distros/hamonikr.py +31 -0
  166. hyfetch/distros/hardclanz.py +26 -0
  167. hyfetch/distros/hash.py +22 -0
  168. hyfetch/distros/huayra.py +24 -0
  169. hyfetch/distros/hybrid.py +23 -0
  170. hyfetch/distros/hydroos.py +16 -0
  171. hyfetch/distros/hyperbola.py +23 -0
  172. hyfetch/distros/hyperbola_small.py +14 -0
  173. hyfetch/distros/iglunix.py +19 -0
  174. hyfetch/distros/instantos.py +29 -0
  175. hyfetch/distros/interix.py +24 -0
  176. hyfetch/distros/irix.py +26 -0
  177. hyfetch/distros/ironclad.py +19 -0
  178. hyfetch/distros/itc.py +18 -0
  179. hyfetch/distros/januslinux.py +31 -0
  180. hyfetch/distros/kaisen.py +25 -0
  181. hyfetch/distros/kali.py +28 -0
  182. hyfetch/distros/kali_small.py +23 -0
  183. hyfetch/distros/kaos.py +23 -0
  184. hyfetch/distros/kde.py +26 -0
  185. hyfetch/distros/kibojoe.py +20 -0
  186. hyfetch/distros/kogaion.py +27 -0
  187. hyfetch/distros/korora.py +23 -0
  188. hyfetch/distros/krassos.py +26 -0
  189. hyfetch/distros/kslinux.py +18 -0
  190. hyfetch/distros/kubuntu.py +27 -0
  191. hyfetch/distros/lainos.py +27 -0
  192. hyfetch/distros/langitketujuh.py +20 -0
  193. hyfetch/distros/langitketujuh_old.py +22 -0
  194. hyfetch/distros/laxeros.py +28 -0
  195. hyfetch/distros/lede.py +16 -0
  196. hyfetch/distros/libreelec.py +27 -0
  197. hyfetch/distros/linspire.py +19 -0
  198. hyfetch/distros/linux.py +19 -0
  199. hyfetch/distros/linux_lite.py +27 -0
  200. hyfetch/distros/linux_mint.py +26 -0
  201. hyfetch/distros/linux_mint_old.py +23 -0
  202. hyfetch/distros/linux_small.py +14 -0
  203. hyfetch/distros/linuxlite_small.py +14 -0
  204. hyfetch/distros/linuxmint_small.py +14 -0
  205. hyfetch/distros/live_raizo.py +27 -0
  206. hyfetch/distros/lmde.py +24 -0
  207. hyfetch/distros/lubuntu.py +27 -0
  208. hyfetch/distros/lunar.py +20 -0
  209. hyfetch/distros/mac.py +24 -0
  210. hyfetch/distros/mac_small.py +15 -0
  211. hyfetch/distros/macaronios.py +29 -0
  212. hyfetch/distros/mageia.py +26 -0
  213. hyfetch/distros/mageia_small.py +14 -0
  214. hyfetch/distros/magix.py +26 -0
  215. hyfetch/distros/magpieos.py +27 -0
  216. hyfetch/distros/mainsailos.py +25 -0
  217. hyfetch/distros/mainsailos_small.py +14 -0
  218. hyfetch/distros/mandriva.py +22 -0
  219. hyfetch/distros/manjaro.py +21 -0
  220. hyfetch/distros/manjaro_small.py +14 -0
  221. hyfetch/distros/massos.py +25 -0
  222. hyfetch/distros/matuusos.py +28 -0
  223. hyfetch/distros/maui.py +27 -0
  224. hyfetch/distros/meowix.py +17 -0
  225. hyfetch/distros/mer.py +34 -0
  226. hyfetch/distros/minix.py +24 -0
  227. hyfetch/distros/miracle_linux.py +23 -0
  228. hyfetch/distros/mx.py +24 -0
  229. hyfetch/distros/mx_small.py +14 -0
  230. hyfetch/distros/namib.py +27 -0
  231. hyfetch/distros/nekos.py +31 -0
  232. hyfetch/distros/neptune.py +24 -0
  233. hyfetch/distros/netbsd.py +24 -0
  234. hyfetch/distros/netbsd_small.py +14 -0
  235. hyfetch/distros/netrunner.py +27 -0
  236. hyfetch/distros/nitrux.py +25 -0
  237. hyfetch/distros/nixos.py +27 -0
  238. hyfetch/distros/nixos_colorful.py +27 -0
  239. hyfetch/distros/nixos_old.py +35 -0
  240. hyfetch/distros/nixos_small.py +14 -0
  241. hyfetch/distros/nobara.py +24 -0
  242. hyfetch/distros/nomadbsd.py +20 -0
  243. hyfetch/distros/nurunner.py +26 -0
  244. hyfetch/distros/nutyx.py +30 -0
  245. hyfetch/distros/obarun.py +26 -0
  246. hyfetch/distros/obrevenge.py +25 -0
  247. hyfetch/distros/omnios.py +16 -0
  248. hyfetch/distros/open_source_media_center.py +27 -0
  249. hyfetch/distros/openbsd.py +30 -0
  250. hyfetch/distros/openbsd_small.py +14 -0
  251. hyfetch/distros/openeuler.py +30 -0
  252. hyfetch/distros/openindiana.py +23 -0
  253. hyfetch/distros/openkylin.py +25 -0
  254. hyfetch/distros/openmamba.py +28 -0
  255. hyfetch/distros/openmandriva.py +29 -0
  256. hyfetch/distros/openstage.py +24 -0
  257. hyfetch/distros/opensuse.py +25 -0
  258. hyfetch/distros/opensuse_leap.py +23 -0
  259. hyfetch/distros/opensuse_small.py +14 -0
  260. hyfetch/distros/opensuse_tumbleweed.py +20 -0
  261. hyfetch/distros/opnsense.py +27 -0
  262. hyfetch/distros/oracle.py +19 -0
  263. hyfetch/distros/orchid.py +27 -0
  264. hyfetch/distros/orchid_small.py +20 -0
  265. hyfetch/distros/os_elbrus.py +21 -0
  266. hyfetch/distros/pacbsd.py +31 -0
  267. hyfetch/distros/panwah.py +29 -0
  268. hyfetch/distros/parabola.py +23 -0
  269. hyfetch/distros/parabola_small.py +13 -0
  270. hyfetch/distros/parch.py +32 -0
  271. hyfetch/distros/pardus.py +25 -0
  272. hyfetch/distros/parrot.py +31 -0
  273. hyfetch/distros/parsix.py +28 -0
  274. hyfetch/distros/pcbsd.py +34 -0
  275. hyfetch/distros/pclinuxos.py +26 -0
  276. hyfetch/distros/pearos.py +28 -0
  277. hyfetch/distros/pengwin.py +22 -0
  278. hyfetch/distros/pentoo.py +27 -0
  279. hyfetch/distros/peppermint.py +28 -0
  280. hyfetch/distros/peropesis.py +12 -0
  281. hyfetch/distros/phyos.py +24 -0
  282. hyfetch/distros/pikaos.py +36 -0
  283. hyfetch/distros/pisi.py +26 -0
  284. hyfetch/distros/pnm_linux.py +28 -0
  285. hyfetch/distros/pop__os.py +27 -0
  286. hyfetch/distros/popos_small.py +15 -0
  287. hyfetch/distros/porteus.py +30 -0
  288. hyfetch/distros/postmarketos.py +25 -0
  289. hyfetch/distros/postmarketos_small.py +16 -0
  290. hyfetch/distros/profelis_sambabox.py +27 -0
  291. hyfetch/distros/proxmox.py +27 -0
  292. hyfetch/distros/puffos.py +20 -0
  293. hyfetch/distros/puppy.py +25 -0
  294. hyfetch/distros/pureos.py +19 -0
  295. hyfetch/distros/pureos_small.py +13 -0
  296. hyfetch/distros/q4os.py +26 -0
  297. hyfetch/distros/qubes.py +28 -0
  298. hyfetch/distros/qubyt.py +22 -0
  299. hyfetch/distros/quibian.py +25 -0
  300. hyfetch/distros/radix.py +25 -0
  301. hyfetch/distros/raspbian.py +30 -0
  302. hyfetch/distros/raspbian_small.py +16 -0
  303. hyfetch/distros/ravynos.py +27 -0
  304. hyfetch/distros/reborn_os.py +27 -0
  305. hyfetch/distros/red_star.py +25 -0
  306. hyfetch/distros/redcore.py +23 -0
  307. hyfetch/distros/redhat.py +25 -0
  308. hyfetch/distros/redhat_old.py +23 -0
  309. hyfetch/distros/refracted_devuan.py +25 -0
  310. hyfetch/distros/regata.py +27 -0
  311. hyfetch/distros/regolith.py +26 -0
  312. hyfetch/distros/rhaymos.py +22 -0
  313. hyfetch/distros/rocky.py +26 -0
  314. hyfetch/distros/rocky_small.py +19 -0
  315. hyfetch/distros/rosa.py +27 -0
  316. hyfetch/distros/sabayon.py +25 -0
  317. hyfetch/distros/sabotage.py +18 -0
  318. hyfetch/distros/sailfish.py +20 -0
  319. hyfetch/distros/salentos.py +27 -0
  320. hyfetch/distros/salient_os.py +27 -0
  321. hyfetch/distros/salix.py +27 -0
  322. hyfetch/distros/sasanqua.py +27 -0
  323. hyfetch/distros/scientific.py +27 -0
  324. hyfetch/distros/semc.py +16 -0
  325. hyfetch/distros/septor.py +27 -0
  326. hyfetch/distros/serene.py +27 -0
  327. hyfetch/distros/sharklinux.py +22 -0
  328. hyfetch/distros/shastraos.py +26 -0
  329. hyfetch/distros/siduction.py +27 -0
  330. hyfetch/distros/skiffos.py +17 -0
  331. hyfetch/distros/slackel.py +29 -0
  332. hyfetch/distros/slackware.py +28 -0
  333. hyfetch/distros/slackware_small.py +14 -0
  334. hyfetch/distros/slitaz.py +24 -0
  335. hyfetch/distros/smartos.py +24 -0
  336. hyfetch/distros/soda.py +22 -0
  337. hyfetch/distros/solus.py +27 -0
  338. hyfetch/distros/source_mage.py +28 -0
  339. hyfetch/distros/sparky.py +28 -0
  340. hyfetch/distros/star.py +26 -0
  341. hyfetch/distros/steamos.py +25 -0
  342. hyfetch/distros/stock_linux.py +28 -0
  343. hyfetch/distros/sulin.py +28 -0
  344. hyfetch/distros/sunos.py +15 -0
  345. hyfetch/distros/sunos_small.py +12 -0
  346. hyfetch/distros/swagarch.py +22 -0
  347. hyfetch/distros/t2.py +14 -0
  348. hyfetch/distros/tails.py +26 -0
  349. hyfetch/distros/tatra.py +23 -0
  350. hyfetch/distros/tearch.py +28 -0
  351. hyfetch/distros/torizoncore.py +36 -0
  352. hyfetch/distros/trisquel.py +24 -0
  353. hyfetch/distros/twister.py +30 -0
  354. hyfetch/distros/ubuntu.py +28 -0
  355. hyfetch/distros/ubuntu_budgie.py +27 -0
  356. hyfetch/distros/ubuntu_cinnamon.py +27 -0
  357. hyfetch/distros/ubuntu_gnome.py +23 -0
  358. hyfetch/distros/ubuntu_kylin.py +27 -0
  359. hyfetch/distros/ubuntu_mate.py +27 -0
  360. hyfetch/distros/ubuntu_old.py +27 -0
  361. hyfetch/distros/ubuntu_old02.py +25 -0
  362. hyfetch/distros/ubuntu_small.py +18 -0
  363. hyfetch/distros/ubuntu_studio.py +27 -0
  364. hyfetch/distros/ubuntu_sway.py +27 -0
  365. hyfetch/distros/ubuntu_touch.py +15 -0
  366. hyfetch/distros/ultramarine_linux.py +27 -0
  367. hyfetch/distros/unicodearch.py +26 -0
  368. hyfetch/distros/univalent.py +26 -0
  369. hyfetch/distros/univention.py +27 -0
  370. hyfetch/distros/uos.py +28 -0
  371. hyfetch/distros/urukos.py +27 -0
  372. hyfetch/distros/uwuntu.py +27 -0
  373. hyfetch/distros/vanilla.py +27 -0
  374. hyfetch/distros/venom.py +27 -0
  375. hyfetch/distros/venom_small.py +18 -0
  376. hyfetch/distros/vnux.py +27 -0
  377. hyfetch/distros/void.py +32 -0
  378. hyfetch/distros/void_small.py +14 -0
  379. hyfetch/distros/vzlinux.py +27 -0
  380. hyfetch/distros/wii_linux_ngx.py +23 -0
  381. hyfetch/distros/windows.py +23 -0
  382. hyfetch/distros/windows95.py +25 -0
  383. hyfetch/distros/windows_10.py +26 -0
  384. hyfetch/distros/windows_11.py +23 -0
  385. hyfetch/distros/wrt.py +16 -0
  386. hyfetch/distros/xenia.py +34 -0
  387. hyfetch/distros/xenia2.py +28 -0
  388. hyfetch/distros/xferience.py +26 -0
  389. hyfetch/distros/xray_os.py +28 -0
  390. hyfetch/distros/xubuntu.py +27 -0
  391. hyfetch/distros/yiffos.py +26 -0
  392. hyfetch/distros/zorin.py +24 -0
  393. hyfetch/fastfetch/LICENSE +22 -0
  394. hyfetch/fastfetch/OpenCL.dll +0 -0
  395. hyfetch/fastfetch/amd_ags_x86.dll +0 -0
  396. hyfetch/fastfetch/fastfetch.exe +0 -0
  397. hyfetch/fastfetch/flashfetch.exe +0 -0
  398. hyfetch/fastfetch/presets/all.jsonc +108 -0
  399. hyfetch/fastfetch/presets/archey.jsonc +82 -0
  400. hyfetch/fastfetch/presets/ci.jsonc +110 -0
  401. hyfetch/fastfetch/presets/examples/10.jsonc +157 -0
  402. hyfetch/fastfetch/presets/examples/11.jsonc +40 -0
  403. hyfetch/fastfetch/presets/examples/12.jsonc +115 -0
  404. hyfetch/fastfetch/presets/examples/13.jsonc +85 -0
  405. hyfetch/fastfetch/presets/examples/14.jsonc +88 -0
  406. hyfetch/fastfetch/presets/examples/15.jsonc +85 -0
  407. hyfetch/fastfetch/presets/examples/16.jsonc +85 -0
  408. hyfetch/fastfetch/presets/examples/17.jsonc +87 -0
  409. hyfetch/fastfetch/presets/examples/18.jsonc +87 -0
  410. hyfetch/fastfetch/presets/examples/19.jsonc +189 -0
  411. hyfetch/fastfetch/presets/examples/2.jsonc +88 -0
  412. hyfetch/fastfetch/presets/examples/20.jsonc +164 -0
  413. hyfetch/fastfetch/presets/examples/21.jsonc +48 -0
  414. hyfetch/fastfetch/presets/examples/22.jsonc +113 -0
  415. hyfetch/fastfetch/presets/examples/23.jsonc +63 -0
  416. hyfetch/fastfetch/presets/examples/24.jsonc +152 -0
  417. hyfetch/fastfetch/presets/examples/3.jsonc +24 -0
  418. hyfetch/fastfetch/presets/examples/4.jsonc +33 -0
  419. hyfetch/fastfetch/presets/examples/5.jsonc +27 -0
  420. hyfetch/fastfetch/presets/examples/6.jsonc +179 -0
  421. hyfetch/fastfetch/presets/examples/7.jsonc +138 -0
  422. hyfetch/fastfetch/presets/examples/8.jsonc +41 -0
  423. hyfetch/fastfetch/presets/examples/9.jsonc +38 -0
  424. hyfetch/fastfetch/presets/neofetch.jsonc +48 -0
  425. hyfetch/fastfetch/presets/paleofetch.jsonc +32 -0
  426. hyfetch/fastfetch/presets/screenfetch.jsonc +37 -0
  427. hyfetch/fastfetch/vulkan-1.dll +0 -0
  428. hyfetch/font_logo.py +37 -0
  429. hyfetch/git/bin/bash.exe +0 -0
  430. hyfetch/git/etc/DIR_COLORS +207 -0
  431. hyfetch/git/etc/bash.bash_logout +15 -0
  432. hyfetch/git/etc/bash.bashrc +65 -0
  433. hyfetch/git/etc/docx2txt.config +70 -0
  434. hyfetch/git/etc/fstab +6 -0
  435. hyfetch/git/etc/gitattributes +23 -0
  436. hyfetch/git/etc/gitconfig +21 -0
  437. hyfetch/git/etc/hosts +31 -0
  438. hyfetch/git/etc/inputrc +82 -0
  439. hyfetch/git/etc/msystem +84 -0
  440. hyfetch/git/etc/mtab +1 -0
  441. hyfetch/git/etc/nanorc +331 -0
  442. hyfetch/git/etc/networks +17 -0
  443. hyfetch/git/etc/nsswitch.conf +12 -0
  444. hyfetch/git/etc/package-versions.txt +162 -0
  445. hyfetch/git/etc/pkcs11/pkcs11.conf.example +9 -0
  446. hyfetch/git/etc/pki/ca-trust/extracted/java/cacerts +0 -0
  447. hyfetch/git/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt +4062 -0
  448. hyfetch/git/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem +2671 -0
  449. hyfetch/git/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem +0 -0
  450. hyfetch/git/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem +3466 -0
  451. hyfetch/git/etc/profile +176 -0
  452. hyfetch/git/etc/profile.d/aliases.sh +21 -0
  453. hyfetch/git/etc/profile.d/bash_profile.sh +11 -0
  454. hyfetch/git/etc/profile.d/env.sh +32 -0
  455. hyfetch/git/etc/profile.d/git-prompt.sh +50 -0
  456. hyfetch/git/etc/profile.d/lang.sh +19 -0
  457. hyfetch/git/etc/profile.d/perlbin.csh +15 -0
  458. hyfetch/git/etc/profile.d/perlbin.sh +17 -0
  459. hyfetch/git/etc/protocols +158 -0
  460. hyfetch/git/etc/services +2493 -0
  461. hyfetch/git/etc/ssh/moduli +455 -0
  462. hyfetch/git/etc/ssh/ssh_config +54 -0
  463. hyfetch/git/etc/ssh/sshd_config +116 -0
  464. hyfetch/git/etc/tigrc +483 -0
  465. hyfetch/git/etc/vimrc +55 -0
  466. hyfetch/git/mingw32/bin/Atlassian.Bitbucket.dll +0 -0
  467. hyfetch/git/mingw32/bin/HarfBuzzSharp.dll +0 -0
  468. hyfetch/git/mingw32/bin/MicroCom.Runtime.dll +0 -0
  469. hyfetch/git/mingw32/bin/Microsoft.AzureRepos.dll +0 -0
  470. hyfetch/git/mingw32/bin/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  471. hyfetch/git/mingw32/bin/System.Buffers.dll +0 -0
  472. hyfetch/git/mingw32/bin/System.CommandLine.dll +0 -0
  473. hyfetch/git/mingw32/bin/System.ComponentModel.Annotations.dll +0 -0
  474. hyfetch/git/mingw32/bin/System.Drawing.Common.dll +0 -0
  475. hyfetch/git/mingw32/bin/System.Memory.dll +0 -0
  476. hyfetch/git/mingw32/bin/System.Numerics.Vectors.dll +0 -0
  477. hyfetch/git/mingw32/bin/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  478. hyfetch/git/mingw32/bin/System.Text.Encodings.Web.dll +0 -0
  479. hyfetch/git/mingw32/bin/System.Threading.Tasks.Extensions.dll +0 -0
  480. hyfetch/git/mingw32/bin/System.ValueTuple.dll +0 -0
  481. hyfetch/git/mingw32/bin/WhoUses.exe +0 -0
  482. hyfetch/git/mingw32/bin/adig.exe +0 -0
  483. hyfetch/git/mingw32/bin/ahost.exe +0 -0
  484. hyfetch/git/mingw32/bin/antiword.exe +0 -0
  485. hyfetch/git/mingw32/bin/blocked-file-util.exe +0 -0
  486. hyfetch/git/mingw32/bin/bunzip2.exe +0 -0
  487. hyfetch/git/mingw32/bin/c_rehash +252 -0
  488. hyfetch/git/mingw32/bin/connect.exe +0 -0
  489. hyfetch/git/mingw32/bin/create-shortcut.exe +0 -0
  490. hyfetch/git/mingw32/bin/edit.dll +0 -0
  491. hyfetch/git/mingw32/bin/edit_test.exe +0 -0
  492. hyfetch/git/mingw32/bin/edit_test_dll.exe +0 -0
  493. hyfetch/git/mingw32/bin/envsubst.exe +0 -0
  494. hyfetch/git/mingw32/bin/gettext.exe +0 -0
  495. hyfetch/git/mingw32/bin/gettext.sh +135 -0
  496. hyfetch/git/mingw32/bin/i686-w64-mingw32-agrep.exe +0 -0
  497. hyfetch/git/mingw32/bin/libcares-2.dll +0 -0
  498. hyfetch/git/mingw32/bin/libexpat-1.dll +0 -0
  499. hyfetch/git/mingw32/bin/libgcc_s_dw2-1.dll +0 -0
  500. hyfetch/git/mingw32/bin/libhogweed-6.dll +0 -0
  501. hyfetch/git/mingw32/bin/libidn2-0.dll +0 -0
  502. hyfetch/git/mingw32/bin/libintl-8.dll +0 -0
  503. hyfetch/git/mingw32/bin/liblzma-5.dll +0 -0
  504. hyfetch/git/mingw32/bin/libnettle-8.dll +0 -0
  505. hyfetch/git/mingw32/bin/libnghttp2-14.dll +0 -0
  506. hyfetch/git/mingw32/bin/libpcre-1.dll +0 -0
  507. hyfetch/git/mingw32/bin/libpcre2-8-0.dll +0 -0
  508. hyfetch/git/mingw32/bin/libpcreposix-0.dll +0 -0
  509. hyfetch/git/mingw32/bin/libpsl-5.dll +0 -0
  510. hyfetch/git/mingw32/bin/libssh2-1.dll +0 -0
  511. hyfetch/git/mingw32/bin/libstdc++-6.dll +0 -0
  512. hyfetch/git/mingw32/bin/libtre-5.dll +0 -0
  513. hyfetch/git/mingw32/bin/libunistring-5.dll +0 -0
  514. hyfetch/git/mingw32/bin/libwinpthread-1.dll +0 -0
  515. hyfetch/git/mingw32/bin/lzmadec.exe +0 -0
  516. hyfetch/git/mingw32/bin/lzmainfo.exe +0 -0
  517. hyfetch/git/mingw32/bin/msalruntime_x86.dll +0 -0
  518. hyfetch/git/mingw32/bin/odt2txt.exe +0 -0
  519. hyfetch/git/mingw32/bin/pcre2-config +121 -0
  520. hyfetch/git/mingw32/bin/pkcs1-conv.exe +0 -0
  521. hyfetch/git/mingw32/bin/proxy-lookup.exe +0 -0
  522. hyfetch/git/mingw32/bin/psl-make-dafsa +692 -0
  523. hyfetch/git/mingw32/bin/psl.exe +0 -0
  524. hyfetch/git/mingw32/bin/sexp-conv.exe +0 -0
  525. hyfetch/git/mingw32/bin/sqlite3_analyzer.sh +899 -0
  526. hyfetch/git/mingw32/bin/tk86.dll +0 -0
  527. hyfetch/git/mingw32/bin/unxz.exe +0 -0
  528. hyfetch/git/mingw32/bin/update-ca-trust +18 -0
  529. hyfetch/git/mingw32/bin/wish.exe +0 -0
  530. hyfetch/git/mingw32/bin/wish86.exe +0 -0
  531. hyfetch/git/mingw32/bin/xmlwf.exe +0 -0
  532. hyfetch/git/mingw32/bin/zlib1.dll +0 -0
  533. hyfetch/git/usr/bin/awk.exe +0 -0
  534. hyfetch/git/usr/bin/bash.exe +0 -0
  535. hyfetch/git/usr/bin/cygpath.exe +0 -0
  536. hyfetch/git/usr/bin/dirname.exe +0 -0
  537. hyfetch/git/usr/bin/grep.exe +0 -0
  538. hyfetch/git/usr/bin/id.exe +0 -0
  539. hyfetch/git/usr/bin/msys-2.0.dll +0 -0
  540. hyfetch/git/usr/bin/msys-gcc_s-1.dll +0 -0
  541. hyfetch/git/usr/bin/msys-gmp-10.dll +0 -0
  542. hyfetch/git/usr/bin/msys-iconv-2.dll +0 -0
  543. hyfetch/git/usr/bin/msys-intl-8.dll +0 -0
  544. hyfetch/git/usr/bin/msys-mpfr-6.dll +0 -0
  545. hyfetch/git/usr/bin/msys-ncursesw6.dll +0 -0
  546. hyfetch/git/usr/bin/msys-pcre-1.dll +0 -0
  547. hyfetch/git/usr/bin/msys-readline8.dll +0 -0
  548. hyfetch/git/usr/bin/sed.exe +0 -0
  549. hyfetch/git/usr/bin/sort.exe +0 -0
  550. hyfetch/git/usr/bin/uname.exe +0 -0
  551. hyfetch/git/usr/bin/uniq.exe +0 -0
  552. hyfetch/git/usr/bin/wc.exe +0 -0
  553. hyfetch/git/usr/etc/profile.d/gawk.csh +11 -0
  554. hyfetch/git/usr/etc/profile.d/gawk.sh +31 -0
  555. hyfetch/main.py +470 -0
  556. hyfetch/models.py +31 -0
  557. hyfetch/neofetch_util.py +429 -0
  558. hyfetch/presets.py +967 -0
  559. hyfetch/pride_month.py +127 -0
  560. hyfetch/scripts/autocomplete.bash +142 -0
  561. hyfetch/scripts/autocomplete.csh +14 -0
  562. hyfetch/scripts/autocomplete.zsh +51 -0
  563. hyfetch/scripts/install-autocomplete.sh +62 -0
  564. hyfetch/scripts/neowofetch +15954 -0
  565. hyfetch/serializer.py +48 -0
  566. hyfetch/termenv.py +171 -0
  567. hyfetch/types.py +10 -0
@@ -0,0 +1,692 @@
1
+ #!/usr/bin/env python
2
+ # Copyright 2014 The Chromium Authors. All rights reserved.
3
+ # Use of this source code is governed by a BSD-style license that can be
4
+ # found in the LICENSE.chromium file.
5
+
6
+ """
7
+ A Deterministic acyclic finite state automaton (DAFSA) is a compact
8
+ representation of an unordered word list (dictionary).
9
+
10
+ https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton
11
+
12
+ This python program converts a list of strings to a byte array in C/C++.
13
+ This python program fetches strings and return values from a gperf file
14
+ and generates a C/C++ file with a byte array representing graph that can be
15
+ used as a memory efficient replacement for the perfect hash table.
16
+
17
+ The input strings must consist of printable 7-bit ASCII characters or UTF-8
18
+ multibyte sequences. Control characters in the range [0x00-0x1F] are not
19
+ allowed. The return values must be one digit integers. .
20
+
21
+ In this program a DAFSA is a diamond shaped graph starting at a common
22
+ source node and ending at a common sink node. All internal nodes contain
23
+ a label and each word is represented by the labels in one path from
24
+ the source node to the sink node.
25
+
26
+ The following python represention is used for nodes:
27
+
28
+ Source node: [ children ]
29
+ Internal node: (label, [ children ])
30
+ Sink node: None
31
+
32
+ The graph is first compressed by prefixes like a trie. In the next step
33
+ suffixes are compressed so that the graph gets diamond shaped. Finally
34
+ one to one linked nodes are replaced by nodes with the labels joined.
35
+
36
+ The order of the operations is crucial since lookups will be performed
37
+ starting from the source with no backtracking. Thus a node must have at
38
+ most one child with a label starting by the same character. The output
39
+ is also arranged so that all jumps are to increasing addresses, thus forward
40
+ in memory.
41
+
42
+ The generated output has suffix free decoding so that the sign of leading
43
+ bits in a link (a reference to a child node) indicate if it has a size of one,
44
+ two or three bytes and if it is the last outgoing link from the actual node.
45
+ A node label is terminated by a byte with the leading bit set.
46
+
47
+ The generated byte array can described by the following BNF:
48
+
49
+ <byte> ::= < 8-bit value in range [0x00-0xFF] >
50
+
51
+ <char> ::= < byte in range [0x1F-0x7F] >
52
+ <end_char> ::= < char + 0x80, byte in range [0x9F-0xFF] >
53
+ <return value> ::= < value + 0x80, byte in range [0x80-0x8F] >
54
+
55
+ <offset1> ::= < byte in range [0x00-0x3F] >
56
+ <offset2> ::= < byte in range [0x40-0x5F] >
57
+ <offset3> ::= < byte in range [0x60-0x7F] >
58
+
59
+ <end_offset1> ::= < byte in range [0x80-0xBF] >
60
+ <end_offset2> ::= < byte in range [0xC0-0xDF] >
61
+ <end_offset3> ::= < byte in range [0xE0-0xFF] >
62
+
63
+ <prefix> ::= <char>
64
+
65
+ <label> ::= <end_char>
66
+ | <char> <label>
67
+
68
+ <end_label> ::= <return_value>
69
+ | <char> <end_label>
70
+
71
+ <offset> ::= <offset1>
72
+ | <offset2> <byte>
73
+ | <offset3> <byte> <byte>
74
+
75
+ <end_offset> ::= <end_offset1>
76
+ | <end_offset2> <byte>
77
+ | <end_offset3> <byte> <byte>
78
+
79
+ <offsets> ::= <end_offset>
80
+ | <offset> <offsets>
81
+
82
+ <source> ::= <offsets>
83
+
84
+ <node> ::= <label> <offsets>
85
+ | <prefix> <node>
86
+ | <end_label>
87
+
88
+ <graph> ::= <graph>
89
+ | <graph> <node>
90
+
91
+ <version> ::= <empty> # The DAFSA was generated in ASCII mode.
92
+ | < byte value 0x01 > # The DAFSA was generated in UTF-8 mode.
93
+
94
+ <dafsa> ::= <graph> <version>
95
+
96
+ Decoding:
97
+
98
+ <char> -> character
99
+ <end_char> & 0x7F -> character
100
+ <return value> & 0x0F -> integer
101
+ <offset1 & 0x3F> -> integer
102
+ ((<offset2> & 0x1F>) << 8) + <byte> -> integer
103
+ ((<offset3> & 0x1F>) << 16) + (<byte> << 8) + <byte> -> integer
104
+
105
+ end_offset1, end_offset2 and and_offset3 are decoded same as offset1,
106
+ offset2 and offset3 respectively.
107
+
108
+ The first offset in a list of offsets is the distance in bytes between the
109
+ offset itself and the first child node. Subsequent offsets are the distance
110
+ between previous child node and next child node. Thus each offset links a node
111
+ to a child node. The distance is always counted between start addresses, i.e.
112
+ first byte in decoded offset or first byte in child node.
113
+
114
+ Transcoding of UTF-8 multibyte sequences:
115
+
116
+ The original DAFSA format was limited to 7-bit printable ASCII characters in
117
+ range [0x20-0xFF], but has been extended to allow UTF-8 multibyte sequences.
118
+ By transcoding of such characters the new format preserves compatibility with
119
+ old parsers, so that a DAFSA in the extended format can be used by an old
120
+ parser without false positives, although strings containing transcoded
121
+ characters will never match. Since the format is extended rather than being
122
+ changed, a parser supporting the new format will automatically support data
123
+ generated in the old format.
124
+
125
+ Transcoding is performed by insertion of a start byte with the special value
126
+ 0x1F, followed by 2-4 bytes shifted into the range [0x40-0x7F], thus inside
127
+ the range of printable ASCII.
128
+
129
+ 2-byte: 110nnnnn, 10nnnnnn -> 00011111, 010nnnnn, 01nnnnnn
130
+
131
+ 3-byte: 1110nnnn, 10nnnnnn, 10nnnnnn -> 00011111, 0110nnnn, 01nnnnnn, 01nnnnnn
132
+
133
+ 4-byte: 11110nnn, 10nnnnnn, 10nnnnnn, 10nnnnnn ->
134
+ 00011111, 01110nnn, 01nnnnnn, 01nnnnnn, 01nnnnnn
135
+
136
+ Example 1:
137
+
138
+ %%
139
+ aa, 1
140
+ a, 2
141
+ %%
142
+
143
+ The input is first parsed to a list of words:
144
+ ["aa1", "a2"]
145
+
146
+ A fully expanded graph is created from the words:
147
+ source = [node1, node4]
148
+ node1 = ("a", [node2])
149
+ node2 = ("a", [node3])
150
+ node3 = ("\x01", [sink])
151
+ node4 = ("a", [node5])
152
+ node5 = ("\x02", [sink])
153
+ sink = None
154
+
155
+ Compression results in the following graph:
156
+ source = [node1]
157
+ node1 = ("a", [node2, node3])
158
+ node2 = ("\x02", [sink])
159
+ node3 = ("a\x01", [sink])
160
+ sink = None
161
+
162
+ A C/C++ representation of the compressed graph is generated:
163
+
164
+ const unsigned char dafsa[7] = {
165
+ 0x81, 0xE1, 0x02, 0x81, 0x82, 0x61, 0x81,
166
+ };
167
+
168
+ The bytes in the generated array has the following meaning:
169
+
170
+ 0: 0x81 <end_offset1> child at position 0 + (0x81 & 0x3F) -> jump to 1
171
+
172
+ 1: 0xE1 <end_char> label character (0xE1 & 0x7F) -> match "a"
173
+ 2: 0x02 <offset1> child at position 2 + (0x02 & 0x3F) -> jump to 4
174
+
175
+ 3: 0x81 <end_offset1> child at position 4 + (0x81 & 0x3F) -> jump to 5
176
+ 4: 0x82 <return_value> 0x82 & 0x0F -> return 2
177
+
178
+ 5: 0x61 <char> label character 0x61 -> match "a"
179
+ 6: 0x81 <return_value> 0x81 & 0x0F -> return 1
180
+
181
+ Example 2:
182
+
183
+ %%
184
+ aa, 1
185
+ bbb, 2
186
+ baa, 1
187
+ %%
188
+
189
+ The input is first parsed to a list of words:
190
+ ["aa1", "bbb2", "baa1"]
191
+
192
+ Compression results in the following graph:
193
+ source = [node1, node2]
194
+ node1 = ("b", [node2, node3])
195
+ node2 = ("aa\x01", [sink])
196
+ node3 = ("bb\x02", [sink])
197
+ sink = None
198
+
199
+ A C/C++ representation of the compressed graph is generated:
200
+
201
+ const unsigned char dafsa[11] = {
202
+ 0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62, 0x82,
203
+ };
204
+
205
+ The bytes in the generated array has the following meaning:
206
+
207
+ 0: 0x02 <offset1> child at position 0 + (0x02 & 0x3F) -> jump to 2
208
+ 1: 0x83 <end_offset1> child at position 2 + (0x83 & 0x3F) -> jump to 5
209
+
210
+ 2: 0xE2 <end_char> label character (0xE2 & 0x7F) -> match "b"
211
+ 3: 0x02 <offset1> child at position 3 + (0x02 & 0x3F) -> jump to 5
212
+ 4: 0x83 <end_offset1> child at position 5 + (0x83 & 0x3F) -> jump to 8
213
+
214
+ 5: 0x61 <char> label character 0x61 -> match "a"
215
+ 6: 0x61 <char> label character 0x61 -> match "a"
216
+ 7: 0x81 <return_value> 0x81 & 0x0F -> return 1
217
+
218
+ 8: 0x62 <char> label character 0x62 -> match "b"
219
+ 9: 0x62 <char> label character 0x62 -> match "b"
220
+ 10: 0x82 <return_value> 0x82 & 0x0F -> return 2
221
+ """
222
+
223
+ import sys
224
+ import os.path
225
+ import hashlib
226
+
227
+ class InputError(Exception):
228
+ """Exception raised for errors in the input file."""
229
+
230
+ # Length of a character starting at a given byte.
231
+ char_length_table = ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x00-0x0F
232
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x10-0x1F
233
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x20-0x2F
234
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x30-x03F
235
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x40-0x4F
236
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x50-x05F
237
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x60-0x6F
238
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 0x70-x07F
239
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x80-0x8F
240
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x90-0x9F
241
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0xA0-0xAF
242
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0xB0-0xBF
243
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, # 0xC0-0xCF
244
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, # 0xD0-0xDF
245
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, # 0xE0-0xEF
246
+ 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 ) # 0xF0-0xFF
247
+
248
+ def to_bytes(n):
249
+ """Converts an integer value to a bytes object."""
250
+ return bytes(bytearray((n,)))
251
+
252
+ def to_dafsa(words, utf_mode):
253
+ """Generates a DAFSA from a word list and returns the source node.
254
+
255
+ Each word is split into characters so that each character is represented by
256
+ a unique node. It is assumed the word list is not empty.
257
+ """
258
+ if not words:
259
+ raise InputError('The domain list must not be empty')
260
+ def to_nodes(word, multibyte_length):
261
+ """Split words into characters"""
262
+ byte = ord(word[:1])
263
+ if multibyte_length:
264
+ # Consume next byte in multibyte sequence.
265
+ if byte & 0xC0 != 0x80:
266
+ raise InputError('Invalid UTF-8 multibyte sequence')
267
+ return to_bytes(byte ^ 0xC0), [to_nodes(word[1:], multibyte_length - 1)]
268
+ char_length = char_length_table[byte]
269
+ if char_length == 1:
270
+ # 7-bit printable ASCII.
271
+ if len(word) == 1:
272
+ return to_bytes(int(word[:1], 16) & 0x0F), [None]
273
+ return word[:1], [to_nodes(word[1:], 0)]
274
+ elif char_length > 1:
275
+ # Leading byte in multibyte sequence.
276
+ if not utf_mode:
277
+ raise InputError('UTF-8 encoded characters are not allowed in ASCII mode')
278
+ if len(word) <= char_length:
279
+ raise InputError('Unterminated UTF-8 multibyte sequence')
280
+ return to_bytes(0x1F), [(to_bytes(byte ^ 0x80), [to_nodes(word[1:], char_length - 1)])]
281
+ # Unexpected character.
282
+ raise InputError('Domain names must be printable ASCII or UTF-8')
283
+
284
+ return [to_nodes(word, 0) for word in words]
285
+
286
+ def to_words(node):
287
+ """Generates a word list from all paths starting from an internal node."""
288
+ if not node:
289
+ return [b'']
290
+ return [(node[0] + word) for child in node[1] for word in to_words(child)]
291
+
292
+
293
+ def reverse(dafsa):
294
+ """Generates a new DAFSA that is reversed, so that the old sink node becomes
295
+ the new source node.
296
+ """
297
+ sink = []
298
+ nodemap = {}
299
+
300
+ def dfs(node, parent):
301
+ """Creates reverse nodes.
302
+
303
+ A new reverse node will be created for each old node. The new node will
304
+ get a reversed label and the parents of the old node as children.
305
+ """
306
+ if not node:
307
+ sink.append(parent)
308
+ elif id(node) not in nodemap:
309
+ nodemap[id(node)] = (node[0][::-1], [parent])
310
+ for child in node[1]:
311
+ dfs(child, nodemap[id(node)])
312
+ else:
313
+ nodemap[id(node)][1].append(parent)
314
+
315
+ for node in dafsa:
316
+ dfs(node, None)
317
+ return sink
318
+
319
+
320
+ def join_labels(dafsa):
321
+ """Generates a new DAFSA where internal nodes are merged if there is a one to
322
+ one connection.
323
+ """
324
+ parentcount = {id(None): 2}
325
+ nodemap = {id(None): None}
326
+
327
+ def count_parents(node):
328
+ """Count incoming references"""
329
+ if id(node) in parentcount:
330
+ parentcount[id(node)] += 1
331
+ else:
332
+ parentcount[id(node)] = 1
333
+ for child in node[1]:
334
+ count_parents(child)
335
+
336
+ def join(node):
337
+ """Create new nodes"""
338
+ if id(node) not in nodemap:
339
+ children = [join(child) for child in node[1]]
340
+ if len(children) == 1 and parentcount[id(node[1][0])] == 1:
341
+ child = children[0]
342
+ nodemap[id(node)] = (node[0] + child[0], child[1])
343
+ else:
344
+ nodemap[id(node)] = (node[0], children)
345
+ return nodemap[id(node)]
346
+
347
+ for node in dafsa:
348
+ count_parents(node)
349
+ return [join(node) for node in dafsa]
350
+
351
+
352
+ def join_suffixes(dafsa):
353
+ """Generates a new DAFSA where nodes that represent the same word lists
354
+ towards the sink are merged.
355
+ """
356
+ nodemap = {frozenset((b'',)): None}
357
+
358
+ def join(node):
359
+ """Returns a matching node. A new node is created if no matching node
360
+ exists. The graph is accessed in dfs order.
361
+ """
362
+ suffixes = frozenset(to_words(node))
363
+ if suffixes not in nodemap:
364
+ nodemap[suffixes] = (node[0], [join(child) for child in node[1]])
365
+ return nodemap[suffixes]
366
+
367
+ return [join(node) for node in dafsa]
368
+
369
+
370
+ def top_sort(dafsa):
371
+ """Generates list of nodes in topological sort order."""
372
+ incoming = {}
373
+
374
+ def count_incoming(node):
375
+ """Counts incoming references."""
376
+ if node:
377
+ if id(node) not in incoming:
378
+ incoming[id(node)] = 1
379
+ for child in node[1]:
380
+ count_incoming(child)
381
+ else:
382
+ incoming[id(node)] += 1
383
+
384
+ for node in dafsa:
385
+ count_incoming(node)
386
+
387
+ for node in dafsa:
388
+ incoming[id(node)] -= 1
389
+
390
+ waiting = [node for node in dafsa if incoming[id(node)] == 0]
391
+ nodes = []
392
+
393
+ while waiting:
394
+ node = waiting.pop()
395
+ assert incoming[id(node)] == 0
396
+ nodes.append(node)
397
+ for child in node[1]:
398
+ if child:
399
+ incoming[id(child)] -= 1
400
+ if incoming[id(child)] == 0:
401
+ waiting.append(child)
402
+ return nodes
403
+
404
+
405
+ def encode_links(children, offsets, current):
406
+ """Encodes a list of children as one, two or three byte offsets."""
407
+ if not children[0]:
408
+ # This is an <end_label> node and no links follow such nodes
409
+ assert len(children) == 1
410
+ return []
411
+ guess = 3 * len(children)
412
+ assert children
413
+ children = sorted(children, key=lambda x: -offsets[id(x)])
414
+ while True:
415
+ offset = current + guess
416
+ buf = []
417
+ for child in children:
418
+ last = len(buf)
419
+ distance = offset - offsets[id(child)]
420
+ assert distance > 0 and distance < (1 << 21)
421
+
422
+ if distance < (1 << 6):
423
+ # A 6-bit offset: "s0xxxxxx"
424
+ buf.append(distance)
425
+ elif distance < (1 << 13):
426
+ # A 13-bit offset: "s10xxxxxxxxxxxxx"
427
+ buf.append(0x40 | (distance >> 8))
428
+ buf.append(distance & 0xFF)
429
+ else:
430
+ # A 21-bit offset: "s11xxxxxxxxxxxxxxxxxxxxx"
431
+ buf.append(0x60 | (distance >> 16))
432
+ buf.append((distance >> 8) & 0xFF)
433
+ buf.append(distance & 0xFF)
434
+ # Distance in first link is relative to following record.
435
+ # Distance in other links are relative to previous link.
436
+ offset -= distance
437
+ if len(buf) == guess:
438
+ break
439
+ guess = len(buf)
440
+ # Set most significant bit to mark end of links in this node.
441
+ buf[last] |= (1 << 7)
442
+ buf.reverse()
443
+ return buf
444
+
445
+
446
+ def encode_prefix(label):
447
+ """Encodes a node label as a list of bytes without a trailing high byte.
448
+
449
+ This method encodes a node if there is exactly one child and the
450
+ child follows immediately after so that no jump is needed. This label
451
+ will then be a prefix to the label in the child node.
452
+ """
453
+ assert label
454
+ return [c for c in bytearray(reversed(label))]
455
+
456
+
457
+ def encode_label(label):
458
+ """Encodes a node label as a list of bytes with a trailing high byte >0x80.
459
+ """
460
+ buf = encode_prefix(label)
461
+ # Set most significant bit to mark end of label in this node.
462
+ buf[0] |= (1 << 7)
463
+ return buf
464
+
465
+
466
+ def encode(dafsa, utf_mode):
467
+ """Encodes a DAFSA to a list of bytes"""
468
+ output = []
469
+ offsets = {}
470
+
471
+ for node in reversed(top_sort(dafsa)):
472
+ if (len(node[1]) == 1 and node[1][0] and
473
+ (offsets[id(node[1][0])] == len(output))):
474
+ output.extend(encode_prefix(node[0]))
475
+ else:
476
+ output.extend(encode_links(node[1], offsets, len(output)))
477
+ output.extend(encode_label(node[0]))
478
+ offsets[id(node)] = len(output)
479
+
480
+ output.extend(encode_links(dafsa, offsets, len(output)))
481
+ output.reverse()
482
+ if utf_mode:
483
+ output.append(0x01)
484
+ return output
485
+
486
+
487
+ def to_cxx(data, codecs):
488
+ """Generates C/C++ code from a list of encoded bytes."""
489
+ text = b'/* This file has been generated by psl-make-dafsa. DO NOT EDIT!\n\n'
490
+ text += b'The byte array encodes effective tld names. See psl-make-dafsa source for'
491
+ text += b' documentation.'
492
+ text += b'*/\n\n'
493
+ text += b'static const unsigned char kDafsa['
494
+ text += bytes(str(len(data)), **codecs)
495
+ text += b'] = {\n'
496
+ for i in range(0, len(data), 12):
497
+ text += b' '
498
+ text += bytes(', '.join('0x%02x' % byte for byte in data[i:i + 12]), **codecs)
499
+ text += b',\n'
500
+ text += b'};\n'
501
+ return text
502
+
503
+ def sha1_file(name):
504
+ sha1 = hashlib.sha1()
505
+ with open(name, 'rb') as f:
506
+ while True:
507
+ data = f.read(65536)
508
+ if not data:
509
+ break
510
+ sha1.update(data)
511
+ return sha1.hexdigest()
512
+
513
+ def to_cxx_plus(data, codecs):
514
+ """Generates C/C++ code from a word list plus some variable assignments as needed by libpsl"""
515
+ text = to_cxx(data, codecs)
516
+ text += b'static time_t _psl_file_time = %d;\n' % os.stat(psl_input_file).st_mtime
517
+ text += b'static int _psl_nsuffixes = %d;\n' % psl_nsuffixes
518
+ text += b'static int _psl_nexceptions = %d;\n' % psl_nexceptions
519
+ text += b'static int _psl_nwildcards = %d;\n' % psl_nwildcards
520
+ text += b'static const char _psl_sha1_checksum[] = "%s";\n' % bytes(sha1_file(psl_input_file), **codecs)
521
+ text += b'static const char _psl_filename[] = "%s";\n' % bytes(psl_input_file, **codecs)
522
+ return text
523
+
524
+ def words_to_whatever(words, converter, utf_mode, codecs):
525
+ """Generates C/C++ code from a word list"""
526
+ dafsa = to_dafsa(words, utf_mode)
527
+ for fun in (reverse, join_suffixes, reverse, join_suffixes, join_labels):
528
+ dafsa = fun(dafsa)
529
+ return converter(encode(dafsa, utf_mode), codecs)
530
+
531
+
532
+ def words_to_cxx(words, utf_mode, codecs):
533
+ """Generates C/C++ code from a word list"""
534
+ return words_to_whatever(words, to_cxx, utf_mode, codecs)
535
+
536
+ def words_to_cxx_plus(words, utf_mode, codecs):
537
+ """Generates C/C++ code from a word list plus some variable assignments as needed by libpsl"""
538
+ return words_to_whatever(words, to_cxx_plus, utf_mode, codecs)
539
+
540
+ def words_to_binary(words, utf_mode, codecs):
541
+ """Generates C/C++ code from a word list"""
542
+ return b'.DAFSA@PSL_0 \n' + words_to_whatever(words, lambda x, _: bytearray(x), utf_mode, codecs)
543
+
544
+
545
+ def parse_psl(infile, utf_mode, codecs):
546
+ """Parses PSL file and extract strings and return code"""
547
+ PSL_FLAG_EXCEPTION = (1<<0)
548
+ PSL_FLAG_WILDCARD = (1<<1)
549
+ PSL_FLAG_ICANN = (1<<2) # entry of ICANN section
550
+ PSL_FLAG_PRIVATE = (1<<3) # entry of PRIVATE section
551
+ PSL_FLAG_PLAIN = (1<<4) #just used for PSL syntax checking
552
+
553
+ global psl_nsuffixes, psl_nexceptions, psl_nwildcards
554
+
555
+ psl = {}
556
+ section = 0
557
+
558
+ for line in infile:
559
+ line = bytes(line.strip(), **codecs)
560
+ if not line:
561
+ continue
562
+
563
+ if line.startswith(b'//'):
564
+ if section == 0:
565
+ if b'===BEGIN ICANN DOMAINS===' in line:
566
+ section = PSL_FLAG_ICANN
567
+ elif b'===BEGIN PRIVATE DOMAINS===' in line:
568
+ section = PSL_FLAG_PRIVATE
569
+ elif section == PSL_FLAG_ICANN and b'===END ICANN DOMAINS===' in line:
570
+ section = 0
571
+ elif section == PSL_FLAG_PRIVATE and b'===END PRIVATE DOMAINS===' in line:
572
+ section = 0
573
+ continue # skip comments
574
+
575
+ if line[:1] == b'!':
576
+ psl_nexceptions += 1
577
+ flags = PSL_FLAG_EXCEPTION | section
578
+ line = line[1:]
579
+ elif line[:1] == b'*':
580
+ if line[1:2] != b'.':
581
+ print('Unsupported kind of rule (ignored): %s' % line)
582
+ continue
583
+ psl_nwildcards += 1
584
+ psl_nsuffixes += 1
585
+ flags = PSL_FLAG_WILDCARD | PSL_FLAG_PLAIN | section
586
+ line = line[2:]
587
+ else:
588
+ psl_nsuffixes += 1
589
+ flags = PSL_FLAG_PLAIN | section
590
+
591
+ punycode = line.decode('utf-8').encode('idna')
592
+
593
+ if punycode in psl:
594
+ """Found existing entry:
595
+ Combination of exception and plain rule is ambiguous
596
+ !foo.bar
597
+ foo.bar
598
+
599
+ Allowed:
600
+ !foo.bar + *.foo.bar
601
+ foo.bar + *.foo.bar
602
+ """
603
+ print('Found %s/%X (now %X)' % punycode, psl[punycode], flags)
604
+ continue
605
+
606
+ if utf_mode:
607
+ psl[line] = flags
608
+ psl[punycode] = flags
609
+
610
+ # with open("psl.out", 'w') as outfile:
611
+ # for (domain, flags) in sorted(psl.iteritems()):
612
+ # outfile.write(domain + "%X" % (flags & 0x0F) + "\n")
613
+
614
+ return [domain + bytes('%X' % (flags & 0x0F), **codecs) for (domain, flags) in sorted(psl.items())]
615
+
616
+
617
+ def usage():
618
+ """Prints the usage"""
619
+ print('usage: %s [options] infile outfile' % sys.argv[0])
620
+ print(' --output-format=cxx Write DAFSA as C/C++ code (default)')
621
+ print(' --output-format=cxx+ Write DAFSA as C/C++ code plus statistical assignments')
622
+ print(' --output-format=binary Write DAFSA binary data')
623
+ print(' --encoding=ascii 7-bit ASCII mode')
624
+ print(' --encoding=utf-8 UTF-8 mode (default)')
625
+ exit(1)
626
+
627
+
628
+ def main():
629
+ """Convert PSL file into C or binary DAFSA file"""
630
+ if len(sys.argv) < 3:
631
+ usage()
632
+
633
+ converter = words_to_cxx
634
+ parser = parse_psl
635
+ utf_mode = True
636
+
637
+ codecs = dict()
638
+ if sys.version_info.major > 2:
639
+ codecs['encoding'] = 'utf-8'
640
+
641
+ for arg in sys.argv[1:-2]:
642
+ # Check --input-format for backward compatibility
643
+ if arg.startswith('--input-format='):
644
+ value = arg[15:].lower()
645
+ if value == 'psl':
646
+ parser = parse_psl
647
+ else:
648
+ print("Unknown input format '%s'" % value)
649
+ return 1
650
+ elif arg.startswith('--output-format='):
651
+ value = arg[16:].lower()
652
+ if value == 'binary':
653
+ converter = words_to_binary
654
+ elif value == 'cxx':
655
+ converter = words_to_cxx
656
+ elif value == 'cxx+':
657
+ converter = words_to_cxx_plus
658
+ else:
659
+ print("Unknown output format '%s'" % value)
660
+ return 1
661
+ elif arg.startswith('--encoding='):
662
+ value = arg[11:].lower()
663
+ if value == 'ascii':
664
+ utf_mode = False
665
+ elif value == 'utf-8':
666
+ utf_mode = True
667
+ else:
668
+ print("Unknown encoding '%s'" % value)
669
+ return 1
670
+ else:
671
+ usage()
672
+
673
+ if sys.argv[-2] == '-':
674
+ with open(sys.argv[-1], 'wb') as outfile:
675
+ outfile.write(converter(parser(sys.stdin, utf_mode, codecs), utf_mode, codecs))
676
+ else:
677
+ """Some statistical data for --output-format=cxx+"""
678
+ global psl_input_file, psl_nsuffixes, psl_nexceptions, psl_nwildcards
679
+
680
+ psl_input_file = sys.argv[-2]
681
+ psl_nsuffixes = 0
682
+ psl_nexceptions = 0
683
+ psl_nwildcards = 0
684
+
685
+ with open(sys.argv[-2], 'r', **codecs) as infile, open(sys.argv[-1], 'wb') as outfile:
686
+ outfile.write(converter(parser(infile, utf_mode, codecs), utf_mode, codecs))
687
+
688
+ return 0
689
+
690
+
691
+ if __name__ == '__main__':
692
+ sys.exit(main())
Binary file
Binary file