pygazpar 1.3.0a15__py312-none-any.whl → 1.3.0a25__py312-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygazpar/datasource.py +528 -522
- pygazpar/excelparser.py +138 -136
- pygazpar/version.py +1 -1
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/METADATA +16 -8
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/RECORD +11 -11
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/WHEEL +1 -1
- tests/test_client.py +159 -159
- tests/test_datasource.py +166 -166
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/LICENSE.md +0 -0
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/entry_points.txt +0 -0
- {pygazpar-1.3.0a15.dist-info → pygazpar-1.3.0a25.dist-info}/top_level.txt +0 -0
pygazpar/excelparser.py
CHANGED
@@ -1,136 +1,138 @@
|
|
1
|
-
import logging
|
2
|
-
from datetime import datetime
|
3
|
-
from pygazpar.enum import Frequency
|
4
|
-
from pygazpar.enum import PropertyName
|
5
|
-
from openpyxl.worksheet.worksheet import Worksheet
|
6
|
-
from openpyxl.cell.cell import Cell
|
7
|
-
from openpyxl import load_workbook
|
8
|
-
from typing import Any, List, Dict
|
9
|
-
|
10
|
-
|
11
|
-
FIRST_DATA_LINE_NUMBER = 10
|
12
|
-
|
13
|
-
Logger = logging.getLogger(__name__)
|
14
|
-
|
15
|
-
|
16
|
-
# ------------------------------------------------------------------------------------------------------------
|
17
|
-
class ExcelParser:
|
18
|
-
|
19
|
-
# ------------------------------------------------------
|
20
|
-
@staticmethod
|
21
|
-
def parse(dataFilename: str, dataReadingFrequency: Frequency) -> List[Dict[str, Any]]:
|
22
|
-
|
23
|
-
parseByFrequency = {
|
24
|
-
Frequency.HOURLY: ExcelParser.__parseHourly,
|
25
|
-
Frequency.DAILY: ExcelParser.__parseDaily,
|
26
|
-
Frequency.WEEKLY: ExcelParser.__parseWeekly,
|
27
|
-
Frequency.MONTHLY: ExcelParser.__parseMonthly
|
28
|
-
}
|
29
|
-
|
30
|
-
Logger.debug(f"Loading Excel data file '{dataFilename}'...")
|
31
|
-
|
32
|
-
workbook = load_workbook(filename=dataFilename)
|
33
|
-
|
34
|
-
worksheet = workbook.active
|
35
|
-
|
36
|
-
res = parseByFrequency[dataReadingFrequency](worksheet) # type: ignore
|
37
|
-
|
38
|
-
workbook.close()
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
ExcelParser.__fillRow(row, PropertyName.
|
78
|
-
ExcelParser.__fillRow(row, PropertyName.
|
79
|
-
ExcelParser.__fillRow(row, PropertyName.
|
80
|
-
ExcelParser.__fillRow(row, PropertyName.
|
81
|
-
ExcelParser.__fillRow(row, PropertyName.
|
82
|
-
ExcelParser.__fillRow(row, PropertyName.
|
83
|
-
row
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
ExcelParser.__fillRow(row, PropertyName.
|
107
|
-
row
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
ExcelParser.__fillRow(row, PropertyName.
|
131
|
-
row
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
1
|
+
import logging
|
2
|
+
from datetime import datetime
|
3
|
+
from pygazpar.enum import Frequency
|
4
|
+
from pygazpar.enum import PropertyName
|
5
|
+
from openpyxl.worksheet.worksheet import Worksheet
|
6
|
+
from openpyxl.cell.cell import Cell
|
7
|
+
from openpyxl import load_workbook
|
8
|
+
from typing import Any, List, Dict
|
9
|
+
|
10
|
+
|
11
|
+
FIRST_DATA_LINE_NUMBER = 10
|
12
|
+
|
13
|
+
Logger = logging.getLogger(__name__)
|
14
|
+
|
15
|
+
|
16
|
+
# ------------------------------------------------------------------------------------------------------------
|
17
|
+
class ExcelParser:
|
18
|
+
|
19
|
+
# ------------------------------------------------------
|
20
|
+
@staticmethod
|
21
|
+
def parse(dataFilename: str, dataReadingFrequency: Frequency) -> List[Dict[str, Any]]:
|
22
|
+
|
23
|
+
parseByFrequency = {
|
24
|
+
Frequency.HOURLY: ExcelParser.__parseHourly,
|
25
|
+
Frequency.DAILY: ExcelParser.__parseDaily,
|
26
|
+
Frequency.WEEKLY: ExcelParser.__parseWeekly,
|
27
|
+
Frequency.MONTHLY: ExcelParser.__parseMonthly
|
28
|
+
}
|
29
|
+
|
30
|
+
Logger.debug(f"Loading Excel data file '{dataFilename}'...")
|
31
|
+
|
32
|
+
workbook = load_workbook(filename=dataFilename)
|
33
|
+
|
34
|
+
worksheet = workbook.active
|
35
|
+
|
36
|
+
res = parseByFrequency[dataReadingFrequency](worksheet) # type: ignore
|
37
|
+
|
38
|
+
workbook.close()
|
39
|
+
|
40
|
+
Logger.debug("Processed Excel %s data: %s", dataReadingFrequency, res)
|
41
|
+
|
42
|
+
return res
|
43
|
+
|
44
|
+
# ------------------------------------------------------
|
45
|
+
@staticmethod
|
46
|
+
def __fillRow(row: Dict, propertyName: str, cell: Cell, isNumber: bool):
|
47
|
+
|
48
|
+
if cell.value is not None:
|
49
|
+
if isNumber:
|
50
|
+
if type(cell.value) is str:
|
51
|
+
if len(cell.value.strip()) > 0:
|
52
|
+
row[propertyName] = float(cell.value.replace(',', '.'))
|
53
|
+
else:
|
54
|
+
row[propertyName] = cell.value
|
55
|
+
else:
|
56
|
+
row[propertyName] = cell.value.strip() if type(cell.value) is str else cell.value
|
57
|
+
|
58
|
+
# ------------------------------------------------------
|
59
|
+
@staticmethod
|
60
|
+
def __parseHourly(worksheet: Worksheet) -> List[Dict[str, Any]]:
|
61
|
+
return []
|
62
|
+
|
63
|
+
# ------------------------------------------------------
|
64
|
+
@staticmethod
|
65
|
+
def __parseDaily(worksheet: Worksheet) -> List[Dict[str, Any]]:
|
66
|
+
|
67
|
+
res = []
|
68
|
+
|
69
|
+
# Timestamp of the data.
|
70
|
+
data_timestamp = datetime.now().isoformat()
|
71
|
+
|
72
|
+
minRowNum = FIRST_DATA_LINE_NUMBER
|
73
|
+
maxRowNum = len(worksheet['B'])
|
74
|
+
for rownum in range(minRowNum, maxRowNum + 1):
|
75
|
+
row = {}
|
76
|
+
if worksheet.cell(column=2, row=rownum).value is not None:
|
77
|
+
ExcelParser.__fillRow(row, PropertyName.TIME_PERIOD.value, worksheet.cell(column=2, row=rownum), False) # type: ignore
|
78
|
+
ExcelParser.__fillRow(row, PropertyName.START_INDEX.value, worksheet.cell(column=3, row=rownum), True) # type: ignore
|
79
|
+
ExcelParser.__fillRow(row, PropertyName.END_INDEX.value, worksheet.cell(column=4, row=rownum), True) # type: ignore
|
80
|
+
ExcelParser.__fillRow(row, PropertyName.VOLUME.value, worksheet.cell(column=5, row=rownum), True) # type: ignore
|
81
|
+
ExcelParser.__fillRow(row, PropertyName.ENERGY.value, worksheet.cell(column=6, row=rownum), True) # type: ignore
|
82
|
+
ExcelParser.__fillRow(row, PropertyName.CONVERTER_FACTOR.value, worksheet.cell(column=7, row=rownum), True) # type: ignore
|
83
|
+
ExcelParser.__fillRow(row, PropertyName.TEMPERATURE.value, worksheet.cell(column=8, row=rownum), True) # type: ignore
|
84
|
+
ExcelParser.__fillRow(row, PropertyName.TYPE.value, worksheet.cell(column=9, row=rownum), False) # type: ignore
|
85
|
+
row[PropertyName.TIMESTAMP.value] = data_timestamp
|
86
|
+
res.append(row)
|
87
|
+
|
88
|
+
Logger.debug(f"Daily data read successfully between row #{minRowNum} and row #{maxRowNum}")
|
89
|
+
|
90
|
+
return res
|
91
|
+
|
92
|
+
# ------------------------------------------------------
|
93
|
+
@staticmethod
|
94
|
+
def __parseWeekly(worksheet: Worksheet) -> List[Dict[str, Any]]:
|
95
|
+
|
96
|
+
res = []
|
97
|
+
|
98
|
+
# Timestamp of the data.
|
99
|
+
data_timestamp = datetime.now().isoformat()
|
100
|
+
|
101
|
+
minRowNum = FIRST_DATA_LINE_NUMBER
|
102
|
+
maxRowNum = len(worksheet['B'])
|
103
|
+
for rownum in range(minRowNum, maxRowNum + 1):
|
104
|
+
row = {}
|
105
|
+
if worksheet.cell(column=2, row=rownum).value is not None:
|
106
|
+
ExcelParser.__fillRow(row, PropertyName.TIME_PERIOD.value, worksheet.cell(column=2, row=rownum), False) # type: ignore
|
107
|
+
ExcelParser.__fillRow(row, PropertyName.VOLUME.value, worksheet.cell(column=3, row=rownum), True) # type: ignore
|
108
|
+
ExcelParser.__fillRow(row, PropertyName.ENERGY.value, worksheet.cell(column=4, row=rownum), True) # type: ignore
|
109
|
+
row[PropertyName.TIMESTAMP.value] = data_timestamp
|
110
|
+
res.append(row)
|
111
|
+
|
112
|
+
Logger.debug(f"Weekly data read successfully between row #{minRowNum} and row #{maxRowNum}")
|
113
|
+
|
114
|
+
return res
|
115
|
+
|
116
|
+
# ------------------------------------------------------
|
117
|
+
@staticmethod
|
118
|
+
def __parseMonthly(worksheet: Worksheet) -> List[Dict[str, Any]]:
|
119
|
+
|
120
|
+
res = []
|
121
|
+
|
122
|
+
# Timestamp of the data.
|
123
|
+
data_timestamp = datetime.now().isoformat()
|
124
|
+
|
125
|
+
minRowNum = FIRST_DATA_LINE_NUMBER
|
126
|
+
maxRowNum = len(worksheet['B'])
|
127
|
+
for rownum in range(minRowNum, maxRowNum + 1):
|
128
|
+
row = {}
|
129
|
+
if worksheet.cell(column=2, row=rownum).value is not None:
|
130
|
+
ExcelParser.__fillRow(row, PropertyName.TIME_PERIOD.value, worksheet.cell(column=2, row=rownum), False) # type: ignore
|
131
|
+
ExcelParser.__fillRow(row, PropertyName.VOLUME.value, worksheet.cell(column=3, row=rownum), True) # type: ignore
|
132
|
+
ExcelParser.__fillRow(row, PropertyName.ENERGY.value, worksheet.cell(column=4, row=rownum), True) # type: ignore
|
133
|
+
row[PropertyName.TIMESTAMP.value] = data_timestamp
|
134
|
+
res.append(row)
|
135
|
+
|
136
|
+
Logger.debug(f"Monthly data read successfully between row #{minRowNum} and row #{maxRowNum}")
|
137
|
+
|
138
|
+
return res
|
pygazpar/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "1.3.
|
1
|
+
__version__ = "1.3.0a25"
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: pygazpar
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.0a25
|
4
4
|
Summary: Retrieve gas consumption from GrDF web site (French Gas Company)
|
5
5
|
Home-page: https://github.com/ssenart/pygazpar
|
6
6
|
Download-URL: https://github.com/ssenart/pygazpar/releases
|
@@ -17,24 +17,22 @@ Platform: any
|
|
17
17
|
Classifier: Development Status :: 5 - Production/Stable
|
18
18
|
Classifier: Topic :: Software Development :: Libraries
|
19
19
|
Classifier: Operating System :: OS Independent
|
20
|
-
Classifier: Programming Language :: Python :: 3.7
|
21
|
-
Classifier: Programming Language :: Python :: 3.8
|
22
20
|
Classifier: Programming Language :: Python :: 3.9
|
23
21
|
Classifier: Programming Language :: Python :: 3.10
|
24
22
|
Classifier: Programming Language :: Python :: 3.11
|
25
23
|
Classifier: Programming Language :: Python :: 3.12
|
26
|
-
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
25
|
+
Requires-Python: >=3.9
|
27
26
|
Description-Content-Type: text/markdown
|
28
27
|
License-File: LICENSE.md
|
29
28
|
Requires-Dist: openpyxl>=2.6.3
|
30
29
|
Requires-Dist: requests>=2.26.0
|
31
30
|
Requires-Dist: pandas
|
31
|
+
Dynamic: download-url
|
32
32
|
|
33
33
|
# PyGazpar
|
34
34
|
|
35
|
-
##
|
36
|
-
|
37
|
-
## <span style="color:red">~~!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!~~</span>
|
35
|
+
## $\text{\color{green}{!!! This library is working again. CAPTCHA has been removed !!!}}$
|
38
36
|
|
39
37
|
PyGazpar is a Python library for getting natural gas consumption from GrDF French provider.
|
40
38
|
|
@@ -220,6 +218,16 @@ All notable changes to this project will be documented in this file.
|
|
220
218
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
221
219
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
222
220
|
|
221
|
+
## [1.2.8](https://github.com/ssenart/PyGazpar/compare/1.2.8...1.2.7) - 2025-01-11
|
222
|
+
|
223
|
+
### Added
|
224
|
+
- [#81](https://github.com/ssenart/PyGazpar/issues/81): Add meter/temperature debug log messages to help investigation in case of errors.
|
225
|
+
|
226
|
+
## [1.2.7](https://github.com/ssenart/PyGazpar/compare/1.2.7...1.2.6) - 2025-01-06
|
227
|
+
|
228
|
+
### Fixed
|
229
|
+
- [#79](https://github.com/ssenart/PyGazpar/issues/79): Fix some unittests that wrongly failed because of the new year.
|
230
|
+
|
223
231
|
## [1.2.6](https://github.com/ssenart/PyGazpar/compare/1.2.6...1.2.5) - 2025-01-03
|
224
232
|
|
225
233
|
### Fixed
|
@@ -1,11 +1,11 @@
|
|
1
1
|
pygazpar/__init__.py,sha256=qshO_XZbDA2Wrt80ABDs0MoScqJytClAuIJjAnILglk,309
|
2
2
|
pygazpar/__main__.py,sha256=Pt3PInX7QiWcs0aBKZN90NTaU8KFnrQiZ5Hsow1eR5U,3177
|
3
3
|
pygazpar/client.py,sha256=JdVm0jZbeibwtTumcRbUSFadfXnCUClPMjL95_J6p5Y,2595
|
4
|
-
pygazpar/datasource.py,sha256=
|
4
|
+
pygazpar/datasource.py,sha256=SQ6ko4ElWp9BBid-TcBo9iWiCMO4VL-_pTkGb6sCGDE,21400
|
5
5
|
pygazpar/enum.py,sha256=3ZCk4SziXF6pxgP3MuQ1qxYfqB3X5DOV8Rtd0GHsK9w,898
|
6
|
-
pygazpar/excelparser.py,sha256=
|
6
|
+
pygazpar/excelparser.py,sha256=A9s0A1xpIxGiqLvVd80p7ntb89Grq9-tVb46Al0xJx8,6149
|
7
7
|
pygazpar/jsonparser.py,sha256=OrRdMZNBi7rI4dRGoRW7gjyFwJFk-IvtkRZ_t1XVFrI,1859
|
8
|
-
pygazpar/version.py,sha256=
|
8
|
+
pygazpar/version.py,sha256=LAtsvNEAdDyYs38U_Z-jNtq_LctK0rzhKzWXmHvVx4M,25
|
9
9
|
pygazpar/resources/daily_data_sample.json,sha256=YJovtrNUMs257magTfyxiewLmecySFypcelbGFUUeT8,199583
|
10
10
|
pygazpar/resources/hourly_data_sample.json,sha256=N1F-Xz3GaBn2H1p7uKzhkhKCQV8QVR0t76XD6wmFtXA,3
|
11
11
|
pygazpar/resources/monthly_data_sample.json,sha256=yrr4SqrB2MubeVU2HX_FRDZKHIhC0LXCqkO1iqnFWcg,3351
|
@@ -16,12 +16,12 @@ samples/excelSample.py,sha256=ltAl-bBz9-U9YI802JpcIswra-vDS7tR_KL5VNdxJ5c,765
|
|
16
16
|
samples/jsonSample.py,sha256=sYAIusdEJhZdwDAMgHqoWcwDR0FA2eWhSt_2gL_mJRk,736
|
17
17
|
samples/testSample.py,sha256=UeirdEtezHwfZDv_75oxul17YzGWn5yZuHfJYTF3Ez0,387
|
18
18
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
tests/test_client.py,sha256=
|
19
|
+
tests/test_client.py,sha256=BFLz0GNk8qEP4d2-7cAaIcLWpkSnDZo3wRb0AlXBNOQ,5765
|
20
20
|
tests/test_datafileparser.py,sha256=nAeUpOHtelblMpmbrrnf-2GuMjK5ai65veDoymceprE,818
|
21
|
-
tests/test_datasource.py,sha256=
|
22
|
-
pygazpar-1.3.
|
23
|
-
pygazpar-1.3.
|
24
|
-
pygazpar-1.3.
|
25
|
-
pygazpar-1.3.
|
26
|
-
pygazpar-1.3.
|
27
|
-
pygazpar-1.3.
|
21
|
+
tests/test_datasource.py,sha256=NTeD3yQEi4fTw8ZWz2cuUUdeFC8QVjChBMw5jyqia40,6149
|
22
|
+
pygazpar-1.3.0a25.dist-info/LICENSE.md,sha256=XsCJx_7_BC9tvmE0ZxS1cTNR7ekurog_ea9ybdZ-8tc,1073
|
23
|
+
pygazpar-1.3.0a25.dist-info/METADATA,sha256=sKs4JpOl8PGFRUDoJUxDPmhtnPFa6YjWc0aDlVdFUaY,19458
|
24
|
+
pygazpar-1.3.0a25.dist-info/WHEEL,sha256=f-tFxHoSaKxpBvh-cZLVJ_1-woq1R_qTNWIS7rvXlLs,93
|
25
|
+
pygazpar-1.3.0a25.dist-info/entry_points.txt,sha256=dNJjC6RYY3FeJIe0hZL9Kcr6vKEx1qkZ71e6Slocb7I,52
|
26
|
+
pygazpar-1.3.0a25.dist-info/top_level.txt,sha256=P7qn-XtanDPBLQsTvjvLV71wH8RK0DYbx8tzN_rDS70,23
|
27
|
+
pygazpar-1.3.0a25.dist-info/RECORD,,
|