Пример #1
0
    def _parser(self):
        """
        You can implement your own _parser() here.
        """

        with open(self._csv, "r") as csvfile:
            spamreader = csv.reader(csvfile)
            addr = None

            block = None
            for row in spamreader:
                row_type = self.cal_row_type(row)
                if row_type == self.TYPE_ADDRESS:
                    addr = Field.extract_hex(row[1])
                    name = row[2]
                    block = Block(name=name, address=addr)
                    self._group.add_block(block)
                elif row_type == self.TYPE_FIELD:
                    bits, shift = Field.extract_range(row[1])
                    name = row[2]
                    f = Field.new_field(name=name,
                                        addr=addr,
                                        bits=bits,
                                        shift=shift,
                                        source=str(row))
                    block.add_field(f)
Пример #2
0
 def add_field(self, addr, row):
     bits, shift = Field.extract_range(row[1])
     name = row[2]
     f = Field.new_field(name=name,
                         addr=addr,
                         bits=bits,
                         shift=shift,
                         source=str(row))
     self._add_field(f)
Пример #3
0
 def extract_addr(self, row):
     return Field.extract_hex(row[1])