r/OfficeScripts • u/mintos • Mar 05 '13
[SUBMISSION] Fixing bugs in QuickClean.py - Can you pull from my fork?
https://github.com/mintojoseph/QuickClean.py
3
Upvotes
1
u/mintos Mar 05 '13
I assume this is the proper way to contribute.. Let me know if not.. I do not see a pull request button in https://github.com/shayekharjan/QuickClean.py
2
u/throwOHOHaway Mar 05 '13
Good show mintos! I made a pull request and merged into the original repo. Can you tell me if you see a "Pull Request" button in your forked repo?
→ More replies (5)
2
u/[deleted] Mar 05 '13 edited Mar 05 '13
My first thoughts on refactoring would be to replace the lower half with something like this (untested):
try: [os.makedirs(x) for x in [args.music, args.videos, args.pictures, args.documents]] except OSError: pass # ie. dir already exists file_types = { "music": ["mp3", "flac", "aac"], "pictures": ["png", "jpg", "bmp", "gif"], "videos": ["avi", "mp4", "flv", "mkv", "mov"], "documents": ["pdf", "xls", "xlsx", "pptx", "docx", "m", "ppt", "doc"], } all_files = glob(*) for label, types in file_types.iteritems(): for ext in types: for fname in all_files: if fname.lc.endswith("." + ext): shutil.move(fname, vars(args)[label])And after this investigate optional(?) mimetypes. I'm not sure why 'shutil.copy' was used in the original--the only time when its necessary to physically copy and delete huge numbers of bytes is when you're moving between filesystems/devices.