diff --git a/CHANGELOG.md b/CHANGELOG.md index 7237ba4..0de7080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.2.2](https://github.com/ssenart/PyGazpar/compare/1.2.1...1.2.2) - 2024-05-08 + +### Fixed +- [#65](https://github.com/ssenart/PyGazpar/issues/65): [Bug] PermissionError happens when loading data from Excel file. ## [1.2.1](https://github.com/ssenart/PyGazpar/compare/1.2.0...1.2.1) - 2024-05-04 diff --git a/README.md b/README.md index 98d678b..4311720 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # PyGazpar -## $\text{\color{red}{!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!}}$ +## !!! This library is working again. CAPTCHA has been removed !!! + +## ~~!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!~~ PyGazpar is a Python library for getting natural gas consumption from GrDF French provider. diff --git a/pygazpar/datasource.py b/pygazpar/datasource.py index 23fca07..b4a4316 100644 --- a/pygazpar/datasource.py +++ b/pygazpar/datasource.py @@ -144,7 +144,10 @@ def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, file_list = glob.glob(data_file_path_pattern) for filename in file_list: if os.path.isfile(filename): - os.remove(filename) + try: + os.remove(filename) + except PermissionError: + pass if frequencies is None: # Transform Enum in List. @@ -194,7 +197,7 @@ def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, try: # openpyxl does not close the file properly. os.remove(filename) - except Exception: + except PermissionError: pass # We compute yearly from daily data. diff --git a/tests/test_client.py b/tests/test_client.py index b5f5532..883e646 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -72,7 +72,7 @@ def test_monthly_jsonweb(self): data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY]) - assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13) + assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13) def test_yearly_jsonweb(self): client = Client(JsonWebDataSource(self.__username, self.__password)) diff --git a/tests/test_datasource.py b/tests/test_datasource.py index 052832a..58ec301 100644 --- a/tests/test_datasource.py +++ b/tests/test_datasource.py @@ -143,7 +143,7 @@ def test_jsonweb(self): assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54) - assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13) + assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13) assert (len(data[Frequency.YEARLY.value]) == 1)