First Round Async. Much work left to do, dont trust results of hash categorization presently.
This commit is contained in:
+10
-12
@@ -14,6 +14,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
@@ -99,15 +100,15 @@ def choose_file(initial_directory=None, required_substring=None):
|
||||
|
||||
|
||||
|
||||
|
||||
def get_sanitized_input(prompt: str) -> str:
|
||||
async def get_sanitized_input(prompt: str) -> str:
|
||||
while True:
|
||||
user_input = input(prompt)
|
||||
user_input = await asyncio.to_thread(input, prompt)
|
||||
if user_input.strip() == "":
|
||||
return user_input # Allow blank lines
|
||||
if re.match(r'^[a-zA-Z0-9_\- .]+$', user_input.strip()):
|
||||
return user_input
|
||||
if re.match(r'^[a-zA-Z0-9_ .-]+$', user_input.strip()):
|
||||
return user_input
|
||||
else:
|
||||
logger.debug("User entered invalid input")
|
||||
print("Invalid input. Only letters, numbers, underscores, spaces, hyphens, and periods are allowed.")
|
||||
|
||||
|
||||
@@ -695,14 +696,11 @@ def formatHTML(df, output_html_path=None, overwrite=True):
|
||||
|
||||
|
||||
|
||||
def open_directory(path):
|
||||
async def open_directory(path):
|
||||
system = platform.system()
|
||||
|
||||
if system == "Windows":
|
||||
os.startfile(path)
|
||||
await asyncio.to_thread(os.startfile, path)
|
||||
elif system == "Linux":
|
||||
subprocess.run(["xdg-open", path])
|
||||
await asyncio.to_thread(subprocess.run, ["xdg-open", path])
|
||||
else:
|
||||
raise OSError(f"Unsupported operating system: {system}")
|
||||
|
||||
|
||||
raise OSError(f"Unsupported operating system: {system}")
|
||||
Reference in New Issue
Block a user