diff --git a/src/diana/diana.py b/src/diana/diana.py --- a/src/diana/diana.py +++ b/src/diana/diana.py @@ -30,10 +30,11 @@ def collect_moves(root): class SourceFile: - def __init__(self, file_name): + def __init__(self, file_name, output_format): self.file_name = file_name self._short_name = "".join(re.split(r'[/\\]', file_name)[-1].split('.')[:-1]) self._game = go.Go() + self.drawer = Tikz if output_format == "tikz" else Svg with open(self.file_name, 'r', encoding=cfg.encoding) as f: games = Collection(f.read()).list_games() @@ -46,7 +47,7 @@ class SourceFile: i = 1 for k in range(0, len(self._moves), cfg.moves_per_diagram): filename = os.path.join(cfg.output_dir, "{0}-{1}".format(self._short_name, i)) - self.create_diagram(k, k + cfg.moves_per_diagram).save(filename, "templ-pleb.svg") + self.create_diagram(k, k+cfg.moves_per_diagram).save(filename) i += 1 info_str = """{GN} @@ -68,7 +69,7 @@ W: {PW} {WR} :rtype: Drawer""" # initialize the diagram - template = Svg() + template = self.drawer(start) self._set_move(start) @@ -97,7 +98,7 @@ W: {PW} {WR} return False # draw the move - template.add_move(c, r, color, k + 1) + template.add_move(c, r, color, k+1) return template @@ -153,7 +154,7 @@ def main(): for item in files: if os.path.isfile(item): try: - f = SourceFile(item) + f = SourceFile(item, cfg.output_format) f.process() except ParserError as e: print("Couldn't parse {0}, following error occured: {1}".format(item, e))