chrome/test/webapps/file_reading.py
def read_platform_supported_actions(csv_file
                                    ) -> PartialAndFullCoverageByBaseName:
    """Reads the action base names and coverage from the given csv file.

    Args:
        csv_file: The comma-separated-values file which lists action base names
                  and whether it is fully or partially supported.

    Returns:
        A dictionary of action base name to a set of partially supported
        and fully supported platforms.
    """
    actions_base_name_to_coverage: PartialAndFullCoverageByBaseName = {}
    column_offset_to_platform = {
        0: TestPlatform.MAC,
        1: TestPlatform.WINDOWS,
        2: TestPlatform.LINUX,
        3: TestPlatform.CHROME_OS
    }
    for i, row in enumerate(csv_file):
        if not row:
            continue
        if row[0].startswith("#"):
            continue
        if len(row) < MIN_COLUMNS_SUPPORTED_ACTIONS_FILE:
            raise ValueError(f"Row {i} does not contain enough entries. "
                             f"Got {row}.")
        action_base_name: str = row[0].strip()
        if action_base_name in actions_base_name_to_coverage:
            raise ValueError(f"Action base name '{action_base_name}' on "
                             f"row {i} is already specified.")
        if not re.fullmatch(r'[a-z_]+', action_base_name):
            raise ValueError(
                f"Invald action base name '{action_base_name}' on "
                f"row {i}. Please use snake_case.")
        fully_supported_platforms: Set[TestPlatform] = set()
        partially_supported_platforms: Set[TestPlatform] = set()
        for j, value in enumerate(row[1:5]):
            value = value.strip()
            if not value:
                continue
            if value == "🌕":
                fully_supported_platforms.add(column_offset_to_platform[j])
            elif value == "🌓":
                partially_supported_platforms.add(column_offset_to_platform[j])
            elif value != "🌑":
                raise ValueError(f"Invalid coverage '{value}' on row {i}. "
                                 f"Please use '🌕', '🌓', or '🌑'.")

        actions_base_name_to_coverage[action_base_name] = (
            partially_supported_platforms, fully_supported_platforms)
    return actions_base_name_to_coverage
Reads the action base names and coverage from the given csv file.

    Args:
        csv_file: The comma-separated-values file which lists action base names
                  and whether it is fully or partially supported.

    Returns:
        A dictionary of action base name to a set of partially supported
        and fully supported platforms.
    
Reads the action base names and coverage from the given csv file.
Reads the action base names and coverage from the given csv file .
def read_platform_supported_actions(csv_file
                                    ) -> PartialAndFullCoverageByBaseName:
    actions_base_name_to_coverage: PartialAndFullCoverageByBaseName = {}
    column_offset_to_platform = {
        0: TestPlatform.MAC,
        1: TestPlatform.WINDOWS,
        2: TestPlatform.LINUX,
        3: TestPlatform.CHROME_OS
    }
    for i, row in enumerate(csv_file):
        if not row:
            continue
        if row[0].startswith("#"):
            continue
        if len(row) < MIN_COLUMNS_SUPPORTED_ACTIONS_FILE:
            raise ValueError(f"Row {i} does not contain enough entries. "
                             f"Got {row}.")
        action_base_name: str = row[0].strip()
        if action_base_name in actions_base_name_to_coverage:
            raise ValueError(f"Action base name '{action_base_name}' on "
                             f"row {i} is already specified.")
        if not re.fullmatch(r'[a-z_]+', action_base_name):
            raise ValueError(
                f"Invald action base name '{action_base_name}' on "
                f"row {i}. Please use snake_case.")
        fully_supported_platforms: Set[TestPlatform] = set()
        partially_supported_platforms: Set[TestPlatform] = set()
        for j, value in enumerate(row[1:5]):
            value = value.strip()
            if not value:
                continue
            if value == "🌕":
                fully_supported_platforms.add(column_offset_to_platform[j])
            elif value == "🌓":
                partially_supported_platforms.add(column_offset_to_platform[j])
            elif value != "🌑":
                raise ValueError(f"Invalid coverage '{value}' on row {i}. "
                                 f"Please use '🌕', '🌓', or '🌑'.")
        actions_base_name_to_coverage[action_base_name] = (
            partially_supported_platforms, fully_supported_platforms)
    return actions_base_name_to_coverage
def read_platform_supported_actions ( csv_file ) -> PartialAndFullCoverageByBaseName : actions_base_name_to_coverage : PartialAndFullCoverageByBaseName = { } column_offset_to_platform = { 0 : TestPlatform . MAC , 1 : TestPlatform . WINDOWS , 2 : TestPlatform . LINUX , 3 : TestPlatform . CHROME_OS } for i , row in enumerate ( csv_file ) : if not row : continue if row [ 0 ] . startswith ( "#" ) : continue if len ( row ) < MIN_COLUMNS_SUPPORTED_ACTIONS_FILE : raise ValueError ( f"Row {i} does not contain enough entries. " f"Got {row}." ) action_base_name : str = row [ 0 ] . strip ( ) if action_base_name in actions_base_name_to_coverage : raise ValueError ( f"Action base name '{action_base_name}' on " f"row {i} is already specified." ) if not re . fullmatch ( r'[a-z_]+' , action_base_name ) : raise ValueError ( f"Invald action base name '{action_base_name}' on " f"row {i}. Please use snake_case." ) fully_supported_platforms : Set [ TestPlatform ] = set ( ) partially_supported_platforms : Set [ TestPlatform ] = set ( ) for j , value in enumerate ( row [ 1 : 5 ] ) : value = value . strip ( ) if not value : continue if value == "🌕": fully_supported_platforms . add ( column_offset_to_platform [ j ] ) elif value == "🌓": partially_supported_platforms . add ( column_offset_to_platform [ j ] ) elif value != "🌑": raise ValueError ( f"Invalid coverage '{value}' on row {i}. " f"Please use '🌕', '🌓', or '🌑'.") actions_base_name_to_coverage [ action_base_name ] = ( partially_supported_platforms , fully_supported_platforms ) return actions_base_name_to_coverage
Reads the action base names and coverage from the given csv file.
Reads the action base names and coverage from the given csv file .
"""Reads the action base names and coverage from the given csv file.

    Args:
        csv_file: The comma-separated-values file which lists action base names
                  and whether it is fully or partially supported.

    Returns:
        A dictionary of action base name to a set of partially supported
        and fully supported platforms.
    """
A dictionary of action base name to a set of partially supported
and fully supported platforms.
A dictionary of action base name to a set of partially supported and fully supported platforms .
csv_file
The comma-separated-values file which lists action base names
and whether it is fully or partially supported.
The comma - separated - values file which lists action base names and whether it is fully or partially supported .