Skip to content

Commit

Permalink
V0.33.0 Renaming of folders is now enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
domhnallmorr committed Jul 31, 2022
1 parent dc44b41 commit 09bd115
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Binary file modified src/__pycache__/branch_tab.cpython-39.pyc
Binary file not shown.
30 changes: 19 additions & 11 deletions src/branch_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def OnRightClick(self, event):
popup_menu.add_separator()

elif os.path.isdir(os.path.join(self.explorer.current_directory, file_name)):
popup_menu.add_command(label="Rename", command=lambda mode='edit', initialvalue=file_name: self.new_file(mode, initialvalue))
popup_menu.add_command(label="Rename", command=lambda mode='edit folder', initialvalue=file_name: self.new_file(mode, initialvalue))

else: # if file not selected, add plugin menu if any run_on_folders plugins are present
if len(plugins) > 0:
Expand Down Expand Up @@ -364,13 +364,13 @@ def new_folders(self):
self.mainapp.undo_redo_states.reset_redo()

#def rename_folder(sel)
def new_file(self, mode, initialvalue=''):
if mode == 'edit':
def new_file(self, mode, initialvalue=""):
if mode == "edit" or mode == "edit folder":
self.orig_file_name = initialvalue
elif mode == 'new excel':
initialvalue = '.xlsx'
elif mode == 'new word':
initialvalue = '.docx'
elif mode == "new excel":
initialvalue = ".xlsx"
elif mode == "new word":
initialvalue = ".docx"

if mode == "edit":
window_mode = "Rename"
Expand All @@ -388,7 +388,11 @@ def new_file(self, mode, initialvalue=''):
#check file does not exist
if mode == "new" or mode == "new excel" or mode == "new word":
if os.path.isfile(os.path.join(self.explorer.current_directory, new_name)):
msg = 'That File Already Exists!'
msg = "That File Already Exists!"

if mode == "edit folder":
if os.path.isdir(os.path.join(self.explorer.current_directory, new_name)):
msg = "That Folder Already Exists!"

# Check if user input is just a bunch of spaces
if new_name.strip() == '':
Expand All @@ -402,9 +406,9 @@ def new_file(self, mode, initialvalue=''):
messagebox.showerror('Error', message=msg)
self.new_file(mode, initialvalue=new_name)
else:
if mode == 'new':
if mode == "new":
with open(os.path.join(self.explorer.current_directory, new_name), 'w') as f:
f.write('')
f.write("")

# New Excel File
elif mode == 'new excel':
Expand All @@ -422,7 +426,11 @@ def new_file(self, mode, initialvalue=''):
except Exception as e:
if "being used by another" in str(e).lower():
msg = "Permission Denied, Ensure Document is not Open in Another Process"

elif "access is denied" in str(e).lower():
if mode == "edit folder":
msg = "Access Denied, Ensure No Files are Open in the Folder"
else:
msg = "Access Denied"
else:
msg = f"The Following Error Occured\n{str(e)}"

Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, parent, *args, **kwargs):
self.load_plugins()

def setup_variables(self):
self.version = "0.32.11"
self.version = "0.33.0"
self.parent.title(f"Tk Path Finder V{self.version}")
self.config_data = config_file_manager.load_config_file(self)
self.plugin_folder = ".\Plugins"
Expand Down

0 comments on commit 09bd115

Please sign in to comment.