PCQRSCANER/venv/Lib/site-packages/textract/parsers/rtf_parser.py
2019-12-22 21:51:47 +01:00

16 lines
420 B
Python

import six
from .utils import ShellParser
class Parser(ShellParser):
"""Extract text from rtf files using unrtf.
"""
def extract(self, filename, **kwargs):
# http://superuser.com/a/243089/126633
stdout, stderr = self.run(['unrtf', '--text', filename])
splitter = six.b('-') * 17 + six.b('\n')
text_conversion = stdout.split(splitter, 1)[-1]
return text_conversion