def decrypt(filename): """Preprocesses data and runs user I/O for the print file Args: filename: the name of the .txt file containing the cipher text. """ # Reads and processes the cipher text cipher_text = fio.read_file_data(filename) words = cipher_text.split() for word in words: cipher_words.append(word) # Sets up dictionary subsets dictionary_words = fio.get_dictionary_words() for word in dictionary_words: if len(word) < SHORT_WORD_CUTOFF: short_words.append(word) else: long_words.append(word) # Counts and displays letter frequency for cribbing count_letter_frequency(cipher_text) print(frequency) cribbing_input() plaintext = decrypt_text() filename = input("Enter the (.txt) file you would like to write to: ") fio.write_to_file(filename, plaintext)
def movie_info(movie): rotten_tomatoes_rating=str(round(10-float(movie['imdbRating']),2)) result_str="\nTitle: "+movie['Title']+";"+'Year: '+movie['Year']+";" +'IMDB rating: '+movie['imdbRating']+";"+'Rotten Tomatoes Rating:'+rotten_tomatoes_rating+";"+'Country: '+movie['Country']+";"+'Language: '+movie['Language']+";"+'Plot: '+movie['Plot']+";"+'Actors: '+movie['Actors'] write_to_file(result_str.replace(";","\n")) print("_______________________________________________") for item in result_str.split(";"): print(item) print("_______________________________________________")
def process_insert_update(form_data): ''' Handle insert and update requests. @param form_data POST Values provided by user. @return boolean True if process is successful, otherwise False ''' table = fileio.read_from_file(DB_NAME) names = [ 'modID', 'storyTitle', 'userStory', 'criteria', 'businessValue', 'estimation', 'status' ] mod_record = [form_data[name] for name in names] if int(form_data['modID']) == -1: # insert mod_record[0] = str(int(table[len(table) - 1][0]) + 1) table.append(mod_record) updated_table = table else: # update updated_table = [ record for record in table if record[0] != mod_record[0] ] updated_table.append(mod_record) updated_table = sorted(updated_table, key=lambda x: int(x[0])) status = True if fileio.write_to_file(updated_table, DB_NAME) else False return status
def process_delete(story_id): ''' Handle delete requests. @param story_id int The id to be deleted. @return boolean True if process is successful, otherwise False ''' table = fileio.read_from_file(DB_NAME) updated_table = [line for line in table if int(line[0]) != story_id] status = True if fileio.write_to_file(updated_table, DB_NAME) else False return status
def decrypt(filename): """Preprocesses data and runs user I/O for the print file Args: filename: the name of the .txt file containing the cipher text. """ # Reads and processes the cipher text cipher_text = fio.read_file_data(filename) words = cipher_text.split() for word in words: cipher_words.append(word) # Counts and displays letter frequency for cribbing count_letter_frequency(cipher_text) plaintext = decrypt_text() print("Decrypted text:") print(plaintext) filename = input("Enter the (.txt) file you would like to write to: ") fio.write_to_file(filename, plaintext)
def song_info(song): tracks = song["tracks"] items = tracks["items"] if items: for item in items: artist = item["artists"][0]['name'] and item["artists"][0]['name'] or 'None' album = item["album"]["name"] and item["album"]["name"] or "None" song_name = item["name"] preview_link = item["preview_url"] and item["preview_url"] or "None" result_str = "Artist: " + artist + ";" "Name of song: "+song_name + ";" + "Preview link: " + preview_link + ";" + "Album name: " + album print("_______________________________________________\n") for item in result_str.split(";"): print(item) print("_______________________________________________") write_to_file(result_str.replace(";","\n")) else: print("Song not found!")