Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest doing this a little differently. I would decouple these two settings from each other:</p> <ol> <li>Magic number signature ===> mimetype</li> <li>mimetype ==> program launcher</li> </ol> <p>For the first part, I would use <a href="https://github.com/ahupp/python-magic" rel="nofollow">python-magic</a>, a library that has bindings to <a href="http://linux.die.net/man/3/libmagic" rel="nofollow">libmagic</a>. You can have python-magic use a custom magic file like this:</p> <pre><code>import magic m = magic.Magic(magic_file='/path/to/magic.file') </code></pre> <p>Your users can specify a custom magic file mapping magic numbers to mimetypes. The syntax of magic files is <a href="http://www.manpagez.com/man/5/magic/" rel="nofollow">documented</a>. Here's an example showing the magic file for the TIFF format:</p> <pre><code># Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com) # The second word of TIFF files is the TIFF version number, 42, which has # never changed. The TIFF specification recommends testing for it. 0 string MM\x00\x2a TIFF image data, big-endian !:mime image/tiff 0 string II\x2a\x00 TIFF image data, little-endian !:mime image/tiff </code></pre> <p>The second part then is pretty easy, since you only need to specify text data now. You could go with an INI or yaml format, as suggested by others, or you could even have just a simple tab-delimited file like this:</p> <pre><code>image/tiff C:\Program Files\imageviewer.exe application/json C:\Program Files\notepad.exe </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload