def menu(): """Main menu of the program. """ os.system('cls') print(Multiline.main_menu) user_input = utils.get_user_input(7) if user_input == 1: add_dvds.add_dvd() menu() elif user_input == 2: lookup_dvds.lookup_dvd() menu() elif user_input == 3: modify_dvds.modify_record() menu() elif user_input == 4: delete_dvd.delete_record() menu() elif user_input == 5: csvexport_dvd.generate_csv() menu() else: exit()
def modify_record(): """Modifies a dvd record in the DB. """ conn, c = utils.connect_to_db(utils.Config.DB_NAME) title = input(Multiline.modify_record_title), # tuple movie = c.execute(utils.SQLQuery.query_by_title, title).fetchone() print(Multiline.modify_record) if movie: utils.print_record(movie) print(utils.GenData.line_sep) user_input = utils.get_user_input(6) if user_input == 1: new_title = input("Enter the new DVD title name: "), update_column(conn, c, utils.SQLQuery.update_title, new_title[0], title[0]) mod_movie = get_modified_movie( c, utils.SQLQuery.query_by_title, new_title) elif user_input == 2: new_star = input("Enter the new DVD star name: ") update_column(conn, c, utils.SQLQuery.update_star, new_star, title[0]) mod_movie = get_modified_movie( c, utils.SQLQuery.query_by_title, title) elif user_input == 3: new_costar = input("Enter the new DVD costar name: ") update_column(conn, c, utils.SQLQuery.update_costar, new_costar, title[0]) mod_movie = get_modified_movie( c, utils.SQLQuery.query_by_title, title) elif user_input == 4: new_year = utils.get_year_input() c.execute(utils.SQLQuery.update_year, (new_year, title[0])) conn.commit() mod_movie = c.execute(utils.SQLQuery.query_by_title, title).fetchone() elif user_input == 5: new_genre = utils.get_genre_input(modify=True) c.execute(utils.SQLQuery.update_genre, (new_genre, title[0])) conn.commit() mod_movie = c.execute(utils.SQLQuery.query_by_title, title).fetchone() print(Multiline.modified_record) utils.print_record(mod_movie) c.close() conn.close() print(utils.GenData.line_sep) input(utils.GenData.enter_continue) else: print("Record not found.") input(utils.GenData.enter_continue)
def get_filters(): """ Asks user to specify a city, month and day to analyze. Returns: (str) city - name of the city to analyze (str) month - name of the month to filter by, or "all" to apply no month filter (str) day - name of the day of week to filter by, or "all" to apply no day filter """ city = get_user_input("Please enter the code for the city to analyse: CH (Chicago), NYC (New York City), WA (Washington ) ...", CITY_DATA.keys(), 'city') month = get_user_input("Please enter the month that you want to analyse: all, january, february, march, april, may, june ...", AVAILABLE_MONTHS, 'month') day = get_user_input("Please enter the day you want to analyse: all, monday, tuesday, wednesday, thursday, friday, saturday, sunday ...", DAYS_OF_WEEK, 'day') print('-'*40) return city, month, day
def make_guess(self): """requests user input,checks for guess.""" #### take letter and change values based on guess Uinput = get_user_input() # change for function if check_letter_in_word(self._word, Uinput): #check in word self._guessed_letters_cor.append(Uinput) print('Good guess love!') # reveal letters else: self._guessed_letters_incor.append(Uinput) self._guesses_remain -= 1 print('Sorry, bad guess :-(') #### display current status self._word_status = self._reveal_letters() self.status() return True
def generate_menu(query): action = query.get('get') if action == 'shows': xbmcplugin.setContent(handle, 'tvshows') if query.get('_filter') == 'genre': results = api.get_shows_by_genre(query['label']) elif query.get('_filter') == 'latest': results = api.get_latest() elif query.get('_filter') == 'simulcast': results = api.get_simulcast() elif query.get('_filter') == 'featured': results = api.get_featured() else: results = api.get_shows(first_letter=query.get('alpha')) add_shows(results) elif action == 'videos': xbmcplugin.setContent(handle, 'episodes') results = api.get_videos(query['show_id']) add_videos(results) elif action == 'search': keyword = utils.get_user_input('Search') if keyword: results = api.search(keyword) if results['shows']: add_shows(results['shows']) if results['episodes']: add_videos(results['episodes']) else: add_list_item({'label': _('no_results')}) elif action == 'genres': for genre in api.get_genres(): add_list_item({'label': genre, 'get': 'shows', '_filter': 'genre'}) elif action == 'alpha': for i in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'): add_list_item({'label': i, 'get': 'shows', 'alpha': i}) add_list_item({'label': '#', 'get': 'shows', 'alpha': 'non-alpha'})
def generate_menu(query): action = query.get('get') if action == 'shows': xbmcplugin.setContent(handle, 'tvshows') if query.get('_filter') == 'genre': results = api.get_shows_by_genre(query['label']) elif query.get('_filter') == 'latest': results = api.get_latest() elif query.get('_filter') == 'simulcast': results = api.get_simulcast() elif query.get('_filter') == 'featured': results = api.get_featured() else: results = api.get_shows(first_letter=query.get('alpha')) add_shows(results) elif action == 'videos': xbmcplugin.setContent(handle, 'episodes') results = api.get_videos(query['show_id']) add_videos(results) elif action == 'search': keyword = utils.get_user_input('Search') if keyword: results = api.search(keyword) add_videos(results) else: add_list_item({'label': _('no_results')}) elif action == 'genres': for genre in api.get_genres(): add_list_item({'label': genre, 'get': 'shows', '_filter': 'genre'}) elif action == 'alpha': for i in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'): add_list_item({'label': i, 'get': 'shows', 'alpha': i}) add_list_item({'label': '#', 'get': 'shows', 'alpha': 'non-alpha'})
self.tank.heat_loss_step() water_flow = self.pump.flow_quantity(self.tank.get_pumping_h()) self.tank.heat_loss_out(water_flow) heat_gen = self.collector.heat_generated(rad) # temp_out = self.collector.temp_out(heat_gen, self.tank.get_tank_temp(), water_flow) self.tank.heat_gain_in(water_flow, heat_gen) print("At {} - Radiation: {:.3f} Tank_Heat_Energy_J: {:.3f} Tank_Temp: {:.3f} Vol_Liq: {:.1f}" .format(time_step, rad, self.tank.get_tank_energy(), self.tank.get_tank_temp(), self.tank.get_volume_liq())) def reset(self): self.rad_iterator = get_radiation_data() self.tank.reset() if __name__ == '__main__': parameters = get_user_input() collector_model = SolarPanel(parameters.collector_area_sqm, parameters.collector_efficiency) pump_model = Pump(parameters.pump_power_hp, parameters.pump_efficiency, parameters.transmission_friction_m) tank_model = StorageTank(parameters.tank_vol_l, parameters.tank_in_flow_height_m, parameters.tank_out_flow_height_m, parameters.tank_heat_loss_factor, parameters.init_temp_k) print("Initiating a simulation environment with the provided values - {}".format(parameters)) env = SolarHeaterEnv(collector_model, pump_model, tank_model) print("Environment Initialized. Simulating the Environment for {} steps".format(parameters.steps)) for t in range(parameters.steps): env.step(t) # TODO: add logger and change print()