Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat config file format to use for user-friendly strings of arbitrary bytes?
    primarykey
    data
    text
    <p>So I made a short Python script to launch files in Windows with ambiguous extensions by examining their <a href="https://en.wikipedia.org/wiki/Magic_number_%28programming%29" rel="nofollow noreferrer">magic number/file signature</a> first:</p> <ul> <li><a href="https://superuser.com/a/317927/13889">https://superuser.com/a/317927/13889</a></li> <li><a href="https://gist.github.com/1119561" rel="nofollow noreferrer">https://gist.github.com/1119561</a></li> </ul> <p>I'd like to compile it to a .exe to make association easier (either using bbfreeze or rewriting in C), but I need some kind of user-friendly config file to specify the matching byte strings and program paths. Basically I want to put this information into a plain text file somehow:</p> <pre><code>magic_numbers = { # TINA 'OBSS': r'%PROGRAMFILES(X86)%\DesignSoft\Tina 9 - TI\TINA.EXE', # PSpice '*version': r'%PROGRAMFILES(X86)%\Orcad\Capture\Capture.exe', 'x100\x88\xce\xcf\xcfOrCAD ': '', #PSpice? # Protel 'DProtel': r'%PROGRAMFILES(X86)%\Altium Designer S09 Viewer\dxp.exe', # Eagle '\x10\x80': r'%PROGRAMFILES(X86)%\EAGLE-5.11.0\bin\eagle.exe', '\x10\x00': r'%PROGRAMFILES(X86)%\EAGLE-5.11.0\bin\eagle.exe', '&lt;?xml version="1.0" encoding="utf-8"?&gt;\n&lt;!DOCTYPE eagle ': r'%PROGRAMFILES(X86)%\EAGLE-5.11.0\bin\eagle.exe', # PADS Logic '\x00\xFE': r'C:\MentorGraphics\9.3PADS\SDD_HOME\Programs\powerlogic.exe', } </code></pre> <p>(The hex bytes are just arbitrary bytes, not Unicode characters.)</p> <p>I guess a .py file in this format works, but I have to leave it uncompiled and somehow still import it into the compiled file, and there's still a bunch of extraneous content like <code>{</code> and <code>,</code> to be confused by/screw up.</p> <p>I looked at YAML, and it would be great except that it requires base64-encoding binary stuff first, which isn't really what I want. I'd prefer the config file to contain hex representations of the bytes. But also ASCII representations, if that's all the file signature is. And maybe also regexes. :D (In case the XML-based format can be written with different amounts of whitespace, for instance)</p> <p>Any ideas?</p>
    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.
 

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