Use backend-specific suffixes for output filenames.

This commit is contained in:
Andrey Golovizin 2014-09-08 21:15:55 +02:00
parent 721de38920
commit 4548f92e73
2 changed files with 4 additions and 1 deletions

View file

@ -21,6 +21,7 @@ from .glyphdb import WhitespaceData
class OutputFormat(object):
suffix = ''
last_tag = None
def __call__(self, glyph_data_stream):
@ -65,6 +66,7 @@ class OutputFormat(object):
class TextFormat(OutputFormat):
suffix = '.txt'
def assign_tag(self, glyph_data):
return None
@ -73,6 +75,7 @@ class TextFormat(OutputFormat):
class HTMLFormat(OutputFormat):
suffix = '.html'
def assign_glyph_tag(self, glyph_data):
style = glyph_data.style
if style.bold:

View file

@ -65,7 +65,7 @@ class OCREngine(QThread):
self.pageChanged.emit(page)
page_text = self.recognize_page(page)
print(page_text)
with open(filename + '.txt', 'w') as page_text_file:
with open(filename + self.output_format.suffix, 'w') as page_text_file:
page_text_file.write(page_text)
def recognize_page(self, page):