Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from datetime import datetime 

2 

3from sdc_etl_libs.sdc_filetransfer.utils.delete_files_mechanism.DeleteCriteria import \ 

4 DeleteCriteria 

5 

6 

7class AfterNDaysDeleteCriteria(DeleteCriteria): 

8 

9 def __init__(self, days_threshold): 

10 self.days_threshold = days_threshold 

11 

12 def get_files_to_delete(self, files): 

13 """ 

14 Filter the files with a modification date older than "days_threshold" days 

15 :param files: List of sftp files 

16 :type files: List(SFTPAttributes) 

17 :return: list of filtered SFTPAttributes objects 

18 :rtype: List(SFTPAttributes) 

19 """ 

20 return [ 

21 file for file in files 

22 if (datetime.now() - datetime.fromtimestamp(file.st_mtime)).days >= self.days_threshold 

23 ]