Example #1
0
File: 1B.py Project: etscrivner/dse
def main():
    """Application entry point"""
    print "Exercise 1B"
    print "==========="
    print "This program allows you to write or read a file containing floating"
    print "point values."
    print
    read_write = io.binary_choice("Mode ((r)ead/(w)rite): ", "r", "w")
    file_path = io.get_and_confirm_input("Please enter a file name: ")
    if read_write == "r":
        read_file(file_path)
    else:
        write_file(file_path)
Example #2
0
File: 8B.py Project: etscrivner/dse
def prompt_for_output_file(original_file_name):
    """Prompt for the file to output data into

    Arguments:
        original_file_name(str): The original file name.

    Returns:
        str: The new file name if a new file is entered, otherwise the original
             file name.
    """
    print 'Original file: {}'.format(original_file_name)
    choice = io.binary_choice('Output file (s)ame/(n)ew file? ', 's', 'n')
    if choice == 'n':
        new_file_name = io.prompt_valid_file_name('New file name: ')
        return new_file_name
    return original_file_name
Example #3
0
File: 3B.py Project: etscrivner/dse
def prompt_for_output_file(original_file_name):
    """Prompt for the file to output data into

    Arguments:
        original_file_name(str): The original file name.

    Returns:
        str: The new file name if a new file is entered, otherwise the original
             file name.
    """
    print "Origin file: {}".format(original_file_name)
    choice = io.binary_choice("Output file (s)ame/(n)ew file? ", "s", "n")
    if choice == "n":
        new_file_name = io.get_and_confirm_input("New file name: ")
        return new_file_name
    return original_file_name