''' Created on 17 mag 2016 @author: oggei ''' import re from afpfapfap.main import NukedFile from afpfapfap import logging log = logging.get('cleaner') class Remover(object): patterns = ( re.compile(r'^:2eDS_Store$'), ) def sanitize(self, entry, suffix='', execute=False): if any(pattern.match(entry.name) for pattern in self.patterns): if execute: entry.unlink() raise NukedFile('{0} removed')
''' Created on 02/feb/2016 @author: oggei ''' import os from pathlib import Path import shutil from tempfile import mkdtemp, mkstemp import unittest from random import random from afpfapfap.main import clean_dir from afpfapfap import logging log = logging.get('tests') class TestIdempotency(unittest.TestCase): def setUp(self): super().setUp() self.tempdir = mkdtemp() self.path = Path(self.tempdir) def tearDown(self): super().tearDown() shutil.rmtree(self.tempdir) def populate(self, tempdir, depth=3, width=3): temp_file = None temp_child = None