コード例 #1
0
ファイル: Negar.py プロジェクト: WinonuX/Negar
def main():
    output_file = "Negar_Output"
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hVf:o:", ["help", "file", "output", "Version"])
    except getopt.GetoptError:
        helpMessage()
        sys.exit(1)

    for opt, arg in opts:
        if opt in ('-h', '--help'):
            helpMessage()
            sys.exit()
        elif opt in ('-V', '--Version'):
            print "You are using Negar version:"+__version__
            sys.exit()
        elif opt in ('-f', '--file'):
            fileName = arg
        elif opt in ('-o', '--output'):
                output_file = arg
    
    try:
        input_file  = open(fileName)
        output_file = open(output_file, 'w') 
        while True:
            line = unicode(input_file.readline(), encoding='utf-8')
            if len(line) == 0:
                break
            run_PE = PersianEditor(line)
            output_file.write(run_PE.cleanup().encode('utf-8'))
    finally:
        input_file.close()
コード例 #2
0
ファイル: gui.py プロジェクト: pyguy/Negar
 def edit_text(self):
     self.output_editor.clear()
     lines = unicode(self.input_editor.toPlainText()).split('\n')
     for line in lines:
         run_PE = PersianEditor(line, *self.option_list)
         self.output_editor.append(run_PE.cleanup())