def search(): print('this is search mode\n\n\n') while 1: clear() st = input('you want to search:') ac.search(st) save = input('save? y/n\n') if save != 'n': ac.save(st) print('saved') st = input('[enter]')
def train(): print('this is train mode') # while 1: trainset = ac.gettrainset() for i in range(len(trainset)): clear() print(i, 'word') print('\n' * 20) print(trainset[i]) ans = input('get? y/n') if ans == 'n': ac.search() save = input('save? y/n') if save == 'y': ac.save(y) st = input('[enter]')
def test_search(self): actions.register(connection, email='*****@*****.**', password='******') actions.auth(connection, "*****@*****.**", password='******', token=None) dumb_socket2 = DumbSocket() connection2 = Connection(dumb_socket2) actions.register(connection2, email='*****@*****.**', password='******') actions.auth(connection2, "*****@*****.**", password='******', token=None) dumb_socket3 = DumbSocket() connection3 = Connection(dumb_socket3) actions.register(connection3, email='*****@*****.**', password='******') actions.auth(connection2, "*****@*****.**", password='******', token=None) actions.add_friend(connection, email="*****@*****.**") actions.add_friend(connection, email="*****@*****.**") user = User.load('*****@*****.**') print user.get_friends() actions.search(connection, need="kitten")
def main(): #print '' log.setDebug(util.argv(_cmds['Debug'])) actions.supress(util.argv(_cmds['Supress'])) args = sys.argv if len(args) == 1: log.comment( "No arguments specified, listing your Gists. Try '%s help' if you need help." % util.fileName) print('') del args[0] # Delete the filename cmd = None log.debug("Arguments " + str(args)) #-------------------------------------------- # If args[0] is a command. We remove it from the list. args now contains only the command arguments # else we keep as is and try to evaluate the command #-------------------------------------------- if _hasCmd(args): cmd = args[0] del args[ 0] # Delete the command. Arguments remaining are the options for each command else: cmd = _deriveCmd(args) log.debug("Adjusted cmd: " + str(cmd)) log.debug("Adjusted arguments " + str(args)) #-------------------------------------------- # Handle commands #-------------------------------------------- if cmd == None: _printNoMatch() elif cmd in (_cmds['Help']): actions.help() elif cmd in (_cmds['List']): actions.list() elif cmd in (_cmds['Token']): actions.updateCredentials() elif cmd in (_cmds['Open']): if len(args) == 1: actions.open(args[0]) else: _printNoMatch() elif cmd in (_cmds['View']): if len(args) == 1: actions.view(args[0]) elif len(args) == 2: actions.view(args[0], fileName=args[1]) elif cmd in (_cmds['Download']): if len(args) == 2: actions.get(args[0], path=args[1]) elif len(args) == 3: actions.get(args[0], fileName=args[1], path=args[2]) elif cmd in (_cmds['New']): # Each option will prompt for public/pvt and description. In silent mode, assumes private and no description. if len(args) == 0: actions.new() elif len(args) == 1: # create File # create Content if util.isFileOrDir(args[0]) == True: actions.new(filename=args[0]) else: actions.new(content=args[0]) elif len(args) == 2: # create Boolean and File # create Boolean and Content # create Description and File # create Description and Content if util.parseBool(args[0]) != None: if util.isFileOrDir(args[1]) == True: actions.new(public=util.parseBool(args[0]), filename=args[1]) else: actions.new(public=util.parseBool(args[0]), content=args[1]) else: if util.isFileOrDir(args[1]) == True: actions.new(description=args[0], filename=args[1]) else: actions.new(description=args[0], content=args[1]) elif len(args) == 3 and util.parseBool(args[0]) != None: # create Boolean, Description and File # create Boolean, Description and Content if util.isFileOrDir(args[2]) == True: actions.new(public=util.parseBool(args[0]), description=args[1], filename=args[2]) else: actions.new(public=util.parseBool(args[0]), description=args[1], content=args[2]) else: _printNoMatch() elif cmd in (_cmds['Append']): # Each option will prompt for public/pvt and description. if len(args) == 0: _printNoMatch() elif len(args) == 2: # append: id File # append: id Content if util.isFileOrDir(args[1]) == True: actions.append(args[0], filename=args[1]) else: actions.append(args[0], content=args[1]) elif len(args) == 3: # append: id Description File # append: id Description Content if util.isFileOrDir(args[2]) == True: actions.append(args[0], description=args[1], filename=args[2]) else: actions.append(args[0], description=args[1], content=args[2]) else: actions.append(args[0]) elif cmd in (_cmds['Update']): # Each option will prompt for public/pvt and description. if len(args) == 0: _printNoMatch() elif len(args) == 2: # append: id File # append: id Content if util.isFileOrDir(args[1]) == True: actions.update(args[0], filename=args[1]) else: actions.update(args[0], content=args[1]) elif len(args) == 3: # append: id Description File # append: id Description Content if util.isFileOrDir(args[2]) == True: actions.update(args[0], description=args[1], filename=args[2]) else: actions.update(args[0], description=args[1], content=args[2]) else: actions.update(args[0]) elif cmd in (_cmds['Delete']): actions.delete(args[0]) elif cmd in (_cmds['Backup']): _printNoImpl() actions.backup() elif cmd in (_cmds['Search']): _printNoImpl() actions.search() else: _printNoMatch() log.debug("Done.") print('')
def search(): print("Search options:") print("2: Using Receipt No.") print("3: Using Customer Name") print("4: Using Date range") print("5: Using Time range") print("6: Using date and time ranges") print("0: Home") print("1: Sale Information") ch = input("Enter your choice: ") while ch not in '0123456' or len(ch) != 1: ch = input("Invalid choice! Enter again: ") if ch == '0': return '0' elif ch == '1': return '1' elif ch == '2': receipt = input("Enter Receipt No.: ") while not receipt.isdigit(): receipt = input("Receipt No. should be an integer! Enter again: ") cur.execute(f"select * from Sale where ReceiptNo like '%{receipt}%'") data = cur.fetchall() actions.format_print(actions.get_columns("Sale"), data) elif ch == '3': name = input("Enter Customer Name: ") actions.format_print( actions.get_columns("Sale"), actions.search("Sale", "CustomerName", "%" + name + "%", " like ")) elif ch == '4': start = input("Enter starting date(yyyy-mm-dd): ") start = actions.check_date(start) while not start: start = input( "Date you entered is not of correct format! Enter again(yyyy-mm-dd): " ) start = actions.check_date(start) print(f"Starting Date: {start}") end = input("Enter ending date(yyyy-mm-dd): ") end = actions.check_date(end) while not end: end = input( "Date you entered is not of correct format! Enter again(yyyy-mm-dd): " ) end = actions.check_date(end) print(f"Ending Date: {end}") actions.format_print( actions.get_columns("Sale"), actions.search_by_condition( "Sale", f"'{end}'>=SaleDate and SaleDate>='{start}'")) elif ch == '5': start = input("Enter starting time(hh:mm:ss): ") while not actions.check_time(start): start = input( "Time you entered is not of correct format! Enter again(hh:mm:ss): " ) end = input("Enter ending time(hh:mm:ss): ") while not actions.check_time(end): end = input( "Time you entered is not of correct format! Enter again(hh:mm:ss): " ) actions.format_print( actions.get_columns("Sale"), actions.search_by_condition( "Sale", f"'{end}'>=SaleTime and SaleTime>='{start}'")) elif ch == '6': start1 = input("Enter starting date(yyyy-mm-dd): ") start1 = actions.check_date(start1) while not start1: start1 = input( "Date you entered is not of correct format! Enter again(yyyy-mm-dd): " ) start1 = actions.check_date(start1) print(f"Starting date: {start1}") end1 = input("Enter ending date(yyyy-mm-dd): ") end1 = actions.check_date(end1) while not end1: end1 = input( "Date you entered is not of correct format! Enter again(yyyy-mm-dd): " ) end1 = actions.check_date(end1) print(f"Ending Date: {end1}") start2 = input("Enter starting time(hh:mm:ss): ") while not actions.check_time(start2): start2 = input( "Time you entered is not of correct format! Enter again(hh:mm:ss): " ) end2 = input("Enter ending time(hh:mm:ss): ") while not actions.check_time(end2): end2 = input( "Time you entered is not of correct format! Enter again(hh:mm:ss): " ) actions.format_print( actions.get_columns("Sale"), actions.search_by_condition( "Sale", f"""'{end2}'>=SaleTime and SaleTime>='{start2}' and '{end1}'>=SaleDate and SaleDate>='{start1}'"""))
def main ( ): #print '' log.setDebug( util.argv( _cmds['Debug'] ) ) actions.supress( util.argv( _cmds['Supress']) ) args = sys.argv if len(args) == 1: log.comment ("No arguments specified, listing your Gists. Try '%s help' if you need help." % util.fileName) print '' del args[0] # Delete the filename cmd = None log.debug ("Arguments " + str( args )) #-------------------------------------------- # If args[0] is a command. We remove it from the list. args now contains only the command arguments # else we keep as is and try to evaluate the command #-------------------------------------------- if _hasCmd( args ): cmd = args[0] del args[0] # Delete the command. Arguments remaining are the options for each command else: cmd = _deriveCmd( args ) log.debug ("Adjusted cmd: " + str(cmd)) log.debug ("Adjusted arguments " + str( args )) #-------------------------------------------- # Handle commands #-------------------------------------------- if cmd == None: _printNoMatch() elif cmd in (_cmds['Help']): actions.help() elif cmd in (_cmds['List']): actions.list() elif cmd in (_cmds['Token']): actions.updateCredentials() elif cmd in (_cmds['View']): if len(args) == 1: actions.view( args[0] ) elif len(args) == 2: actions.view( args[0], fileName=args[1]) elif cmd in (_cmds['Download']): if len(args) == 2: actions.get( args[0], path=args[1] ) elif len(args) == 3: actions.get( args[0], fileName=args[1], path=args[2] ) elif cmd in (_cmds['New']): # Each option will prompt for public/pvt and description. In silent mode, assumes private and no description. if len(args) == 0: actions.new() elif len(args) == 1: # create File # create Content if util.isFileOrDir(args[0]) == True: actions.new( filename = args[0] ) else: actions.new( content = args[0] ) elif len(args) == 2: # create Boolean and File # create Boolean and Content # create Description and File # create Description and Content if util.parseBool( args[0] ) != None: if util.isFileOrDir(args[1]) == True: actions.new( public=util.parseBool( args[0] ), filename=args[1] ) else: actions.new( public=util.parseBool( args[0] ), content=args[1] ) else: if util.isFileOrDir(args[1]) == True: actions.new( description=args[0], filename=args[1] ) else: actions.new( description=args[0], content=args[1] ) elif len(args) == 3 and util.parseBool( args[0] ) != None: # create Boolean, Description and File # create Boolean, Description and Content if util.isFileOrDir(args[2]) == True: actions.new( public=util.parseBool( args[0] ), description=args[1], filename=args[2] ) else: actions.new( public=util.parseBool( args[0] ), description=args[1], content=args[2] ) else: _printNoMatch() elif cmd in (_cmds['Append']): # Each option will prompt for public/pvt and description. if len(args) == 0: _printNoMatch() elif len(args) == 2: # append: id File # append: id Content if util.isFileOrDir(args[1]) == True: actions.append( args[0], filename=args[1] ) else: actions.append( args[0], content=args[1] ) elif len(args) == 3: # append: id Description File # append: id Description Content if util.isFileOrDir(args[2]) == True: actions.append( args[0], description=args[1], filename=args[2] ) else: actions.append( args[0], description=args[1], content=args[2] ) else: actions.append( args[0] ) elif cmd in (_cmds['Update']): # Each option will prompt for public/pvt and description. if len(args) == 0: _printNoMatch() elif len(args) == 2: # append: id File # append: id Content if util.isFileOrDir(args[1]) == True: actions.update( args[0], filename=args[1] ) else: actions.update( args[0], content=args[1] ) elif len(args) == 3: # append: id Description File # append: id Description Content if util.isFileOrDir(args[2]) == True: actions.update( args[0], description=args[1], filename=args[2] ) else: actions.update( args[0], description=args[1], content=args[2] ) else: actions.update( args[0] ) elif cmd in (_cmds['Delete']): actions.delete( args[0] ) elif cmd in (_cmds['Backup']): _printNoImpl() actions.backup( ) elif cmd in (_cmds['Search']): _printNoImpl() actions.search( ) else: _printNoMatch() log.debug ("Done.") print ''