Пример #1
0
 def __init__(self,
              parent,
              name,
              nbytes,
              description="Padding",
              pattern=None):
     """ pattern is None or repeated string """
     assert (pattern is None) or (isinstance(pattern, bytes))
     Bytes.__init__(self, parent, name, nbytes, description)
     self.pattern = pattern
     self._display_pattern = self.checkPattern()
Пример #2
0
 def __init__(self, parent, name, length, decompressor, description=None,
              parser=None, filename=None, mime_type=None, parser_class=None):
     if filename:
         if not isinstance(filename, str):
             filename = makePrintable(filename, "ISO-8859-1")
         if not description:
             description = 'File "%s" (%s)' % (
                 filename, humanFilesize(length))
     Bytes.__init__(self, parent, name, length, description)
     self.setupInputStream(decompressor, parser,
                           filename, mime_type, parser_class)
Пример #3
0
    def __init__(self, parent, name, description=None,
                 strip=None, nbytes=None, truncate=None):
        Bytes.__init__(self, parent, name, 1, description)

        self._format = "WidePascalString16"
        self._strip = strip
        self._truncate = truncate
        self._character_size = 2
        self._charset = "UTF-16-LE"
        self._content_offset = 2
        self._content_size = self._character_size * self._parent.stream.readBits(
            self.absolute_address, self._content_offset * 8, self._parent.endian)
        self._size = (self._content_size + self.content_offset) * 8
Пример #4
0
    def __init__(self, parent, name, length, description=None,
                 parser=None, filename=None, mime_type=None, parser_class=None):
        if filename:
            if not isinstance(filename, str):
                filename = makePrintable(filename, "ISO-8859-1")
            if not description:
                description = 'File "%s" (%s)' % (
                    filename, humanFilesize(length))
        Bytes.__init__(self, parent, name, length, description)

        def createInputStream(cis, **args):
            tags = args.setdefault("tags", [])
            if parser_class:
                tags.append(("class", parser_class))
            if parser is not None:
                tags.append(("id", parser.PARSER_TAGS["id"]))
            if mime_type:
                tags.append(("mime", mime_type))
            if filename:
                tags.append(("filename", filename))
            return cis(**args)
        self.setSubIStream(createInputStream)
Пример #5
0
 def __init__(self, parent):
     Bytes.__init__(self, parent, 'file', parent['size'].value, None)
Пример #6
0
 def __init__(self, parent, name, *args, **kwargs):
     Bytes.__init__(self, parent, name, 16, *args, **kwargs)