def main(): """Will be used to create the console script""" import optparse import sys import codecs import locale from algorithm import get_display parser = optparse.OptionParser() parser.add_option('-e', '--encoding', dest='encoding', default='utf-8', type='string', help='Text encoding (default: utf-8)') parser.add_option('-u', '--upper-is-rtl', dest='upper_is_rtl', default=False, action='store_true', help="Treat upper case chars as strong 'R' " 'for debugging (default: False).') parser.add_option('-d', '--debug', dest='debug', default=False, action='store_true', help="Display the steps taken with the algorithm") parser.add_option('-b', '--base-dir', dest='base_dir', default=None, type='string', help="Override base direction [L|R]") options, rest = parser.parse_args() if options.base_dir and options.base_dir not in 'LR': parser.error('option -b can be L or R') # allow unicode in sys.stdout.write sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) if rest: lines = rest else: lines = sys.stdin for line in lines: display = get_display(line, options.encoding, options.upper_is_rtl, options.base_dir, options.debug) # adjust the encoding as unicode, to match the output encoding if not isinstance(display, unicode): display = display.decode(options.encoding) sys.stdout.write(display)
def main(): """Will be used to create the console script""" import optparse import sys import codecs import locale from algorithm import get_display parser = optparse.OptionParser() parser.add_option('-e', '--encoding', dest='encoding', default='utf-8', type='string', help='Text encoding (default: utf-8)') parser.add_option('-u', '--upper-is-rtl', dest='upper_is_rtl', default=False, action='store_true', help="treat upper case chars as strong 'R' " 'for debugging (default: False).') parser.add_option('-d', '--debug', dest='debug', default=False, action='store_true', help="Display the steps taken with the algorithm") options, rest = parser.parse_args() # allow unicode in sys.stdout.write sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) if rest: sys.stdout.write(get_display(rest[0], options.encoding, options.upper_is_rtl, options.debug)) else: for line in sys.stdin: sys.stdout.write(get_display(line, options.encoding, options.upper_is_rtl, options.debug))
def ConvTxt(str, boolFlipHeb): cnvStr = str Engl = isEng(cnvStr) if Engl: return Eng2Heb(str) else: hebChr = 0 for strDecode in strDecoders: tmpStr = str.encode(strEncode, "replace").decode(strDecode, "replace") tmpChr = isHeb(tmpStr) if tmpChr > hebChr: cnvStr = tmpStr hebChr = tmpChr meth = strDecode + "(" + hebChr.ToString() + ")" if cnvStr != str: if boolFlipHeb: return get_display(u'' + cnvStr, upper_is_rtl=False, encoding=strEncode, debug=False) else: return cnvStr else: return str
def run(self, edit): region = sublime.Region(0, self.view.size()) txt = self.view.substr(region) reshaped_text = arabic_reshaper.reshape(txt) bdiText = get_display(reshaped_text) self.view.replace(edit, region, bdiText)
def run(self, edit): region = sublime.Region(0, self.view.size()) txt = self.view.substr(region) bdiText = get_display(txt, upper_is_rtl=True) self.view.replace(edit, region, bdiText)