diff options
author | emkael <emkael@tlen.pl> | 2019-07-08 22:45:38 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-07-08 22:45:38 +0200 |
commit | a0644da194f61f627535e6b72c7a6e761986498d (patch) | |
tree | c9fe545dc585320c90f547dfe70c4bb0bd8e2ca7 /dealconvert/__init__.py | |
parent | 3a136318f40f607e21069afc4141a5cbcba9ccb8 (diff) | |
parent | e3e5c088687d73dc492199be071cc12d786ba00d (diff) |
Merge branch 'master' of github.com:emkael/deal-convert
Diffstat (limited to 'dealconvert/__init__.py')
-rw-r--r-- | dealconvert/__init__.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/dealconvert/__init__.py b/dealconvert/__init__.py index 1779976..3b5a8ba 100644 --- a/dealconvert/__init__.py +++ b/dealconvert/__init__.py @@ -1,17 +1,18 @@ from .formats import * class DealConverter(object): - def __init__(self, input_file): + def __init__(self, input_file=None): self.input = input_file self.formats = {} - self.parser = self._detect_format(self.input) + if input_file is not None: + self.parser = self._detect_format(self.input) def output(self, output_files): deal_set = sorted(self.parser.parse(self.input), key=lambda d:d.number) for output in output_files: self._detect_format(output).output(output, deal_set) - def _detect_format(self, filename): + def detect_format(self, filename): for deal_format in globals()['formats'].__all__: if deal_format not in self.formats: self.formats[deal_format] = getattr( @@ -19,4 +20,4 @@ class DealConverter(object): deal_format.upper() + 'Format')() if self.formats[deal_format].match_file(filename): return self.formats[deal_format] - raise ValueError('Unrecognized file extension: %s' % filename) + raise RuntimeError('Unrecognized file extension: %s' % filename) |