This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Util.py
65 lines (57 loc) · 2.39 KB
/
Util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright Notice for YitongSuperProf
# Copyright (c) at Carina Schoppe 2021
# File created on 18.12.21, 16:10 by Carina Latest changes made by Carina on 18.12.21, 16:10
# All contents of "Util.py" are protected by copyright.
# The copyright law, unless expressly indicated otherwise, is
# at Carina Schoppe. All rights reserved
# Any type of duplication, distribution, rental, sale, award,
# Public accessibility or other use
# requires the express written consent of Carina Schoppe.
import main
from Analysator import analyse_pdf_files_for_content
from Searcher import get_website_links
def getInputs() -> None:
main.download_path = input("Enter the path to the folder where the files should be: ")
if main.download_path == "":
return getInputs()
folder = input("Analyse folder? (y/n): ").lower()
if folder != "y" and folder != "n":
return getInputs()
main.analyse_folder = folder == "y"
if not main.analyse_folder:
straight = input("Analyse straight? (y/n): ").lower()
if straight != "y" and straight != "n":
return getInputs()
main.analyse_straight = straight == "y"
if not main.analyse_folder:
main.queries = input("Enter the queries (separated by comma): ")
if main.queries == "" and not main.analyse_folder:
return getInputs()
main.queries = main.queries.split(",")
filter_words = input("Enter the words that should be filtered (separated by comma): ")
main.words.clear()
if filter_words != "":
filter_words = filter_words.split(",")
for word in filter_words:
main.words[word] = getNumer(word)
if not main.analyse_folder:
main.search_result_amounts = getInputNumer()
print("\nInput is done starting the program!\n")
if main.analyse_folder:
analyse_pdf_files_for_content(file=None, filter_dict=main.words, analysor=True)
else:
get_website_links(main.queries, main.search_result_amounts)
def getNumer(word: str) -> int:
try:
x = int(input(f"Enter the amount of \"{word}\" that should be found: "))
return x
except Exception:
print("Please enter a number!")
return getNumer(word)
def getInputNumer() -> int:
try:
x = int(input("Enter the amount of search results: "))
return x
except Exception:
print("Please enter a number!")
return getInputNumer()