# fribidi does not support ungetting, so force newlines
params['progress_with_newline']=True
forfidin['_screen_file','_err_file']:
classFribidiOut(object):
def__init__(self,outfile,errfile):
self.outfile=outfile
self.process=subprocess.Popen(
['fribidi'],
stdin=subprocess.PIPE,
stdout=outfile,
stderr=errfile)
defwrite(self,s):
res=self.process.stdin.write(s)
self.flush()
returnres
defflush(self):
returnself.process.stdin.flush()
defisatty(self):
returnself.outfile.isatty()
try:
vout=FribidiOut(getattr(self,fid),self._err_file)
setattr(self,fid,vout)
exceptOSErrorasose:
ifose.errno==2:
self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')
break
else:
raise
try:
importpty
master,slave=pty.openpty()
width=get_term_width()
ifwidthisNone:
width_args=[]
else:
width_args=['-w',str(width)]
self._fribidi=subprocess.Popen(
['fribidi','-c','UTF-8']+width_args,
stdin=subprocess.PIPE,
stdout=slave,
stderr=self._err_file)
self._fribidi_channel=os.fdopen(master,'rb')
exceptOSErrorasose:
ifose.errno==2:
self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')