def parse_assignment()

in deepracer_systems_pkg/deepracer_systems_pkg/network_monitor_module/wifi_config_utils.py [0:0]


def parse_assignment(line):
    """Helper method to parse the lines with assignment(=) operator in them.

    Args:
        line (str): Line read from the WiFi configuration file.

    Returns:
        tuple: Tuple with name and value strings.
    """
    while True:
        # Ignore comments.
        if line.startswith("#"):
            break

        # Separate the variable from the value.
        assignment = line.split(":", 1)
        if len(assignment) != 2:
            break

        # Extract the variable name.
        name = assignment[0].strip()
        if name == "":
            break

        # Extract the value and stript leading and trailing quotes if any.
        value = assignment[1].strip()
        if value.startswith("\'") and value.endswith("\'"):
            value = value[1:-1]
        if value.startswith("\"") and value.endswith("\""):
            value = value[1:-1]

        return str(name), str(value)

    return None, None