Skip to content

Commit

Permalink
V0.56.1
Browse files Browse the repository at this point in the history
  • Loading branch information
domhnallmorr committed Nov 13, 2023
1 parent adf50b5 commit 3aa71c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, parent, *args, **kwargs):
self.controller = controller.Controller(root, parent, self)

# ----------------- VERSION -----------------------
self.version = "0.56.0"
self.version = "0.56.1"

# ----------------- WEEK NUMBER -----------------------
year, week_num, day_of_week = datetime.date.today().isocalendar()
Expand Down
40 changes: 23 additions & 17 deletions src/view/search_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ def __init__(self, master, data, view, file_extensions):

ttk.Label(self.text_search_options_frame, text="File Extension:").grid(row=5, column=0, padx=5, pady=5, sticky="E")
self.text_extension_combo = ttk.Combobox(self.text_search_options_frame, values=self.file_extensions)
self.text_extension_combo.set(self.file_extensions[0])
self.text_extension_combo.config(state="readonly")
if len(self.file_extensions) > 0:
self.text_extension_combo.set(self.file_extensions[0])
self.text_extension_combo.config(state="readonly")
else:
self.text_extension_combo.config(state="disabled")
self.text_extension_combo.grid(row=5, column=1, padx=5, pady=5, sticky="W")

self.case_insensitive = IntVar(value=0)
ttk.Checkbutton(self.text_search_options_frame, text="Case Insensitive", variable=self.case_insensitive).grid(row=6, column=0, padx=5, pady=5, sticky="E")
ttk.Checkbutton(self.text_search_options_frame, text="Case Insensitive", variable=self.case_insensitive).grid(row=6, column=1, padx=5, pady=5, sticky="W")

b2 = ttk.Button(self.text_search_options_frame, text="Search", width=10,
command=self.on_search_text, style="primary.TButton")
Expand Down Expand Up @@ -179,22 +182,25 @@ def on_search(self, event=None):
def on_search_text(self, event=None):
self.search_text.delete('1.0', END)

text_to_find = self.text_to_find_entry.get()
extensions_to_check = self.text_extension_combo.get()
if len(self.file_extensions):
text_to_find = self.text_to_find_entry.get()
extensions_to_check = self.text_extension_combo.get()

if self.case_insensitive.get() == 1:
command = ['findstr', "/I", f'{text_to_find}', f'{self.directory}\\*{extensions_to_check}']
else:
command = ['findstr', f'{text_to_find}', f'{self.directory}\\*{extensions_to_check}']

try:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True).stdout
self.search_text.insert(END, result)
except Exception as e:
if "non-zero" in str(e):
self.search_text.insert(END, "Failed to Find Matching Text")
if self.case_insensitive.get() == 1:
command = ['findstr', "/I", f'{text_to_find}', f'{self.directory}\\*{extensions_to_check}']
else:
self.view.show_error(str(e))
command = ['findstr', f'{text_to_find}', f'{self.directory}\\*{extensions_to_check}']

try:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True).stdout
self.search_text.insert(END, result)
except Exception as e:
if "non-zero" in str(e):
self.search_text.insert(END, "Failed to Find Matching Text")
else:
self.view.show_error(str(e))
else:
self.search_text.insert(END, "No Files in Directory")

def add_file_to_text(self, directory, filename):
if not filename.startswith('~$'): # avoid temporary files
Expand Down

0 comments on commit 3aa71c0

Please sign in to comment.