(self, adapter: str, profile_name: str)
Create a profile entry using the adapter's sample_profiles.yml

        Renames the profile in sample_profiles.yml to match that of the project.
Create a profile entry using the adapter's sample_profiles.yml
Create a profile entry using the adapter s sample_profiles . yml
def create_profile_from_sample(self, adapter: str, profile_name: str):
        """Create a profile entry using the adapter's sample_profiles.yml

        Renames the profile in sample_profiles.yml to match that of the project."""
        # Line below raises an exception if the specified adapter is not found
        load_plugin(adapter)
        adapter_path = get_include_paths(adapter)[0]
        sample_profiles_path = adapter_path / "sample_profiles.yml"

        if not sample_profiles_path.exists():
            fire_event(NoSampleProfileFound(adapter=adapter))
        else:
            with open(sample_profiles_path, "r") as f:
                sample_profile = f.read()
            sample_profile_name = list(yaml.safe_load(sample_profile).keys())[0]
            # Use a regex to replace the name of the sample_profile with
            # that of the project without losing any comments from the sample
            sample_profile = re.sub(
                f"^{sample_profile_name}:",
                f"{profile_name}:",
                sample_profile
            )
            profiles_filepath = Path(flags.PROFILES_DIR) / Path("profiles.yml")
            if profiles_filepath.exists():
                with open(profiles_filepath, "a") as f:
                    f.write("\n" + sample_profile)
            else:
                with open(profiles_filepath, "w") as f:
                    f.write(sample_profile)
                fire_event(
                    ProfileWrittenWithSample(
                        name=profile_name,
                        path=str(profiles_filepath)
                    )
                )
def create_profile_from_sample ( self , adapter : str , profile_name : str ) : # Line below raises an exception if the specified adapter is not found load_plugin ( adapter ) adapter_path = get_include_paths ( adapter ) [ 0 ] sample_profiles_path = adapter_path / "sample_profiles.yml" if not sample_profiles_path . exists ( ) : fire_event ( NoSampleProfileFound ( adapter = adapter ) ) else : with open ( sample_profiles_path , "r" ) as f : sample_profile = f . read ( ) sample_profile_name = list ( yaml . safe_load ( sample_profile ) . keys ( ) ) [ 0 ] # Use a regex to replace the name of the sample_profile with # that of the project without losing any comments from the sample sample_profile = re . sub ( f"^{sample_profile_name}:" , f"{profile_name}:" , sample_profile ) profiles_filepath = Path ( flags . PROFILES_DIR ) / Path ( "profiles.yml" ) if profiles_filepath . exists ( ) : with open ( profiles_filepath , "a" ) as f : f . write ( "\n" + sample_profile ) else : with open ( profiles_filepath , "w" ) as f : f . write ( sample_profile ) fire_event ( ProfileWrittenWithSample ( name = profile_name , path = str ( profiles_filepath ) ) )