def _open(file: str) -> TextIO:
- if file.endswith('.gz'):
- return gzip.open(file, 'rt', encoding='utf-8')
- return open(file, 'rt', encoding='utf-8')
+ try:
+ if file.endswith('.gz'):
+ return gzip.open(file, 'rt', encoding='utf-8')
+ return open(file, 'rt', encoding='utf-8')
+ except FileNotFoundError:
+ sys.exit(f'[!] ERROR: unable to open {file}, are you sure it exists?')
def detect_arch(fname: str, archs: List[str]) -> Tuple[StrOrNone, str]: