Skip to content

Commit a1673d7

Browse files
committed
flake8 Linting fixes
1 parent 0e81747 commit a1673d7

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

desktop_cleanup/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Script to automatically deletes/ lists all files recursively in desktop which havent been modified
1+
22

33
Script expect the user to pass limit in days beyond which the file if not modified would be listed/ deleted
44
depending on the arguments provided to the scipts

desktop_cleanup/main.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ def __init__(self):
1111
self._args = self.cli_parse()
1212
self._desktop_path = self.get_desktop_path()
1313
self.logger = logging.getLogger(__name__)
14-
logging.basicConfig(filename='Log.log', filemode='w', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
14+
logging.basicConfig(filename='Log.log', filemode='w',
15+
level=logging.INFO,
16+
format='%(asctime)s - %(levelname)s - %(message)s')
1517
self._files_paths = []
1618

1719
@staticmethod
1820
def cli_parse():
19-
arg_parser = argparse.ArgumentParser(prog='Desktop cleanup', description='Automation script to \
20-
clean up old desktop files')
21-
arg_parser.add_argument("--delete", type=int, required=False, help='Flag to delete the files')
22-
arg_parser.add_argument("--limit", type=int, required=True, help='No of days to check for')
21+
arg_parser = argparse.ArgumentParser(prog='Desktop cleanup',
22+
description='Automation script to clean up old desktop files')
23+
arg_parser.add_argument("--delete", type=int,
24+
required=False,
25+
help='Flag to delete the files')
26+
27+
arg_parser.add_argument("--limit", type=int,
28+
required=True,
29+
help='No of days to check for')
2330
return arg_parser.parse_args()
2431

2532
@staticmethod
@@ -34,7 +41,7 @@ def get_desktop_path():
3441
return _username_path
3542

3643
def delete_files(self):
37-
self.logger.info(f"Deleting all the files \n")
44+
self.logger.info("Deleting all the files \n")
3845
for file_path in self._files_paths:
3946
try:
4047
os.remove(file_path)
@@ -48,8 +55,7 @@ def delete_files(self):
4855

4956
def scan_desktop(self):
5057

51-
52-
for dirpath,_,files in os.walk(self._desktop_path):
58+
for dirpath, _, files in os.walk(self._desktop_path):
5359
self.logger.info("Walking through all files in desktop\n")
5460
for file in files:
5561
file_path = str(os.path.join(dirpath, file))
@@ -65,18 +71,15 @@ def scan_desktop(self):
6571
self.logger.info(f"{file_path} is exceeding threshold - last modified {delta_days.days} ago\n")
6672
self._files_paths.append(file_path)
6773

68-
if self._args.delete and len(self._files_paths)>0:
74+
if self._args.delete and len(self._files_paths) > 0:
6975
self.delete_files()
7076
elif len(self._files_paths) > 0:
71-
self.logger.info(f"Delete option not selected - so only logging file names\n")
77+
self.logger.info("Delete option not selected - so only logging file names\n")
7278
else:
73-
self.logger.info(f"No files exceeding the limit\n")
79+
self.logger.info("No files exceeding the limit\n")
80+
7481

75-
if __name__=='__main__':
82+
if __name__ == '__main__':
7683

7784
desktop_cleaner = DesktopCleaner()
7885
desktop_cleaner.scan_desktop()
79-
80-
81-
82-

0 commit comments

Comments
 (0)