]> sigrok.org Git - libsigrokdecode.git/commitdiff
Rename values that shadow built-in keywords
authorRyan Jarvis <redacted>
Sat, 19 Jan 2019 08:05:07 +0000 (00:05 -0800)
committerUwe Hermann <redacted>
Tue, 29 Jan 2019 23:08:39 +0000 (00:08 +0100)
decoders/arm_etmv3/pd.py
decoders/cec/pd.py
decoders/cec/protocoldata.py
decoders/jtag_ejtag/pd.py
decoders/lin/pd.py
decoders/spiflash/pd.py

index 8de3ce2c8d40915af88ef580f1a645a88d2e62b0..59168248a0eb0c1f603d3c9a43ce83ebc6f193cd 100644 (file)
@@ -31,30 +31,30 @@ exc_names = [
 for i in range(8, 496):
     exc_names.append('IRQ%d' % i)
 
-def parse_varint(bytes):
+def parse_varint(bytes_):
     '''Parse an integer where the top bit is the continuation bit.
     Returns value and number of parsed bytes.'''
     v = 0
-    for i, b in enumerate(bytes):
+    for i, b in enumerate(bytes_):
         v |= (b & 0x7F) << (i * 7)
         if b & 0x80 == 0:
             return v, i+1
-    return v, len(bytes)
+    return v, len(bytes_)
 
-def parse_uint(bytes):
+def parse_uint(bytes_):
     '''Parse little-endian integer.'''
     v = 0
-    for i, b in enumerate(bytes):
+    for i, b in enumerate(bytes_):
         v |= b << (i * 8)
     return v
 
-def parse_exc_info(bytes):
+def parse_exc_info(bytes_):
     '''Parse exception information bytes from a branch packet.'''
-    if len(bytes) < 1:
+    if len(bytes_) < 1:
         return None
 
-    excv, exclen = parse_varint(bytes)
-    if bytes[exclen - 1] & 0x80 != 0x00:
+    excv, exclen = parse_varint(bytes_)
+    if bytes_[exclen - 1] & 0x80 != 0x00:
         return None # Exception info not complete.
 
     if exclen == 2 and excv & (1 << 13):
@@ -69,21 +69,21 @@ def parse_exc_info(bytes):
     resume = (excv >> 14) & 0x0F
     return (ns, exc, cancel, altisa, hyp, resume)
 
-def parse_branch_addr(bytes, ref_addr, cpu_state, branch_enc):
+def parse_branch_addr(bytes_, ref_addr, cpu_state, branch_enc):
     '''Parse encoded branch address.
        Returns addr, addrlen, cpu_state, exc_info.
        Returns None if packet is not yet complete'''
 
-    addr, addrlen = parse_varint(bytes)
+    addr, addrlen = parse_varint(bytes_)
 
-    if bytes[addrlen-1] & 0x80 != 0x00:
+    if bytes_[addrlen - 1] & 0x80 != 0x00:
         return None # Branch address not complete.
 
     addr_bits = 7 * addrlen
 
     have_exc_info = False
     if branch_enc == 'original':
-        if addrlen == 5 and bytes[4] & 0x40:
+        if addrlen == 5 and bytes_[4] & 0x40:
             have_exc_info = True
     elif branch_enc == 'alternative':
         addr_bits -= 1 # Top bit of address indicates exc_info.
@@ -93,20 +93,20 @@ def parse_branch_addr(bytes, ref_addr, cpu_state, branch_enc):
 
     exc_info = None
     if have_exc_info:
-        exc_info = parse_exc_info(bytes[addrlen:])
+        exc_info = parse_exc_info(bytes_[addrlen:])
         if exc_info is None:
             return None # Exception info not complete.
 
     if addrlen == 5:
         # Possible change in CPU state.
-        if bytes[4] & 0xB8 == 0x08:
+        if bytes_[4] & 0xB8 == 0x08:
             cpu_state = 'arm'
-        elif bytes[4] & 0xB0 == 0x10:
+        elif bytes_[4] & 0xB0 == 0x10:
             cpu_state = 'thumb'
-        elif bytes[4] & 0xA0 == 0x20:
+        elif bytes_[4] & 0xA0 == 0x20:
             cpu_state = 'jazelle'
         else:
-            raise NotImplementedError('Unhandled branch byte 4: 0x%02x' % bytes[4])
+            raise NotImplementedError('Unhandled branch byte 4: 0x%02x' % bytes_[4])
 
     # Shift the address according to current CPU state.
     if cpu_state == 'arm':
index 6e8ddecf44d83981a0a8395d712d0c91d7dadd4a..e4a40f3f3c736aae108dcf3dbaf86af60f9e421c 100644 (file)
@@ -116,41 +116,41 @@ class Decoder(srd.Decoder):
             return
 
         i = 0
-        str = ''
+        string = ''
         while i < len(self.cmd_bytes):
-            str += '{:02x}'.format(self.cmd_bytes[i]['val'])
+            string += '{:02x}'.format(self.cmd_bytes[i]['val'])
             if i != (len(self.cmd_bytes) - 1):
-                str += ':'
+                string += ':'
             i += 1
 
-        self.put(self.frame_start, self.frame_end, self.out_ann, [7, [str]])
+        self.put(self.frame_start, self.frame_end, self.out_ann, [7, [string]])
 
         i = 0
         operands = 0
-        str = ''
+        string = ''
         while i < len(self.cmd_bytes):
             if i == 0: # Parse header
                 (src, dst) = decode_header(self.cmd_bytes[i]['val'])
-                str = 'HDR: ' + src + ', ' + dst
+                string = 'HDR: ' + src + ', ' + dst
             elif i == 1: # Parse opcode
-                str += ' | OPC: ' + opcodes.get(self.cmd_bytes[i]['val'], 'Invalid')
+                string += ' | OPC: ' + opcodes.get(self.cmd_bytes[i]['val'], 'Invalid')
             else: # Parse operands
                 if operands == 0:
-                    str += ' | OPS: '
+                    string += ' | OPS: '
                 operands += 1
-                str += '0x{:02x}'.format(self.cmd_bytes[i]['val'])
+                string += '0x{:02x}'.format(self.cmd_bytes[i]['val'])
                 if i != len(self.cmd_bytes) - 1:
-                    str += ', '
+                    string += ', '
             i += 1
 
         # Header only commands are PINGS
         if i == 1:
-            str += ' | OPC: PING' if self.eom else ' | OPC: NONE. Aborted cmd'
+            string += ' | OPC: PING' if self.eom else ' | OPC: NONE. Aborted cmd'
 
         # Add extra information (ack of the command from the destination)
-        str += ' | R: NACK' if is_nack else ' | R: ACK'
+        string += ' | R: NACK' if is_nack else ' | R: ACK'
 
-        self.put(self.frame_start, self.frame_end, self.out_ann, [8, [str]])
+        self.put(self.frame_start, self.frame_end, self.out_ann, [8, [string]])
 
     def process(self):
         zero_time = ((self.rise - self.fall_start) / self.samplerate) * 1000.0
index 833ac7f5e9f4fe2a5b4451bfb343eb5254a89488..78c3b6f537d7ab5b4c1fa4cec5ff96a3eefeb1a3 100644 (file)
@@ -101,15 +101,15 @@ opcodes = {
     0x9A: 'SET_AUDIO_RATE',
 }
 
-def resolve_logical_address(id, is_initiator):
-    if id < 0 or id > 0x0F:
+def resolve_logical_address(id_, is_initiator):
+    if id_ < 0 or id_ > 0x0F:
         return 'Invalid'
 
     # Special handling of 0x0F.
-    if id == 0x0F:
+    if id_ == 0x0F:
         return 'Unregistered' if is_initiator else 'Broadcast'
 
-    return logical_adresses[id]
+    return logical_adresses[id_]
 
 def decode_header(header):
     src = (header & 0xF0) >> 4
index ceaa1142dd6f02bda715b30823bbe800a5b5564e..94a3a1ab2f4c94fcee483d3122baf1e8620bde52 100644 (file)
@@ -357,16 +357,16 @@ class Decoder(srd.Decoder):
 
     def handle_ir_tdi(self, val):
         code = bin2int(val[0])
-        hex = '0x{:02X}'.format(code)
+        hex_value = '0x{:02X}'.format(code)
         if code in ejtag_insn:
             # Format instruction name.
             insn = ejtag_insn[code]
             s_short = insn[0]
-            s_long = insn[0] + ': ' + insn[1] + ' (' + hex + ')'
+            s_long = insn[0] + ': ' + insn[1] + ' (' + hex_value + ')'
             # Display it and select data register.
             self.put_current([Ann.INSTRUCTION, [s_long, s_short]])
         else:
-            self.put_current([Ann.INSTRUCTION, [hex, 'IR TDI ({})'.format(hex)]])
+            self.put_current([Ann.INSTRUCTION, [hex_value, 'IR TDI ({})'.format(hex_value)]])
         self.select_reg(code)
 
     def handle_new_state(self, new_state):
index e0340fc4f9945a805ecad816b1721a0485be9907..e1b6d1b3112182b5bd8aaf1d5223a4d414490b12 100644 (file)
@@ -150,7 +150,7 @@ class Decoder(srd.Decoder):
         checksum = self.lin_rsp.pop() if len(self.lin_rsp) else None
 
         if pid:
-            id = pid[2] & 0x3F
+            id_ = pid[2] & 0x3F
             parity = pid[2] >> 6
 
             expected_parity = self.calc_parity(pid[2])
@@ -161,8 +161,8 @@ class Decoder(srd.Decoder):
 
             ann_class = 0 if parity_valid else 3
             self.put(pid[0], pid[1], self.out_ann, [ann_class, [
-                'ID: %02X Parity: %d (%s)' % (id, parity, 'ok' if parity_valid else 'bad'),
-                'ID: 0x%02X' % id, 'I: %d' % id
+                'ID: %02X Parity: %d (%s)' % (id_, parity, 'ok' if parity_valid else 'bad'),
+                'ID: 0x%02X' % id_, 'I: %d' % id_
             ]])
 
         if len(self.lin_rsp):
@@ -188,9 +188,9 @@ class Decoder(srd.Decoder):
 
     def checksum_is_valid(self, pid, data, checksum):
         if self.lin_version == 2:
-            id = pid & 0x3F
+            id_ = pid & 0x3F
 
-            if id != 60 and id != 61:
+            if id_ != 60 and id_ != 61:
                 checksum += pid
 
         for d in data:
@@ -203,10 +203,10 @@ class Decoder(srd.Decoder):
 
     @staticmethod
     def calc_parity(pid):
-        id = [((pid & 0x3F) >> i) & 1 for i in range(8)]
+        id_ = [((pid & 0x3F) >> i) & 1 for i in range(8)]
 
-        p0 = id[0] ^ id[1] ^ id[2] ^ id[4]
-        p1 = not (id[1] ^ id[3] ^ id[4] ^ id[5])
+        p0 = id_[0] ^ id_[1] ^ id_[2] ^ id_[4]
+        p1 = not (id_[1] ^ id_[3] ^ id_[4] ^ id_[5])
 
         return (p0 << 0) | (p1 << 1)
 
index aecc2d37db5766ce8e994177f05b3b9396f15df9..bbdf3fb113080fde58dcd7e73bf726d824cf706c 100644 (file)
@@ -473,8 +473,8 @@ class Decoder(srd.Decoder):
             self.putx([Ann.FIELD, ['%s ID: 0x%02x' % (d, miso)]])
 
         if self.cmdstate == 6:
-            id = self.ids[1] if self.manufacturer_id_first else self.ids[0]
-            self.device_id = id
+            id_ = self.ids[1] if self.manufacturer_id_first else self.ids[0]
+            self.device_id = id_
             self.es_cmd = self.es
             self.putc([Ann.REMS, self.cmd_vendor_dev_list()])
             self.state = None