mirror of
https://github.com/Xevion/sharex-quickzoom.git
synced 2025-12-14 16:12:59 -06:00
cleaned up for file folder type recognition, some comments
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# sharex-quickzoom
|
# sharex-quickzoom
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The purpose of this project is to simply provide an easy way to apply a blur effect to an image using the ShareX application.
|
The purpose of this project is to simply provide an easy way to apply a blur effect to an image using the ShareX application.
|
||||||
The reasoning for zoom is mostly for personal humor.
|
The reasoning for zoom is mostly for personal humor.
|
||||||
|
|||||||
27
clean.py
27
clean.py
@@ -4,11 +4,11 @@ blacklist = [
|
|||||||
'clean.py',
|
'clean.py',
|
||||||
'main.py',
|
'main.py',
|
||||||
'LICENSE',
|
'LICENSE',
|
||||||
'output.jpg',
|
|
||||||
'screenshot.png',
|
'screenshot.png',
|
||||||
'README.md',
|
'README.md',
|
||||||
'.git',
|
'.git',
|
||||||
'.gitignore',
|
'.gitignore',
|
||||||
|
'resources'
|
||||||
]
|
]
|
||||||
|
|
||||||
def run(recycle=True, print_ignores=False):
|
def run(recycle=True, print_ignores=False):
|
||||||
@@ -19,25 +19,40 @@ def run(recycle=True, print_ignores=False):
|
|||||||
print_ignores {bool} -- True to print what files have been ignored (default: {False})
|
print_ignores {bool} -- True to print what files have been ignored (default: {False})
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# ternary raise support function, shouldn't ever be raised
|
||||||
|
def raiseMe(filePath):
|
||||||
|
raise('Invalid file or folder ; \'{}\''.format(filePath))
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
basepath = sys.path[0]
|
basepath = sys.path[0]
|
||||||
_log = []
|
_logFiles = []
|
||||||
|
_logFolders = []
|
||||||
|
getName = lambda someList : 'folder' if someList is _logFolders else 'file' if someList is _logFiles else '???'
|
||||||
|
|
||||||
print('Deletion sequence started')
|
print('Deletion sequence started')
|
||||||
for file in os.listdir(basepath):
|
for file in os.listdir(basepath):
|
||||||
filepath = os.path.join(basepath, file)
|
filepath = os.path.join(basepath, file)
|
||||||
|
# Take action on the offending file
|
||||||
if file not in blacklist:
|
if file not in blacklist:
|
||||||
_log.append('Recycled: \'{}\''.format(filepath))
|
|
||||||
# Send to recycle bin vs straightup permanently delete
|
# Send to recycle bin vs straightup permanently delete
|
||||||
|
curType = _logFiles if os.path.isfile(filepath) else _logFolders if os.path.isdir(filepath) else raiseMe(filepath)
|
||||||
|
# We want to recycle the file
|
||||||
if recycle:
|
if recycle:
|
||||||
send2trash.send2trash(filepath)
|
send2trash.send2trash(filepath)
|
||||||
|
curType.append('Recycled {}: \'{}\''.format(getName(curType), filepath))
|
||||||
|
# We want to permanently delete the file
|
||||||
else:
|
else:
|
||||||
os.remove(filepath)
|
os.remove(filepath)
|
||||||
|
curType.append('Deleted {}: \'{}\''.format(getName(curType), filepath))
|
||||||
else:
|
else:
|
||||||
if print_ignores:
|
if print_ignores:
|
||||||
_log.append('IGNORED: \'{}\''.format(filepath))
|
curType.append('Ignored {}: \'{}\''.format(getName(curType), filepath))
|
||||||
print('\n'.join(_log), end='\n' if _log else '')
|
|
||||||
print(f'Finished deleting {len(_log)} files')
|
# Clean up
|
||||||
|
ending = '\n' if (_logFiles or _logFolders) else ''
|
||||||
|
print('\n'.join(_logFiles), end=ending)
|
||||||
|
print('\n'.join(_logFolders), end=ending)
|
||||||
|
print(f'Finished deleting {len(_logFiles)} files and {len(_logFolders)} folders.')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB |
Reference in New Issue
Block a user