Re: [gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Delete empty directories

2019-12-04 Thread Zac Medico
On 12/4/19 6:12 PM, Matt Turner wrote:
> Closes: https://bugs.gentoo.org/671592
> Signed-off-by: Matt Turner 
> ---
>  pym/gentoolkit/eclean/clean.py | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py
> index b790de0..89300ce 100644
> --- a/pym/gentoolkit/eclean/clean.py
> +++ b/pym/gentoolkit/eclean/clean.py
> @@ -139,6 +139,10 @@ class CleanUp(object):
>   # only count size if successfully 
> deleted and not a link
>   if statinfo.st_nlink == 1:
>   clean_size += statinfo.st_size
> + try:
> + 
> os.rmdir(os.path.dirname(file_))
> + except OSError as er:
> + pass
>   except EnvironmentError as er:
>   print( pp.error("Could not delete 
> "+file_), file=sys.stderr)
>   print( pp.error("Error: %s" %str(er)), 
> file=sys.stderr)
> 

Looks good except you can omit " as er" since it's unused.
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


[gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Delete empty directories

2019-12-04 Thread Matt Turner
Closes: https://bugs.gentoo.org/671592
Signed-off-by: Matt Turner 
---
 pym/gentoolkit/eclean/clean.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py
index b790de0..89300ce 100644
--- a/pym/gentoolkit/eclean/clean.py
+++ b/pym/gentoolkit/eclean/clean.py
@@ -139,6 +139,10 @@ class CleanUp(object):
# only count size if successfully 
deleted and not a link
if statinfo.st_nlink == 1:
clean_size += statinfo.st_size
+   try:
+   
os.rmdir(os.path.dirname(file_))
+   except OSError as er:
+   pass
except EnvironmentError as er:
print( pp.error("Could not delete 
"+file_), file=sys.stderr)
print( pp.error("Error: %s" %str(er)), 
file=sys.stderr)
-- 
2.23.0