def _transform(self, pkg, sep, common_protos):
        """Transform to the appropriate proto package layout.

        Works with arbitrary separator (e.g., '/' for import statements,
        '.' for proto package statements, os.path.sep for filenames)
        """
        if sep != '.' and pkg.endswith('.proto'):
            dotted = pkg[:-6].replace(sep, '.')
            suffix = '.proto'
        else:
            dotted = pkg.replace(sep, '.')
            suffix = ''

        # Sanity check: Do not transform common protos.
        for common_pkg in common_protos:
            if dotted.startswith(common_pkg):
                return pkg

        # Special case: If the organization name is "google-cloud", then we
        # have to ensure that "cloud" exists in the path. The protos
        # themselves may not follow this.
        if 'cloud' not in dotted and self._organization_name == 'google-cloud':
            dotted = dotted.replace('google.', 'google.cloud.', 1)

        # Transform into the ideal proto path.
        # What essentially should happen here is that "{api}.{vN}" should
        # change to "{api}_{vN}".
        dotted = re.sub(r'\.v([\da-z_]*)([\d]+)\b', r'_v\1\2.proto', dotted)

        # Edge case: Some internal customers use "vNalpha" and "vNbeta".
        # Rather than make the regular expression more complicated, catch
        # this as a one-off.
        if re.search(r'\.v[\d]+alpha\b', dotted):
            dotted = re.sub(r'\.v([\d]+)alpha\b', r'_v\1alpha.proto', dotted)
        if re.search(r'\.v[\d]+beta\b', dotted):
            dotted = re.sub(r'\.v([\d]+)beta\b', r'_v\1beta.proto', dotted)
        if re.search(r'\.v[\d]+eap\b', dotted):
            dotted = re.sub(r'\.v([\d]+)eap\b', r'_v\1eap.proto', dotted)

        # Done; return with the appropriate separator.
        return dotted.replace('.', sep) + suffix