Back to index

plone3  3.1.7
Classes | Functions | Variables
MimetypesRegistry.mime_types.magic Namespace Reference

Classes

class  magicTest

Functions

def strToNum
def guessMime

Variables

string __version__ = '$Revision: 1.2 $'
list magic
list magicNumbers = []

Detailed Description

magic.py

 Initial Author: Jason Petrone <jp@demonseed.net>

 Updated by Gabriel Wicke <groups@gabrielwicke.de>
Thu Oct 16 23:00:03 CEST 2003
with magic data from gnome-vfs-mime-magic

Function Documentation

Definition at line 336 of file magic.py.

00336 
00337 def guessMime(data):
00338     for test in magicNumbers:
00339         m = test.compare(data)
00340         if m: 
00341             return m
00342     # no matching, magic number.
00343     return
00344 
#import sys

Here is the caller graph for this function:

Definition at line 248 of file magic.py.

00248 
00249 def strToNum(n):
00250     val = 0
00251     col = long(1)
00252     if n[:1] == 'x': n = '0' + n
00253     if n[:2] == '0x':
00254         # hex
00255         n = string.lower(n[2:])
00256         while len(n) > 0:
00257             l = n[len(n) - 1]
00258             val = val + string.hexdigits.index(l) * col
00259             col = col * 16
00260             n = n[:len(n)-1]
00261     elif n[0] == '\\':
00262         # octal
00263         n = n[1:]
00264         while len(n) > 0:
00265             l = n[len(n) - 1]
00266             if ord(l) < 48 or ord(l) > 57: break
00267             val = val + int(l) * col
00268             col = col * 8
00269             n = n[:len(n)-1]
00270     else:
00271         val = string.atol(n)
00272     return val

Here is the caller graph for this function:


Variable Documentation

Definition at line 20 of file magic.py.

Definition at line 22 of file magic.py.

Definition at line 246 of file magic.py.