Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #338 from dephell/fix-format-infer
Browse files Browse the repository at this point in the history
ignore unreadable content in format inference
  • Loading branch information
orsinium committed Dec 17, 2019
2 parents a846e18 + d5ab4c2 commit 0f5f172
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dephell/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import re
from collections import defaultdict
from contextlib import suppress
from copy import deepcopy
from logging import captureWarnings
from logging.config import dictConfig
Expand All @@ -15,7 +16,7 @@
from tomlkit.exceptions import TOMLKitError

# app
from ..constants import ENV_VAR_TEMPLATE, NON_PATH_FORMATS, SUFFIXES
from ..constants import ARCHIVE_EXTENSIONS, ENV_VAR_TEMPLATE, NON_PATH_FORMATS, SUFFIXES
from .defaults import DEFAULT
from .logging_config import LOGGING
from .scheme import SCHEME
Expand Down Expand Up @@ -96,7 +97,10 @@ def _expand_converter(text: str) -> Dict[str, str]:

# if passed only filename
path = Path(text)
content = None if not path.is_file() else path.read_text()
content = None
if path.is_file() and not path.name.endswith(ARCHIVE_EXTENSIONS):
with suppress(Exception):
content = path.read_text()
for name, converter in CONVERTERS.items():
if converter.can_parse(path=path, content=content):
return dict(format=name, path=text)
Expand Down

0 comments on commit 0f5f172

Please sign in to comment.