示例#1
0
文件: menus.py 项目: sonipta/test
    def handle_input():
        """
        Prompts the user for a choice and calls the function from the 'modules' folder that corresponds
        with that choice.
        """
        userChoice = input()

        # Choice 1 is downloading all json and pdf files.
        if userChoice == "1":
            clear()
            print(
                "\nUpon pressing ENTER, a file browser will open.\nPlease select your input CSV file."
            )
            input()
            # Opens a graphical file browser and returns the path to the csv file that the user selected.
            csvChoice = file_browser.browseCSVFiles()

            # Assigns the choice to a global variable, so other modules can find the path that the user specified.
            global_variables.CSV_INPUT_PATH = csvChoice
            clear()
            menus.select_paths_menu()
            clear()
            menus.specify_client_matter_menu()
            print(msg)
            get_json_and_pdfs()
        # Choice 2 is donwloading only JSON files.
        elif userChoice == "2":
            clear()
            print(
                "\nUpon pressing ENTER, a file browser will open.\nPlease select your input CSV file."
            )
            input()
            # Opens a graphical file browser and returns the path to the csv file that the user selected.
            csvChoice = file_browser.browseCSVFiles()
            # Assigns the choice to a global variable, so other modules can find the path that the user specified.
            global_variables.CSV_INPUT_PATH = csvChoice
            clear()
            menus.select_paths_menu(pdfOption=False)
            menus.specify_client_matter_menu()
            print(msg)
            get_json.thread_download_json()
        # Choice 3 is downloading only PDF files.
        elif userChoice == "3":
            clear()
            menus.select_paths_menu()
            menus.specify_client_matter_menu()
            print(msg)
            link_list = get_pdfs.get_urls("json-output")
            get_pdfs.thread_download_pdfs(link_list)
        elif userChoice == "4":
            spreadsheet_generator_menu()
        elif userChoice == "5":
            clear()
            menus.other_options_menu()

        # If the user enters anything other than a valid choice, then it tells them their choice is invalid and
        # restarts this function, prompting them to make a choice again.
        else:
            print("Please Enter Valid input (1, 2 or 3)")
            return handle_input()
示例#2
0
文件: menus.py 项目: sonipta/test
def get_json_and_pdfs():
    """
    This function calls the function to download JSON first, immediately followed by the function to download
    PDFs. This is used when the user chooses the menu choice to download both.
    """

    # The function that downloads the JSON files
    # get_json.loop_dataframe()
    get_json.thread_download_json()

    # The function that extracts the proper arguments to pass to the function for downloading PDFs using multiprocessing.
    # That function requires a list of tuples, each tuple being a seperate set of arguments to pass.
    link_list = get_pdfs.get_urls("json-output")

    # This function uses threading on the function that downloads PDFs, allowing us to download multiple PDFs at once,
    # speeding up the process.
    get_pdfs.thread_download_pdfs(link_list)
示例#3
0
文件: gui.py 项目: sonipta/test
def display_main_window():
    """
    Displays the main window of the program.
    This window prompts the user for the paths for their CSV, their PDF files, and their JSON files.
    """
    while True:
        # Read() opens the window of our choice.
        # Event is the key for the button pressed. We can make logic around this to give buttons their abilities.
        # Values is a dictionary containing any information the user entered into the program.
        event, values = window.read()
        print(
            event, values
        )  # For debugging - Prints buttons pressed, and values returned to the console.
        # If the user selects the 'Get JSON & PDFs' button, we run the function that gets JSON and PDF files.
        if event == "getJSON_PDF":
            # Sets the path choices specified as the global variables that can be used throughout the whole program
            # to reference their choice.
            declare_globals(event, values)
            # Downloads JSON files and PDF files.
            main.get_json_and_pdfs()
        # If the user selects the 'Get JSON' button, we run the function that gets JSON files.
        if event == "getJSON":
            # Sets the path choices specified as the global variables that can be used throughout the whole program
            # to reference their choice.
            declare_globals(event, values)
            # Downloads JSON files.
            get_json.loop_dataframe()
        # If the user selects the 'Get PDFs' button, we run the function that gets the PDF files.
        # (JSON files must be downloaded first to use this option.)
        if event == "getPDF":
            # Sets the path choices specified as the global variables that can be used throughout the whole program
            # to reference their choice.
            declare_globals(event, values)
            # Gets all the links to PDF files from within the json files in the directory the user specified.
            # This is a list of tuples.
            link_list = get_pdfs.get_urls("json-output")
            # Downloads all of the PDF files. Takes the link list from above as an argument.
            get_pdfs.thread_download_pdfs(link_list)
        # If the user closes the window with the "X" in the corner...
        if event == sg.WIN_CLOSED:
            # Close the window.
            break
示例#4
0
    def handle_input():
        """
        Prompts the user for a choice and calls the function from the 'modules' folder that corresponds
        with that choice.
        """
        userChoice = input()

        # Choice 1 is downloading all json and pdf files.
        if userChoice == "1":
            clear()
            menus.select_paths_menu()
            clear()
            menus.specify_client_matter_menu()
            print(msg)
            get_json_and_pdfs()
        # Choice 2 is donwloading only JSON files.
        elif userChoice == "2":
            clear()
            menus.select_paths_menu(pdfOption=False)
            menus.specify_client_matter_menu()
            print(msg)
            get_json.thread_download_json()
        # Choice 3 is downloading only PDF files.
        elif userChoice == "3":
            clear()
            menus.select_paths_menu()
            menus.specify_client_matter_menu()
            print(msg)
            link_list = get_pdfs.get_urls("json-output")

            # get_pdfs.multiprocess_download_pdfs(link_list)
            get_pdfs.thread_download_pdfs(link_list)
        elif userChoice == "4":
            clear()
            menus.other_options_menu()

        # If the user enters anything other than a valid choice, then it tells them their choice is invalid and
        # restarts this function, prompting them to make a choice again.
        else:
            print("Please Enter Valid input (1, 2 or 3)")
            return handle_input()