# 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:
try:
vout=FribidiOut(getattr(self,fid),self._err_file)
importpty
setattr(self,fid,vout)
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:
exceptOSErrorasose:
ifose.errno==2:
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.')
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.')