def main(): #parsing print 'Program started.' parser = argparse.ArgumentParser(description= 'Enter parameters for conversion.') parser.add_argument('-ini', action='store', default='', dest='file_ini', help='Adress or name of source file in ini.') parser.add_argument('-json', action='store', default='', dest='file_json', help='Adress or name of source file in json. (UNUSED)') parser.add_argument('-final', action='store', default='', dest='file_final', help='Adress or name of converted file.') parser.add_argument('-mat', action='store', default='', dest='file_material', help='Adress or name of material file. Type * for automatic file detection.') parser.add_argument('-sw', action='store_true', dest='warnings', help='Show not found messages during conversion.') parser.add_argument('-nc', action='store_false', dest='comments', help='Disable saving of comments.') parser.add_argument('-db', action='store_true', dest='debug', help='Show saved values (used for debugging).') parser.add_argument('-nd', action='store_false', dest='altering', help='Disable alterations to json file (quotation marks, colons).') args = vars(parser.parse_args()) #print args #checking for empty parameters f1 = args['file_ini'] f2 = args['file_json'] f3 = args['file_final'] converted = False if (f1 == ''): if (f2 == ''): print 'Error: no file name inserted.' else : converted = True if (f3 == ''): f3 = f2[0:-3] + 'json' print 'Name of final file: ' + f3 else : if (f2 == ''): f2 = f1[0:-4] + '_temp.json' print 'Name of source file in json: ' + f2 if (f3 == ''): f3 = f1[0:-3] + 'json' print 'Name of final file: ' + f3 converted = cnv.convert(f1, f2, args['comments']) #converts inifile into JSON #alter json file if (converted == True): print 'Starting final conversion.' complete = comp.complete(f2, f3, args['warnings'], args['comments'], args['debug'], args['altering'], args['file_material']) print 'Program terminated.' pass
def data_received(self, data): while _tasks: _t = _tasks.pop() _t.cancel() msg = json.loads(data.decode('utf-8')) mode = msg[1].get('mode') if mode == 'clear_cache': Complete.clear_cache() elif mode == 'completion': self.task = ensure_future(complete(msg, self.transport)) _tasks.append(self.task)
def handle_key_press(widget, event): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == 'Return': text = window.get_input() if text == None: text = '' output.print_input(text) window.clear_input() global history_index history_index = 0 if text != '': result = ui_interface.enter(text) #assert result != None if result != []: if isinstance(result, list): output.print_outputs(result) else: output.print_output(result) window.refresh() elif keyname == 'F5': window.refresh() elif keyname == 'Up': new_command_str = previous_command(processor.environment.history) window.set_input(new_command_str) window.cursor_to_end() # return True to stop default action of switching widget focus return True elif keyname == 'Down': new_command_str = next_command(processor.environment.history) window.set_input(new_command_str) window.cursor_to_end() # return True to stop default action of switching widget focus return True elif keyname == 'Tab': input = window.get_input(); completed = completion.complete(input) if completed: window.set_input(completed) window.cursor_to_end() return True