Пример #1
0
  def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=None, QSignal=None):
    DataSource.__init__(self, ['header'])
    self.eof = 1
    self.recTypes = set(recTypes)
    self.inp = inp
    self.reopen_fn = reopen_fn
    self.endian = endian
    self.inp.seek(0, 2)
    self.inpSize = self.inp.tell()
    self.inp.seek(0)
    self.QSignal = QSignal
    self.parse_complete = False
    self.recordMap = dict(
      [ ( (recType.typ, recType.sub), recType )
        for recType in recTypes ])

    self.unpackMap = {
      "C1": self.readField,
      "B1": self.readField,
      "U1": self.readField,
      "U2": self.readField,
      "U4": self.readField,
      "U8": self.readField,
      "I1": self.readField,
      "I2": self.readField,
      "I4": self.readField,
      "I8": self.readField,
      "R4": self.readField,
      "R8": self.readField,
      "Cn": lambda header, fmt: self.readCn(header),
      "Bn": lambda header, fmt: self.readBn(header),
      "Dn": lambda header, fmt: self.readDn(header),
      "Vn": lambda header, fmt: self.readVn(header)
    }

    self.recordParsers = dict(
      [ ( (recType.typ, recType.sub), self.createRecordParser(recType) )
        for recType in recTypes ])

    self.vnMap = {
      0: lambda header: self.inp.read(header, 1),
      1: lambda header: self.readField(header, "U1"),
      2: lambda header: self.readField(header, "U2"),
      3: lambda header: self.readField(header, "U4"),
      4: lambda header: self.readField(header, "I1"),
      5: lambda header: self.readField(header, "I2"),
      6: lambda header: self.readField(header, "I4"),
      7: lambda header: self.readField(header, "R4"),
      8: lambda header: self.readField(header, "R8"),
      10: lambda header: self.readCn(header),
      11: lambda header: self.readBn(header),
      12: lambda header: self.readDn(header),
      13: lambda header: self.readField(header, "U1")
    }
Пример #2
0
Файл: IO.py Проект: cmars/pystdf
  def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=None):
    DataSource.__init__(self, ['header']);
    self.eof = 1
    self.recTypes = set(recTypes)
    self.inp = inp
    self.reopen_fn = reopen_fn
    self.endian = endian

    self.recordMap = dict(
      [ ( (recType.typ, recType.sub), recType )
        for recType in recTypes ])

    self.unpackMap = {
      "C1": self.readField,
      "B1": self.readField,
      "U1": self.readField,
      "U2": self.readField,
      "U4": self.readField,
      "U8": self.readField,
      "I1": self.readField,
      "I2": self.readField,
      "I4": self.readField,
      "I8": self.readField,
      "R4": self.readField,
      "R8": self.readField,
      "Cn": lambda header, fmt: self.readCn(header),
      "Bn": lambda header, fmt: self.readBn(header),
      "Dn": lambda header, fmt: self.readDn(header),
      "Vn": lambda header, fmt: self.readVn(header)
    }

    self.recordParsers = dict(
      [ ( (recType.typ, recType.sub), self.createRecordParser(recType) )
        for recType in recTypes ])

    self.vnMap = {
      0: lambda header: self.inp.read(header, 1),
      1: lambda header: self.readField(header, "U1"),
      2: lambda header: self.readField(header, "U2"),
      3: lambda header: self.readField(header, "U4"),
      4: lambda header: self.readField(header, "I1"),
      5: lambda header: self.readField(header, "I2"),
      6: lambda header: self.readField(header, "I4"),
      7: lambda header: self.readField(header, "R4"),
      8: lambda header: self.readField(header, "R8"),
      10: lambda header: self.readCn(header),
      11: lambda header: self.readBn(header),
      12: lambda header: self.readDn(header),
      13: lambda header: self.readField(header, "U1")
    }