def setWindSpeed(): while (True): sys.stdout.write("Enter the wind speed:") temporary = str(input()) windRegex = "[1-9]|[0-9]{1,3}" if (extras.checkRegex(windRegex, temporary)): return temporary else: continue
def setWindDirection(): while (True): sys.stdout.write("Enter the wind direction:") windDirection = str(input()) directionRegex = "n|e|w|s|N|W|S|E|NE|SE|SW|NW|ne|sw|sw|nw" if (extras.checkRegex(directionRegex, windDirection)): return windDirection else: continue
def setTemp(): while(True): sys.stdout.write("\nEnter the temperature:") temporary = str(input()) tempRegex = "[-]?[0-9]{1,3}" if(extras.checkRegex(tempRegex, temporary)): if(temporary == "0"): print("Invalid input") continue else: return temporary else: continue
def loadLanguage(): with open("known.lang") as f: i = int(0) choice = int(-1) for line in f: i += 1 print(line) (key, val) = line.split() knownLang[int(key)] = val while (True): sys.stdout.write("Choice language(int):") temporary = str(input) tempRegex = "[1-9]|[0-9]{2,3}" if (extras.checkRegex(tempRegex, temporary)): if (int(temporary) > i): print("Not valid station") else: choice = int(temporary) loadChoice(choice) break else: continue
wind = "" direction = "" weatherHistory = [None] * size historyCount = 0 historyIndex = 0 while (True): print("\nNext Command") #2 print("0 to exit") #3 print("1 to input weather data") #4 print("2 to print out last data input") #5 print("3 to print up to the last " + str(size) + " histories") #6,7 sys.stdout.write("Input:") #8 mystr = input() repeatRegex = "[0-3]" if (extras.checkRegex(repeatRegex, mystr)): num = int(mystr) if (num == 0): sys.stdout.write("Goodbye Tom") #9 break elif (num == 1): current = weatherMeasurement.weatherMeasurement_t() #print("History Index: " + str(historyIndex)) weatherHistory[historyIndex] = current temp = current.temperature.temperature wind = current.wind.speed direction = current.wind.direction myFlagg = True historyCount += 1