2024-04-22 17:13:43 -03:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import tkinter as tk
|
|
|
|
from tkinter import filedialog
|
|
|
|
|
|
|
|
def select_file():
|
2024-04-21 05:22:36 -03:00
|
|
|
"""
|
2024-04-22 17:13:43 -03:00
|
|
|
Opens a file dialog to select a .db file and returns the selected file path.
|
2024-04-21 05:22:36 -03:00
|
|
|
"""
|
2024-04-22 17:13:43 -03:00
|
|
|
root = tk.Tk()
|
|
|
|
root.withdraw() # Use to hide the tkinter root window
|
|
|
|
|
|
|
|
# Open file dialog and return the selected file path
|
|
|
|
file_path = filedialog.askopenfilename(
|
|
|
|
title="Select a .db file",
|
|
|
|
filetypes=(("DB files", "*.db"), ("All files", "*.*"))
|
|
|
|
)
|
|
|
|
return file_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
file_path = select_file()
|
|
|
|
if file_path: # Proceed only if a file was selected
|
|
|
|
with open(file_path, "r", encoding="utf-8-sig") as file:
|
|
|
|
lines = file.readlines()
|
2024-04-22 04:21:25 -03:00
|
|
|
|
2024-04-22 17:13:43 -03:00
|
|
|
udt_json = parse_udts(lines)
|
|
|
|
# Assume processing and file generation happens here, e.g., creating `output.txt`
|
|
|
|
output_file_path = os.path.join(os.path.dirname(file_path), "output.txt")
|
|
|
|
# Save or manipulate output files as needed
|
2024-04-22 04:21:25 -03:00
|
|
|
|
2024-04-22 17:13:43 -03:00
|
|
|
# Open the directory containing the new file in Explorer
|
|
|
|
open_file_explorer(os.path.dirname(output_file_path))
|
|
|
|
else:
|
|
|
|
print("No file was selected.")
|