Ejemplo n.º 1
0
def createEditableField(fieldset, field):
    if isInteger(field):
        cls = EditableInteger
    elif isString(field):
        cls = EditableString
    elif field.__class__ in (RawBytes, Bytes, PaddingBytes):
        cls = EditableBytes
    elif field.__class__ in (RawBits, Bits, Bit, PaddingBits):
        cls = EditableBits
    elif field.__class__ == Character:
        cls = EditableCharacter
    else:
        cls = FakeField
    return cls(fieldset, field.name)
Ejemplo n.º 2
0
def createEditableField(fieldset, field):
    if isInteger(field):
        cls = EditableInteger
    elif isString(field):
        cls = EditableString
    elif field.__class__ in (RawBytes, Bytes, PaddingBytes):
        cls = EditableBytes
    elif field.__class__ in (RawBits, Bits, Bit, PaddingBits):
        cls = EditableBits
    elif field.__class__ == Character:
        cls = EditableCharacter
    else:
        cls = FakeField
    return cls(fieldset, field.name)
Ejemplo n.º 3
0
 def extractNames(self, names):
     offset = names["offset"].value
     for header in names.array("header"):
         key = header["nameID"].value
         foffset = offset + header["offset"].value
         field = names.getFieldByAddress(foffset*8)
         if not field or not isString(field):
             continue
         value = field.value
         if key not in self.NAMEID_TO_ATTR:
             continue
         key = self.NAMEID_TO_ATTR[key]
         if key == "version" and value.startswith(u"Version "):
             # "Version 1.2" => "1.2"
             value = value[8:]
         setattr(self, key, value)
Ejemplo n.º 4
0
 def extractNames(self, names):
     offset = names["offset"].value
     for header in names.array("header"):
         key = header["nameID"].value
         foffset = offset + header["offset"].value
         field = names.getFieldByAddress(foffset * 8)
         if not field or not isString(field):
             continue
         value = field.value
         if key not in self.NAMEID_TO_ATTR:
             continue
         key = self.NAMEID_TO_ATTR[key]
         if key == "version" and value.startswith(u"Version "):
             # "Version 1.2" => "1.2"
             value = value[8:]
         setattr(self, key, value)