def parse(self): prog = Program() tok = self.lex.getLookaheadToken() while(tok.getTokenType() != TokenType.EOS): stmt = self.getStatement() prog.add(stmt) tok = self.lex.getLookaheadToken() return prog
def main(): app = Program(DB) choise = '' while True: print(UI) choise = input('Choise (1 - 6): ') if choise.isdigit(): choise = int(choise) print('-' * WIDTH) # show if choise == 1: app.show() # add elif choise == 2: app.add() # change elif choise == 3: changeable_name = input("Name for change: ") app.change(name=changeable_name) # delete elif choise == 4: deletable_name = tuple (input(\ "Name for delete: (1 or more names)\n" "example: 'Name2 Name2 Name3 ... ' "\ ).replace(',',' ').split()) print('-' * WIDTH) app.delete(*deletable_name) # search elif choise == 5: searchable_name = input("Search: ") app.search(searchable_name) # reset all elif choise == 6: sure_reset = input( "Are you sure you want reset all contacts? (Y/n): ") if sure_reset.lower() == 'y': app.reset_all() print('Done.') elif sure_reset.lower() == 'n': print('Reset canceled') else: print('Wrong choise!') # exit elif choise == 7: answer = input("Are you sure? ('Y/n')") if answer.lower() == 'y': break else: print("Wrong choise!!!")
def getPrograms(): ''' Get a dictionary of Programs and a list of Program names from the RSF self-documentation system. ''' import rsf.doc import rsf.prog programs = {} for progname in list(rsf.doc.progs.keys()): prog = rsf.doc.progs[progname] name = prog.name synopsis = prog.snps comments = prog.cmts desc = prog.desc file = prog.file also = prog.also wiki = prog.wiki vers = prog.vers uses = prog.uses.copy() program = Program(name,synopsis,comments,desc,uses,also,wiki,file,vers) for parname,par in list(prog.pars.items()): type = par.type.replace('\t','').replace('\n','').replace(' ','') desc = par.desc.replace('\t','').replace('\n','') default = par.default.replace('\t','').replace('\n','').replace(' ','') if default == '=': default = '' prange = par.range.replace('\t','').replace('\n','') parameter = Parameter(parname,type,desc,default,prange) program.add(parameter) custom = Parameter('custom','string','additional parameters specified by the user without key=val formatting','','') input = Parameter('input','string','input rsf file names','','') output = Parameter('output','string','output rsf file names','','') program.add(custom) program.add(input) program.add(output) programs[progname] = program for plotcommand in plotCommands.split(' '): name = plotcommand synopsis = 'Vppen command' comments = '' desc = '' file = '' also = '' wiki = '' vers = '' uses = {} program = Program(name,synopsis,comments,desc,uses,also,wiki,file,vers) custom = Parameter('custom','string','additional parameters specified by the user without key=val formatting','','') input = Parameter('input','string','input rsf file names','','') output = Parameter('output','string','output rsf file names','','') program.add(custom) program.add(input) program.add(output) programs[plotcommand] = program programNames = list(programs.keys()) programNames.sort() return programs, programNames
def getPrograms(): ''' Get a dictionary of Programs and a list of Program names from the RSF self-documentation system. ''' import rsf.doc import rsf.prog programs = {} for progname in rsf.doc.progs.keys(): prog = rsf.doc.progs[progname] name = prog.name synopsis = prog.snps comments = prog.cmts desc = prog.desc file = prog.file also = prog.also wiki = prog.wiki vers = prog.vers uses = prog.uses.copy() program = Program(name,synopsis,comments,desc,uses,also,wiki,file,vers) for parname,par in prog.pars.items(): type = par.type.replace('\t','').replace('\n','').replace(' ','') desc = par.desc.replace('\t','').replace('\n','') default = par.default.replace('\t','').replace('\n','').replace(' ','') if default == '=': default = '' prange = par.range.replace('\t','').replace('\n','') parameter = Parameter(parname,type,desc,default,prange) program.add(parameter) custom = Parameter('custom','string','additional parameters specified by the user without key=val formatting','','') input = Parameter('input','string','input rsf file names','','') output = Parameter('output','string','output rsf file names','','') program.add(custom) program.add(input) program.add(output) programs[progname] = program for plotcommand in plotCommands.split(' '): name = plotcommand synopsis = 'Vppen command' comments = '' desc = '' file = '' also = '' wiki = '' vers = '' uses = {} program = Program(name,synopsis,comments,desc,uses,also,wiki,file,vers) custom = Parameter('custom','string','additional parameters specified by the user without key=val formatting','','') input = Parameter('input','string','input rsf file names','','') output = Parameter('output','string','output rsf file names','','') program.add(custom) program.add(input) program.add(output) programs[plotcommand] = program programNames = programs.keys() programNames.sort() return programs, programNames