From 0174602093dcb097e23f6493bfd4f5d1a9fe2e3c Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Fri, 17 Jan 2020 20:31:42 -0600 Subject: Remove _split_on_dot from base parser and add it to utils Also, change the default behavior to split on every dot and split on only the last dot if specified --- config_file/config_file.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'config_file/config_file.py') diff --git a/config_file/config_file.py b/config_file/config_file.py index c47def2..5a2dbb5 100644 --- a/config_file/config_file.py +++ b/config_file/config_file.py @@ -1,7 +1,9 @@ +import inspect from pathlib import Path from config_file.parsers.base_parser import BaseParser from config_file.parsers.ini_parser import IniParser +from config_file.utils import split_on_dot class ConfigFile: @@ -21,10 +23,10 @@ class ConfigFile: return Path(file_path) def __determine_parser(self, file_path: str, parser): - if isinstance(parser, BaseParser): + if isinstance(parser, BaseParser) and not inspect.isabstract(parser): return parser(self.contents) - file_type = self._split_on_dot(file_path, all_dots=True)[-1] + file_type = split_on_dot(file_path)[-1] if file_type == "ini": return IniParser(self.contents) else: -- cgit v1.2.3