<commit_before>import time

import uart

import elm327
from obd import commands
from obd.fuel_type import FUEL_TYPE_DESCRIPTION


def decode_bitwise_pids(hex_string):
    """
        Determine supported PIDs based on the supplied hexadecimal string
        :param hex_string:a hex string representing bitwise encoded PID support
        :return: a dictionary of PID number: boolean pairs that indicate
        whether or not a PID is supported
    """
    clean_hex = hex_string.replace(' ', '')
    bits = bin(int(clean_hex, 16))[2:].zfill(32)
    return dict(
            (hex(i + 1)[2:].zfill(2).upper(), True if value == '1' else False)
            for i, value in enumerate(bits)
           )


class OBDScanner(object):

    """
        ELM327 OBD-II Scanner

        Information about OBD-II PIDs
        http://en.wikipedia.org/wiki/OBD-II_PIDs

        Additional details about EML327 OBD <-> RS232 found here:
        http://elmelectronics.com/DSheets/ELM327DS.pdf

    """

    def __init__(self):
        self.uart_port = None
        self.connected = False
        self.elm_version = ""
        self.obd_protocol = ""
        # Time to wait (in seconds) before attempting to receive data after an
        # OBD command has been issued
        self.receive_wait_time = 0.5

    def connect(self):<commit_msg>Fixed zfill support for different versions<commit_after>import time
import uart
import elm327
from obd import commands
from obd.fuel_type import FUEL_TYPE_DESCRIPTION

def zfill(string, width):
    """
        Wrapper for str.zfill which is not exists in micropython
        :param string: a string for alignment
        :param width: width of the resulted string
        :return: a string that has been aligned to the width
    """
    return string.zfill(width)
           if hasattr(string, 'zfill') else
           ('{0:0%d}'%(width)).format(int(string))

def decode_bitwise_pids(hex_string):
    """
        Determine supported PIDs based on the supplied hexadecimal string
        :param hex_string:a hex string representing bitwise encoded PID support
        :return: a dictionary of PID number: boolean pairs that indicate
        whether or not a PID is supported
    """
    clean_hex = hex_string.replace(' ', '')
    bits = zfill(bin(int(clean_hex, 16))[2:], 32)
    return dict(
            (zfill(hex(i + 1)[2:],2).upper(), True if value == '1' else False)
            for i, value in enumerate(bits)
           )


class OBDScanner(object):

    """
        ELM327 OBD-II Scanner

        Information about OBD-II PIDs
        http://en.wikipedia.org/wiki/OBD-II_PIDs

        Additional details about EML327 OBD <-> RS232 found here:
        http://elmelectronics.com/DSheets/ELM327DS.pdf

    """

    def __init__(self):
        self.uart_port = None
        self.connected = False
        self.elm_version = ""
        self.obd_protocol = ""
        # Time to wait (in seconds) before attempting to receive data after an
        # OBD command has been issued
        self.receive_wait_time = 0.5

    def connect(self):
{'fraction_non_alphanumeric': 0.09055246812683884, 'fraction_numerical': 0.017652827721477606, 'mean_word_length': 2.5172413793103448, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6093138', 'n_tokens_mistral': 958, 'n_tokens_neox': 899, 'n_words': 285}