From 37f12041c349d6cff5d5d5f4ca5934edc47b06f2 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Tue, 8 Mar 2011 00:05:36 -0800 Subject: [PATCH] add a dotfile check and only delete hidden (.dotfile's) during a destructive search. --- pym/gentoolkit/eclean/search.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py index e29bbfc..4992ad7 100644 --- a/pym/gentoolkit/eclean/search.py +++ b/pym/gentoolkit/eclean/search.py @@ -124,7 +124,7 @@ class DistfilesSearch(object): self.output("...checking limits for %d ebuild sources" %len(pkgs)) - checks = self._get_default_checks(size_limit, time_limit, exclude) + checks = self._get_default_checks(size_limit, time_limit, exclude, destructive) checks.extend(extra_checks) clean_me = self._check_limits(_distdir, checks, clean_me) # remove any protected files from the list @@ -140,7 +140,7 @@ class DistfilesSearch(object): ####################### begin _check_limits code block - def _get_default_checks(self, size_limit, time_limit, excludes): + def _get_default_checks(self, size_limit, time_limit, excludes, destructive): #checks =[(self._isreg_check_, "is_reg_check")] checks =[self._isreg_check_] if 'filenames' in excludes: @@ -159,6 +159,10 @@ class DistfilesSearch(object): checks.append(partial(self._time_check_, time_limit)) else: self.output(" - skipping time limit check") + if destructive: + self.output(" - skipping dot files check") + else: + checks.append(self._dotfile_check_) return checks @@ -234,6 +238,14 @@ class DistfilesSearch(object): return True, False return False, True + @staticmethod + def _dotfile_check_(file_stat, file): + """check if file is a regular file.""" + head, tail = os.path.split(file) + if tail: + is_dot_file = tail.startswith('.') + return is_dot_file, not is_dot_file + ####################### end _check_limits code block @staticmethod -- 2.26.2