-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e08451
commit 4ef8bc6
Showing
31 changed files
with
1,066 additions
and
10,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
.env | ||
.vscode/ | ||
env/ | ||
__pycache__/ | ||
logic/__pycache__/ | ||
models/__pycache__/ | ||
sqlite_db.db | ||
venv/ | ||
formInfo.log | ||
.DS_Store | ||
queryInfo.log | ||
reports/ | ||
app/reports/ | ||
app/feedback | ||
.env | ||
.vscode/ | ||
env/ | ||
__pycache__/ | ||
sqlite_db.db | ||
venv/ | ||
formInfo.log | ||
.DS_Store | ||
queryInfo.log | ||
reports/ | ||
app/reports/ | ||
!app/logic/reports | ||
app/feedback | ||
api_response.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from pathlib import Path | ||
import re | ||
|
||
|
||
######################################################################### | ||
# find_example_use # | ||
# Search for and retrieve example usage of a specified software # | ||
# from text files in a given directory. # | ||
# parameters: # | ||
# software_name {str}: Name of the software to search for # | ||
# example_use_dir {str}: Directory path to search for example # | ||
# usage files (default: 'data/exampleUse') # | ||
# return: # | ||
# {str or bool}: Content of the first matching file if found, # | ||
# False if an error occurs or no match is found # | ||
# notes: # | ||
# - Searches for case-insensitive matches in file names # | ||
# - Returns the entire content of the first matching file # | ||
######################################################################### | ||
def find_example_use(software_name, example_use_dir = 'data/exampleUse'): | ||
|
||
normalized_software_name = re.escape(software_name).lower() | ||
|
||
# software name pattern to search for in the files | ||
pattern = re.compile(normalized_software_name, re.IGNORECASE) | ||
|
||
example_use_path = Path.cwd() / example_use_dir | ||
|
||
try: | ||
for file_path in example_use_path.iterdir(): | ||
if pattern.search(file_path.stem): # get only the file name (with extensions like .txt) | ||
with open(file_path, 'r') as file: | ||
example_use = file.read() | ||
return example_use | ||
|
||
except Exception as e: | ||
print(e) | ||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from datetime import datetime | ||
import pytz | ||
|
||
def get_last_updated(file_path="./static/last_updated.txt", timezone='US/Eastern'): | ||
""" | ||
returns datetime of when the software_table data was last updated | ||
""" | ||
with open(file_path, 'r') as luf: | ||
date_time = luf.readline().strip() | ||
|
||
try: | ||
date_obj = datetime.strptime(date_time, "%Y-%m-%d %H:%M:%S") | ||
# Format output | ||
output = date_obj.strftime("%B %d, %Y at %I:%M:%S %p Eastern Daylight Time") | ||
return output | ||
except Exception as e: | ||
print("ERROR trying to convert datetime", e) | ||
return(date_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from datetime import datetime | ||
from pathlib import Path | ||
import json | ||
|
||
|
||
######################################################################### | ||
# sanitize_and_process_feedback # | ||
# Process the user feedback. Currently no code is added to for # | ||
# sanitization. # | ||
# parameter: # | ||
# user_feedback {dict}: dict with feedback as a key and the # | ||
# feedback retrieved from the user as values # | ||
# return: # | ||
# report{dict}: dict with datetime and feedback as keys. datetime # | ||
# contains the date and time of when the report was received # | ||
######################################################################### | ||
def sanitize_and_process_feedback(user_feedback): | ||
# Pull user-submitted form contents from modal | ||
feedback_text = user_feedback['feedback'] | ||
|
||
# Generate timestamp | ||
current_datetime = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") | ||
|
||
# Create report | ||
report = { | ||
"datetime": current_datetime, | ||
"feedback": feedback_text, | ||
} | ||
|
||
return report | ||
|
||
######################################################################### | ||
# save_user_feedback # | ||
# creates a new directory for each feedback and dumps the feedback# | ||
# text into a json file inside the dir. # | ||
# parameter: # | ||
# feedback_report{dict}: dict with 'feedback' and 'datetime' as # | ||
# keys. obtained from sanitize_and_process_feedback function # | ||
# return: # | ||
# True{bool}: If feedback was successfully saved # | ||
# False{bool}: If there was an error saving the feedback # | ||
######################################################################### | ||
def save_user_feedback(feedback_report): | ||
|
||
try: | ||
# cwd Returns the current working directory. | ||
# In our case it returns the cwd of where the application was run from (the app dir) not this .py file | ||
feedback_folder = Path.cwd() / "feedback" / feedback_report['datetime'] | ||
feedback_folder.mkdir(parents=True, exist_ok=True) | ||
feedback_file = feedback_folder / "feedback.json" | ||
|
||
with open(feedback_file, 'w') as f: | ||
json.dump(feedback_report, f, indent=4) | ||
|
||
return True | ||
|
||
except Exception as e: | ||
print(e) | ||
|
||
return False | ||
|
Oops, something went wrong.