Gnumed.pycommon.gmMimeMagic

Package Gnumed :: Package pycommon :: Module gmMimeMagic |
[frames] | no frames]

# Module gmMimeMagic

source code

    magic.py
     determines a file type by its magic number

     (C)opyright 2000 Jason Petrone <jp@demonseed.net>
     All Rights Reserved

     Command Line Usage: running as `python3 magic.py file` will print
                                                                                     a description of what 'file' is.

     Module Usage:
                     magic.whatis(data): when passed a string 'data' containing
                                                                                                     binary or text data, a description of
                                                                                                     what the data is will be returned.

                     magic.filedesc(filename): returns a description of what the file
                                                                                                             'filename' contains.

    Acknowledgements: This module has been pulled from the web. Thanks to
    Jason Petrone for providing it to the community. It is based on his
    __version__ = '0.1'

Author: Jason Petrone <jp@demonseed.net>, Karsten Hilbert <Karsten.Hilbert@gmx.net>

License: GPL

Classes
| magicTest

Functions
strToNum(n) | source code
unescape(s) | source code
load(file) | source code
whatis(data) | source code
filedesc(file) | source code

Variables
| magic = ``[``[`0`,` `'``leshort``'``,` `'``=``'``,` 1538`,` `'``application/x-alan-adventu``...``
| magicNumbers = ``[`<Gnumed.pycommon.gmMimeMagic.magicTest object>`...``
| __package__ = ``'``Gnumed.pycommon``'``
| m = ``[`0`,` `'``string``'``,` `'``=``'``,` `'``ZyXEL\x02``'``,` `'``ZyXEL voice data``'``]``

Imports: re, struct, string, io, sys

Variables Details

  ### magic Value:
      [[0, 'leshort', '=', 1538, 'application/x-alan-adventure-game'],
       [0, 'string', '=', 'TADS', 'application/x-tads-game'],
       [0, 'short', '=', 420, 'application/x-executable-file'],
       [0, 'short', '=', 421, 'application/x-executable-file'],
       [0, 'leshort', '=', 603, 'application/x-executable-file'],
       [0, 'string', '=', 'Core\x01', 'application/x-executable-file'],
       [0,
        'string',
      ...

  ### magicNumbers Value:
      [<Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
       <Gnumed.pycommon.gmMimeMagic.magicTest object>,
      ...