Added folder deletion

This commit is contained in:
2022-02-15 23:41:23 -05:00
parent 93ac4ef824
commit 0314bf36af
2 changed files with 21 additions and 8 deletions
+11 -4
View File
@@ -4,15 +4,22 @@
from os import remove, listdir
from os.path import expanduser
from shutil import rmtree
# utility functions
def delete(_file_path):
try:
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
except FileNotFoundError:
print('\nFile does not exist remotely.\n')
if _file_path.endswith('/'):
try:
rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}")
except FileNotFoundError:
print('\nFolder does not exist remotely.')
else:
try:
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
except FileNotFoundError:
print('\nFile does not exist remotely.\n')
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}.{_device_name}.del", 'w')