Skip to content

Commit

Permalink
Try adding .txt to default config if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Apr 23, 2024
1 parent 695e4a4 commit 466dfcb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions avtdl/avtdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse
import asyncio
import logging
import os
from asyncio import AbstractEventLoop
from pathlib import Path
from typing import Any, Dict, Tuple
Expand All @@ -21,8 +20,13 @@

def load_config(path: Path) -> Any:
try:
if not os.path.exists(path):
raise ValueError('Configuration file {} does not exist'.format(path))
if not path.exists():
alt_path = path.with_suffix(path.suffix + '.txt')
if alt_path.exists():
print(f'Configuration file {path} not found, trying {alt_path} instead')
path = alt_path
else:
raise ValueError('Configuration file {} does not exist'.format(path))
config_text = read_file(path)
config = yaml.load(config_text, Loader=yaml.FullLoader)
except Exception as e:
Expand Down

0 comments on commit 466dfcb

Please sign in to comment.