()
| 81 | |
| 82 | |
| 83 | def create_new_config_file(): |
| 84 | typer.echo("Creating new config file") |
| 85 | file_path = typer.prompt( |
| 86 | "Where do you want to put your config file ?", |
| 87 | type=str, |
| 88 | default="~/.codecarbon.config", |
| 89 | ) |
| 90 | if file_path[0] == "~": |
| 91 | file_path = Path.home() / file_path[2:] |
| 92 | else: |
| 93 | file_path = Path(file_path) |
| 94 | |
| 95 | if not file_path.parent.exists(): |
| 96 | create = Confirm.ask( |
| 97 | "Parent folder does not exist do you want to create it (and parents) ?" |
| 98 | ) |
| 99 | if create: |
| 100 | file_path.parent.mkdir(parents=True, exist_ok=True) |
| 101 | |
| 102 | file_path.touch() |
| 103 | with open(file_path, "w") as f: |
| 104 | f.write("[codecarbon]\n") |
| 105 | typer.echo(f"Config file created at {file_path}") |
| 106 | return file_path |
no outgoing calls
no test coverage detected
searching dependent graphs…