From 1318886864a742d9434ef26d976d400339069868 Mon Sep 17 00:00:00 2001 From: davidmunoznovoa Date: Tue, 13 Feb 2024 15:40:14 +0100 Subject: [PATCH] Add version control --- mesures/p5d.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mesures/p5d.py b/mesures/p5d.py index a1b8f1e..79b24ab 100644 --- a/mesures/p5d.py +++ b/mesures/p5d.py @@ -104,6 +104,12 @@ def writer(self): P5D contains an hourly raw curve :return: file path """ + existing_files = os.listdir('/tmp') + if existing_files: + versions = [int(f.split('.')[1]) for f in existing_files if self.filename.split('.')[0] in f] + if versions: + self.version = max(versions) + 1 + file_path = os.path.join('/tmp', self.filename) kwargs = {'sep': ';', 'header': False,