From ed8e4ce0313f78d21c73b806f2dd06ee80d6f042 Mon Sep 17 00:00:00 2001
From: Impact <pascal.mouquet@ird.fr>
Date: Fri, 26 Feb 2021 14:26:04 +0400
Subject: [PATCH] new remove_l1c tile function

---
 sen2chain/tiles.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/sen2chain/tiles.py b/sen2chain/tiles.py
index 83993ec..00a5655 100644
--- a/sen2chain/tiles.py
+++ b/sen2chain/tiles.py
@@ -976,7 +976,24 @@ 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_l1c(self):
+        """
+        Remove l1c files
+        """
+        for product in self.l1c:
+            l1c = L1cProduct(product.identifier)
+            if l1c.path.is_symlink():
+                l1c_path = os.readlink(str(l1c.path))
+                logger.info("Removing: {}".format(l1c_path))
+                shutil.rmtree(l1c_path)
+                logger.info("Removing symlink: {}".format(l1c.path))
+                l1c.path.unlink()
+            else:
+                #~ l1c_path = os.readlink(str(l1c.path))
+                logger.info("Removing: {}".format(l1c.path))
+                shutil.rmtree(str(l1c.path))
+                
     def remove_l2a(self):
         """
         Remove l2a files
-- 
GitLab