diff --git a/sen2chain/tiles.py b/sen2chain/tiles.py index 5a4a7f8fc262478a058b22f0af7d719c71ceacb5..e5be5ce91fcc3896c3c44438257fe31af29882c6 100644 --- a/sen2chain/tiles.py +++ b/sen2chain/tiles.py @@ -10,6 +10,7 @@ import fiona import shutil from PIL import Image import distutils +import os from pathlib import Path from collections import namedtuple @@ -976,5 +977,15 @@ class Tile: for indice in [val for sublist in [getattr(self, i) for i in [p for p in self.paths["indices"]]] for val in sublist]: IndiceProduct(identifier = indice.identifier) - - + def remove_l2a(self): + """ + Remove l2a files + """ + for product in self.l2a: + l2a = L2aProduct(product.identifier) + if l2a.path.is_symlink(): + l2a_path = os.readlink(str(l2a.path)) + logger.info("Removing: {}".format(l2a_path)) + shutil.rmtree(l2a_path) + logger.info("Removing symlink: {}".format(l2a.path)) + l2a.path.unlink()