Remove submodule, just put Dependencies in ./libs

This commit is contained in:
Ruud
2011-02-28 15:25:42 +01:00
parent 2fb578d4de
commit 6888798ef6
541 changed files with 173394 additions and 4 deletions
+33
View File
@@ -0,0 +1,33 @@
from hachoir_core.field import CompressedField
try:
from zlib import decompressobj, MAX_WBITS
class DeflateStream:
def __init__(self, stream, wbits=None):
if wbits:
self.gzip = decompressobj(-MAX_WBITS)
else:
self.gzip = decompressobj()
def __call__(self, size, data=None):
if data is None:
data = ''
return self.gzip.decompress(self.gzip.unconsumed_tail+data, size)
class DeflateStreamWbits(DeflateStream):
def __init__(self, stream):
DeflateStream.__init__(self, stream, True)
def Deflate(field, wbits=True):
if wbits:
CompressedField(field, DeflateStreamWbits)
else:
CompressedField(field, DeflateStream)
return field
has_deflate = True
except ImportError:
def Deflate(field, wbits=True):
return field
has_deflate = False
+62
View File
@@ -0,0 +1,62 @@
"""
MS-DOS structures.
Documentation:
- File attributes:
http://www.cs.colorado.edu/~main/cs1300/include/ddk/winddk.h
"""
from hachoir_core.field import StaticFieldSet
from hachoir_core.field import Bit, NullBits
_FIELDS = (
(Bit, "read_only"),
(Bit, "hidden"),
(Bit, "system"),
(NullBits, "reserved[]", 1),
(Bit, "directory"),
(Bit, "archive"),
(Bit, "device"),
(Bit, "normal"),
(Bit, "temporary"),
(Bit, "sparse_file"),
(Bit, "reparse_file"),
(Bit, "compressed"),
(Bit, "offline"),
(Bit, "dont_index_content"),
(Bit, "encrypted"),
)
class MSDOSFileAttr16(StaticFieldSet):
"""
MSDOS 16-bit file attributes
"""
format = _FIELDS + ((NullBits, "reserved[]", 1),)
_text_keys = (
# Sort attributes by importance
"directory", "read_only", "compressed",
"hidden", "system",
"normal", "device",
"temporary", "archive")
def createValue(self):
mode = []
for name in self._text_keys:
if self[name].value:
if 4 <= len(mode):
mode.append("...")
break
else:
mode.append(name)
if mode:
return ", ".join(mode)
else:
return "(none)"
class MSDOSFileAttr32(MSDOSFileAttr16):
"""
MSDOS 32-bit file attributes
"""
format = _FIELDS + ((NullBits, "reserved[]", 17),)
+10
View File
@@ -0,0 +1,10 @@
"""
Shared code for tracker parser.
"""
NOTE_NAME = {}
NOTES = ("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "G#", "A", "A#", "B")
for octave in xrange(10):
for index, note in enumerate(NOTES):
NOTE_NAME[octave*12+index] = "%s (octave %s)" % (note, octave)
+154
View File
@@ -0,0 +1,154 @@
from hachoir_core.field import (FieldSet,
UInt16, UInt32, Enum, String, Bytes, Bits, TimestampUUID60)
from hachoir_parser.video.fourcc import video_fourcc_name
from hachoir_core.bits import str2hex
from hachoir_core.text_handler import textHandler, hexadecimal
from hachoir_parser.network.common import MAC48_Address
# Dictionary: Windows codepage => Python charset name
CODEPAGE_CHARSET = {
874: "CP874",
# 932: Japanese Shift-JIS
# 936: Simplified Chinese GBK
# 949: Korean
# 950: Traditional Chinese Big5
1250: "WINDOWS-1250",
1251: "WINDOWS-1251",
1252: "WINDOWS-1252",
1253: "WINDOWS-1253",
1254: "WINDOWS-1254",
1255: "WINDOWS-1255",
1256: "WINDOWS-1256",
1257: "WINDOWS-1257",
1258: "WINDOWS-1258",
65001: "UTF-8",
}
class PascalStringWin32(FieldSet):
def __init__(self, parent, name, description=None, strip=None, charset="UTF-16-LE"):
FieldSet.__init__(self, parent, name, description)
length = self["length"].value
self._size = 32 + length * 16
self.strip = strip
self.charset = charset
def createFields(self):
yield UInt32(self, "length", "Length in widechar characters")
size = self["length"].value
if size:
yield String(self, "text", size*2, charset=self.charset, strip=self.strip)
def createValue(self):
if "text" in self:
return self["text"].value
else:
return None
class GUID(FieldSet):
"""
Windows 128 bits Globally Unique Identifier (GUID)
See RFC 4122
"""
static_size = 128
NULL = "00000000-0000-0000-0000-000000000000"
FIELD_NAMES = {
3: ("sha1_high", "sha1_low"),
4: ("random_high", "random_low"),
5: ("md5_high", "md5_low"),
}
VERSION_NAME = {
1: "Timestamp & MAC-48",
2: "DCE Security version",
3: "Name SHA-1 hash",
4: "Randomly generated",
5: "Name MD5 hash",
}
VARIANT_NAME = {
0: "NCS",
2: "Leach-Salz",
# 5: Microsoft Corporation?
6: "Microsoft Corporation",
7: "Reserved Future",
}
def __init__(self, *args):
FieldSet.__init__(self, *args)
self.version = self.stream.readBits(self.absolute_address + 32 + 16 + 12, 4, self.endian)
def createFields(self):
if self.version == 1:
yield TimestampUUID60(self, "time")
yield Enum(Bits(self, "version", 4), self.VERSION_NAME)
yield Enum(Bits(self, "variant", 3), self.VARIANT_NAME)
yield textHandler(Bits(self, "clock", 13), hexadecimal)
# yield textHandler(Bits(self, "clock", 16), hexadecimal)
if self.version == 1:
yield MAC48_Address(self, "mac", "IEEE 802 MAC address")
else:
yield Bytes(self, "node", 6)
else:
namea, nameb = self.FIELD_NAMES.get(
self.version, ("data_a", "data_b"))
yield textHandler(Bits(self, namea, 60), hexadecimal)
yield Enum(Bits(self, "version", 4), self.VERSION_NAME)
yield Enum(Bits(self, "variant", 3), self.VARIANT_NAME)
yield textHandler(Bits(self, nameb, 61), hexadecimal)
def createValue(self):
addr = self.absolute_address
a = self.stream.readBits (addr, 32, self.endian)
b = self.stream.readBits (addr + 32, 16, self.endian)
c = self.stream.readBits (addr + 48, 16, self.endian)
d = self.stream.readBytes(addr + 64, 2)
e = self.stream.readBytes(addr + 80, 6)
return "%08X-%04X-%04X-%s-%s" % (a, b, c, str2hex(d), str2hex(e))
def createDisplay(self):
value = self.value
if value == self.NULL:
name = "Null GUID: "
else:
name = "GUID v%u (%s): " % (self.version, self["version"].display)
return name + value
def createRawDisplay(self):
value = self.stream.readBytes(self.absolute_address, 16)
return str2hex(value, format=r"\x%02x")
class BitmapInfoHeader(FieldSet):
""" Win32 BITMAPINFOHEADER structure from GDI """
static_size = 40*8
COMPRESSION_NAME = {
0: u"Uncompressed (RGB)",
1: u"RLE (8 bits)",
2: u"RLE (4 bits)",
3: u"Bitfields",
4: u"JPEG",
5: u"PNG"
}
def __init__(self, parent, name, use_fourcc=False):
FieldSet.__init__(self, parent, name)
self._use_fourcc = use_fourcc
def createFields(self):
yield UInt32(self, "hdr_size", "Header size (in bytes) (=40)")
yield UInt32(self, "width", "Width")
yield UInt32(self, "height", "Height")
yield UInt16(self, "nb_planes", "Color planes")
yield UInt16(self, "bpp", "Bits/pixel")
if self._use_fourcc:
yield Enum(String(self, "codec", 4, charset="ASCII"), video_fourcc_name)
else:
yield Enum(UInt32(self, "codec", "Compression"), self.COMPRESSION_NAME)
yield UInt32(self, "size", "Image size (in bytes)")
yield UInt32(self, "xres", "X pixels per meter")
yield UInt32(self, "yres", "Y pixels per meter")
yield UInt32(self, "color_used", "Number of used colors")
yield UInt32(self, "color_important", "Number of important colors")
def createDescription(self):
return "Bitmap info header: %ux%u pixels, %u bits/pixel" % \
(self["width"].value, self["height"].value, self["bpp"].value)
+136
View File
@@ -0,0 +1,136 @@
"""
Windows 2000 - List of Locale IDs and Language Groups
Original data table:
http://www.microsoft.com/globaldev/reference/win2k/setup/lcid.mspx
"""
LANGUAGE_ID = {
0x0436: u"Afrikaans",
0x041c: u"Albanian",
0x0401: u"Arabic Saudi Arabia",
0x0801: u"Arabic Iraq",
0x0c01: u"Arabic Egypt",
0x1001: u"Arabic Libya",
0x1401: u"Arabic Algeria",
0x1801: u"Arabic Morocco",
0x1c01: u"Arabic Tunisia",
0x2001: u"Arabic Oman",
0x2401: u"Arabic Yemen",
0x2801: u"Arabic Syria",
0x2c01: u"Arabic Jordan",
0x3001: u"Arabic Lebanon",
0x3401: u"Arabic Kuwait",
0x3801: u"Arabic UAE",
0x3c01: u"Arabic Bahrain",
0x4001: u"Arabic Qatar",
0x042b: u"Armenian",
0x042c: u"Azeri Latin",
0x082c: u"Azeri Cyrillic",
0x042d: u"Basque",
0x0423: u"Belarusian",
0x0402: u"Bulgarian",
0x0403: u"Catalan",
0x0404: u"Chinese Taiwan",
0x0804: u"Chinese PRC",
0x0c04: u"Chinese Hong Kong",
0x1004: u"Chinese Singapore",
0x1404: u"Chinese Macau",
0x041a: u"Croatian",
0x0405: u"Czech",
0x0406: u"Danish",
0x0413: u"Dutch Standard",
0x0813: u"Dutch Belgian",
0x0409: u"English United States",
0x0809: u"English United Kingdom",
0x0c09: u"English Australian",
0x1009: u"English Canadian",
0x1409: u"English New Zealand",
0x1809: u"English Irish",
0x1c09: u"English South Africa",
0x2009: u"English Jamaica",
0x2409: u"English Caribbean",
0x2809: u"English Belize",
0x2c09: u"English Trinidad",
0x3009: u"English Zimbabwe",
0x3409: u"English Philippines",
0x0425: u"Estonian",
0x0438: u"Faeroese",
0x0429: u"Farsi",
0x040b: u"Finnish",
0x040c: u"French Standard",
0x080c: u"French Belgian",
0x0c0c: u"French Canadian",
0x100c: u"French Swiss",
0x140c: u"French Luxembourg",
0x180c: u"French Monaco",
0x0437: u"Georgian",
0x0407: u"German Standard",
0x0807: u"German Swiss",
0x0c07: u"German Austrian",
0x1007: u"German Luxembourg",
0x1407: u"German Liechtenstein",
0x0408: u"Greek",
0x040d: u"Hebrew",
0x0439: u"Hindi",
0x040e: u"Hungarian",
0x040f: u"Icelandic",
0x0421: u"Indonesian",
0x0410: u"Italian Standard",
0x0810: u"Italian Swiss",
0x0411: u"Japanese",
0x043f: u"Kazakh",
0x0457: u"Konkani",
0x0412: u"Korean",
0x0426: u"Latvian",
0x0427: u"Lithuanian",
0x042f: u"Macedonian",
0x043e: u"Malay Malaysia",
0x083e: u"Malay Brunei Darussalam",
0x044e: u"Marathi",
0x0414: u"Norwegian Bokmal",
0x0814: u"Norwegian Nynorsk",
0x0415: u"Polish",
0x0416: u"Portuguese Brazilian",
0x0816: u"Portuguese Standard",
0x0418: u"Romanian",
0x0419: u"Russian",
0x044f: u"Sanskrit",
0x081a: u"Serbian Latin",
0x0c1a: u"Serbian Cyrillic",
0x041b: u"Slovak",
0x0424: u"Slovenian",
0x040a: u"Spanish Traditional Sort",
0x080a: u"Spanish Mexican",
0x0c0a: u"Spanish Modern Sort",
0x100a: u"Spanish Guatemala",
0x140a: u"Spanish Costa Rica",
0x180a: u"Spanish Panama",
0x1c0a: u"Spanish Dominican Republic",
0x200a: u"Spanish Venezuela",
0x240a: u"Spanish Colombia",
0x280a: u"Spanish Peru",
0x2c0a: u"Spanish Argentina",
0x300a: u"Spanish Ecuador",
0x340a: u"Spanish Chile",
0x380a: u"Spanish Uruguay",
0x3c0a: u"Spanish Paraguay",
0x400a: u"Spanish Bolivia",
0x440a: u"Spanish El Salvador",
0x480a: u"Spanish Honduras",
0x4c0a: u"Spanish Nicaragua",
0x500a: u"Spanish Puerto Rico",
0x0441: u"Swahili",
0x041d: u"Swedish",
0x081d: u"Swedish Finland",
0x0449: u"Tamil",
0x0444: u"Tatar",
0x041e: u"Thai",
0x041f: u"Turkish",
0x0422: u"Ukrainian",
0x0420: u"Urdu",
0x0443: u"Uzbek Latin",
0x0843: u"Uzbek Cyrillic",
0x042a: u"Vietnamese",
}