From 351cd75a09c06182b3b1c6c1c654feb54f8053e8 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Mon, 19 Dec 2005 18:25:04 +0000 Subject: [PATCH] Add reqular expression matching for eclean. Bug 114365 svn path=/; revision=268 --- trunk/ChangeLog | 10 ++++++++-- trunk/src/eclean/ChangeLog | 4 ++++ trunk/src/eclean/eclean | 24 +++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/trunk/ChangeLog b/trunk/ChangeLog index ede1f64..ea45431 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,9 @@ +2005-12-19 Paul Varner + * eclean: Add regular expression matching for exclude files (Bug 114365) + +2005-12-13 Paul Varner + * equery: Fix USE flag parsing. (Bug 115294) + 2005-12-07 Paul Varner * revdep-rebuild: Fix revdep-rebuild to work with findutils-4.2.27. (bug 111203) @@ -77,8 +83,8 @@ be missed. (bug 97171) 2005-06-07 Paul Varner - * revdep-rebuild: Delete temporary files if the environment does not match the previous - environment (bug 95274) + * revdep-rebuild: Delete temporary files if the environment does not + match the previous environment (bug 95274) 2005-06-05 Paul Varner * revdep-rebuild: Imported revdep-rebuild release from bug 62644 diff --git a/trunk/src/eclean/ChangeLog b/trunk/src/eclean/ChangeLog index ad8a0ef..36d9a28 100644 --- a/trunk/src/eclean/ChangeLog +++ b/trunk/src/eclean/ChangeLog @@ -1,3 +1,7 @@ +2005-12-19 Paul Varner + * Add support for reqular expression matching for file names in the + exclude files. + 2005-08-28 Thomas de Grenier de Latour (tgl) * Version 0.4.1 * added support for some "eclean-dist" and "eclean-pkg" symlinks on eclean diff --git a/trunk/src/eclean/eclean b/trunk/src/eclean/eclean index 0b0b6ce..c631cea 100644 --- a/trunk/src/eclean/eclean +++ b/trunk/src/eclean/eclean @@ -450,7 +450,13 @@ def parseExcludeFile(filepath): else: raise ParseExcludeFileException("Invalid cat/pkg: "+mycp) except: pass #raise ParseExcludeFileException("Invalid line: "+line) - excl_dict['garbage'][line] = None + try: + excl_dict['garbage'][line] = re.compile(line) + except: + try: + excl_dict['garbage'][line] = re.compile(re.escape(line)) + except: + raise ParseExcludeFileException("Invalid file name/regular expression: "+line) return excl_dict @@ -551,8 +557,20 @@ def findDistfiles( \ continue if time_limit and (file_stat[stat.ST_MTIME] >= time_limit): continue - if 'garbage' in exclude_dict and file in exclude_dict['garbage']: - continue + if 'garbage' in exclude_dict: + # Try to match file name directly + if file in exclude_dict['garbage']: + file_match = True + # See if file matches via regular expression matching + else: + file_match = False + for file_entry in exclude_dict['garbage']: + if exclude_dict['garbage'][file_entry].match(file): + file_match = True + break + + if file_match: + continue # this is a candidate for cleaning clean_dict[file]=[filepath] # remove files owned by some protected packages -- 2.26.2