icalreporting 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jérémie GRESSIER
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.1
2
+ Name: icalreporting
3
+ Version: 0.1.0
4
+ Summary: Reporting tools from ical files
5
+ Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 Jérémie GRESSIER
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/jgressier/icalreporting
28
+ Classifier: Development Status :: 3 - Alpha
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Natural Language :: English
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
37
+ Requires-Python: >=3.9
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy>=1.15
41
+ Requires-Dist: scipy>=1.6
42
+ Requires-Dist: h5py>=3.1
43
+ Requires-Dist: pyvista>=0.38
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=6.0; extra == "dev"
46
+ Requires-Dist: pytest-cov>=2.11.1; extra == "dev"
47
+ Requires-Dist: pylint>=2.6.0; extra == "dev"
48
+
49
+ cfdtools
50
+ -----
51
+
52
+ [![PyPi Version](https://img.shields.io/pypi/v/cfdtools.svg?style=flat)](https://pypi.org/project/cfdtools)
53
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/cfdtools.svg?style=flat)](https://pypi.org/pypi/cfdtools/)
54
+ [![GitHub stars](https://img.shields.io/github/stars/jgressier/cfdtools.svg?style=flat&logo=github&label=Stars&logoColor=white)](https://github.com/jgressier/cfdtools)
55
+ [![PyPi downloads](https://img.shields.io/pypi/dm/cfdtools.svg?style=flat)](https://pypistats.org/packages/cfdtools)
56
+ [![codecov](https://img.shields.io/codecov/c/github/jgressier/cfdtools.svg?style=flat)](https://codecov.io/gh/jgressier/cfdtools)
57
+
58
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d32cf67a5fa242c88bb1568277f1d60e)](https://app.codacy.com/gh/jgressier/cfdtools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Doc](https://readthedocs.org/projects/cfdtools/badge/?version=latest)](https://readthedocs.org/projects/cfdtools/)
59
+ [![Slack](https://img.shields.io/static/v1?logo=slack&label=slack&message=contact&style=flat)](https://join.slack.com/t/isae-opendev/shared_invite/zt-obqywf6r-UUuHR4_hc5iTzyL5bFCwpw
60
+ )
61
+
62
+ ### Features
63
+
64
+ - readers: IC3 (v2, v3), GMSH (v2, v4), CGNS (hdf5)
65
+ - writers: IC3 (v2, v3), VTK
66
+ - generic options for command line writers: extrusion
67
+ - generic format command line: `cfdinfo`, `cfdwrite_ic3v3`
68
+ - specific IC3 command line: `ic3brief`
69
+ - specific VTK command line: `vtkbrief`, `vtkpack`
70
+
71
+ ### Installation and usage
72
+
73
+ ```bash
74
+ pip install cfdtools
75
+ ```
76
+
77
+ ### Requirements
78
+
79
+ see [requirements.txt](https://github.com/jgressier/cfdtools/blob/master/requirements.txt)
@@ -0,0 +1,31 @@
1
+ cfdtools
2
+ -----
3
+
4
+ [![PyPi Version](https://img.shields.io/pypi/v/cfdtools.svg?style=flat)](https://pypi.org/project/cfdtools)
5
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/cfdtools.svg?style=flat)](https://pypi.org/pypi/cfdtools/)
6
+ [![GitHub stars](https://img.shields.io/github/stars/jgressier/cfdtools.svg?style=flat&logo=github&label=Stars&logoColor=white)](https://github.com/jgressier/cfdtools)
7
+ [![PyPi downloads](https://img.shields.io/pypi/dm/cfdtools.svg?style=flat)](https://pypistats.org/packages/cfdtools)
8
+ [![codecov](https://img.shields.io/codecov/c/github/jgressier/cfdtools.svg?style=flat)](https://codecov.io/gh/jgressier/cfdtools)
9
+
10
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d32cf67a5fa242c88bb1568277f1d60e)](https://app.codacy.com/gh/jgressier/cfdtools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Doc](https://readthedocs.org/projects/cfdtools/badge/?version=latest)](https://readthedocs.org/projects/cfdtools/)
11
+ [![Slack](https://img.shields.io/static/v1?logo=slack&label=slack&message=contact&style=flat)](https://join.slack.com/t/isae-opendev/shared_invite/zt-obqywf6r-UUuHR4_hc5iTzyL5bFCwpw
12
+ )
13
+
14
+ ### Features
15
+
16
+ - readers: IC3 (v2, v3), GMSH (v2, v4), CGNS (hdf5)
17
+ - writers: IC3 (v2, v3), VTK
18
+ - generic options for command line writers: extrusion
19
+ - generic format command line: `cfdinfo`, `cfdwrite_ic3v3`
20
+ - specific IC3 command line: `ic3brief`
21
+ - specific VTK command line: `vtkbrief`, `vtkpack`
22
+
23
+ ### Installation and usage
24
+
25
+ ```bash
26
+ pip install cfdtools
27
+ ```
28
+
29
+ ### Requirements
30
+
31
+ see [requirements.txt](https://github.com/jgressier/cfdtools/blob/master/requirements.txt)
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,147 @@
1
+ """reporting module
2
+
3
+ This module uses an ical loader package to fill a pandas database which is parsed to generate a workbook and worksheets
4
+
5
+ The difficulty may be to handle recurrent events.
6
+
7
+ note..:
8
+ existing ical loading packages
9
+ - ixsts (local, non pip) from N. Garcia-Rosa
10
+ - icalendar
11
+ - icalevents (fork of icalendar)
12
+ - ics-py
13
+ - ical (handle recurring events)
14
+ """
15
+ import re
16
+ from datetime import datetime, timedelta
17
+ from ical.calendar_stream import IcsCalendarStream
18
+ import pandas as pd
19
+ from pathlib import Path
20
+ import openpyxl as xl
21
+ from openpyxl.utils.dataframe import dataframe_to_rows
22
+
23
+
24
+ def ical_to_dframe(filename: Path, startdate: datetime, enddate: datetime):
25
+ with filename.open() as ics_file:
26
+ calendar = IcsCalendarStream.calendar_from_ics(ics_file.read())
27
+ return pd.DataFrame(
28
+ [
29
+ {
30
+ "date": event.dtstart,
31
+ "year": event.dtstart.year,
32
+ "month": event.dtstart.month,
33
+ "h_begin": event.dtstart.time,
34
+ "duration": (event.dtend - event.dtstart).seconds / 3600.0,
35
+ "name": event.summary,
36
+ "description": event.description,
37
+ "begin": event.dtstart,
38
+ }
39
+ for event in calendar.timeline.included(startdate, enddate)
40
+ ]
41
+ )
42
+
43
+
44
+ class Project:
45
+ def __init__(
46
+ self, name: str, folder=None, start: str = "2020-01-01", end: str = "2030-01-01", default_WP="No_WP"
47
+ ):
48
+ self._name = name
49
+ self._folder = name if folder is None else folder
50
+ self._start = datetime.fromisoformat(start)
51
+ self._end = datetime.fromisoformat(end) + timedelta(days=1)
52
+ self._default_WP = default_WP
53
+ print(self._end)
54
+ print(f"> init project {self._name} in folder {self._folder}")
55
+ print(f" will include {self._start.date()} to {self._end.date()}")
56
+
57
+ def load_ics(self):
58
+ framedict = {}
59
+ # print(Path(self._folder), Path(self._folder).exists(), Path(self._folder).is_dir())
60
+ # print(list(Path(self._folder).glob("*.ics")))
61
+ for filename in list(Path(self._folder).glob("*.ics")):
62
+ print(f"- reading {filename}")
63
+ framedict[filename.stem] = ical_to_dframe(filename, self._start, self._end)
64
+ framedict[filename.stem]["Member"] = filename.stem # file name without path nor extension
65
+ self._dframe = pd.concat(tuple(framedict.values()))
66
+ self._set_wp(default=self._default_WP)
67
+ self._clean_wp()
68
+
69
+ def members(self):
70
+ return set(self._dframe["Member"])
71
+
72
+ def work_packages(self):
73
+ return set(self._dframe["WP"])
74
+
75
+ def _df_to_tab(self, wb: xl.Workbook, df, title=None):
76
+ ws = wb.create_sheet(title=title)
77
+ for row in dataframe_to_rows(df, header=True):
78
+ ws.append(row)
79
+ return ws
80
+
81
+ def _df_slot(self, start: str, end: str):
82
+ df = self._dframe
83
+ slot = df[df["date"] >= start]
84
+ slot = slot[slot["date"] <= end]
85
+ return slot
86
+
87
+ def _set_wp(self, default=None):
88
+ rewp = re.compile(r"WP[0-9]*[A-Z]*")
89
+ self._dframe["WP"] = self._dframe["name"].apply(lambda s: rewp.findall(s))
90
+ self._dframe["WP"] = self._dframe["WP"].apply(lambda wplist: wplist[0] if wplist else default)
91
+
92
+ def _clean_wp(self):
93
+ rewp = re.compile(r"WP. *-* *")
94
+ self._dframe["name"] = self._dframe["name"].apply(lambda s: rewp.sub("", s))
95
+ return
96
+
97
+ def filter(self, start: str, end: str):
98
+ self._dframe = self._df_slot(start, end)
99
+
100
+ def add_tabdetail_member(self, wb, member: str):
101
+ df = self._dframe[self._dframe["Member"] == member].loc[:, ["date", "duration", "WP", "name"]]
102
+ df["date"] = df["date"].apply(lambda d: d.strftime("%d/%m/%Y"))
103
+ ws = self._df_to_tab(wb, df, member)
104
+ ws.delete_cols(1)
105
+ ws.delete_rows(2)
106
+ return ws
107
+
108
+ def add_tab_workpackage(self, wb, wp: str):
109
+ dfwp = self._dframe[self._dframe["WP"] == wp].loc[
110
+ :, ["date", "Member", "duration", "WP", "name", "year", "month"]
111
+ ]
112
+ dfwp["YearMonth"] = dfwp.year.map(str) + "-" + dfwp.month.map(str)
113
+ dfpiv = dfwp.pivot_table(
114
+ values="duration", index="Member", columns="YearMonth", aggfunc="sum"
115
+ ).fillna(0)
116
+ ws = self._df_to_tab(wb, dfpiv, wp)
117
+ ws.delete_rows(2)
118
+ return ws
119
+
120
+ def add_tab_allworkpackages(self, wb):
121
+ df = self._dframe.pivot_table(values="duration", index="Member", columns="WP", aggfunc="sum")
122
+ ws = self._df_to_tab(wb, df, "Synthèse")
123
+ ws.delete_rows(2)
124
+
125
+ def workbook(self) -> xl.Workbook:
126
+ print("> create workbook")
127
+ wb = xl.Workbook()
128
+ ws_empty = wb.active
129
+ print("- create global worksheet")
130
+ self.add_tab_allworkpackages(wb)
131
+ for member in self.members():
132
+ print(f"- create member worksheet {member}")
133
+ self.add_tabdetail_member(wb, member)
134
+ for wp in sorted(self.work_packages()):
135
+ if wp is not None:
136
+ print(f"- create WP worksheet {wp}")
137
+ self.add_tab_workpackage(wb, wp)
138
+ wb.remove(ws_empty)
139
+ return wb
140
+
141
+
142
+ if __name__ == "__main__":
143
+ prj = Project(name="mambo", folder="examples/projetA", start="2023-01-01", end="2024-01-01")
144
+ prj.load_ics() # lecture des .ics
145
+ # prj.filter(start="2023-01-01", end="2023-12-31") # filtre des dates
146
+ wb = prj.workbook() # création du tableur
147
+ wb.save("projetA.xlsx") # sauvegarde du fichier
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.1
2
+ Name: icalreporting
3
+ Version: 0.1.0
4
+ Summary: Reporting tools from ical files
5
+ Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 Jérémie GRESSIER
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/jgressier/icalreporting
28
+ Classifier: Development Status :: 3 - Alpha
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Natural Language :: English
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
37
+ Requires-Python: >=3.9
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy>=1.15
41
+ Requires-Dist: scipy>=1.6
42
+ Requires-Dist: h5py>=3.1
43
+ Requires-Dist: pyvista>=0.38
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=6.0; extra == "dev"
46
+ Requires-Dist: pytest-cov>=2.11.1; extra == "dev"
47
+ Requires-Dist: pylint>=2.6.0; extra == "dev"
48
+
49
+ cfdtools
50
+ -----
51
+
52
+ [![PyPi Version](https://img.shields.io/pypi/v/cfdtools.svg?style=flat)](https://pypi.org/project/cfdtools)
53
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/cfdtools.svg?style=flat)](https://pypi.org/pypi/cfdtools/)
54
+ [![GitHub stars](https://img.shields.io/github/stars/jgressier/cfdtools.svg?style=flat&logo=github&label=Stars&logoColor=white)](https://github.com/jgressier/cfdtools)
55
+ [![PyPi downloads](https://img.shields.io/pypi/dm/cfdtools.svg?style=flat)](https://pypistats.org/packages/cfdtools)
56
+ [![codecov](https://img.shields.io/codecov/c/github/jgressier/cfdtools.svg?style=flat)](https://codecov.io/gh/jgressier/cfdtools)
57
+
58
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d32cf67a5fa242c88bb1568277f1d60e)](https://app.codacy.com/gh/jgressier/cfdtools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Doc](https://readthedocs.org/projects/cfdtools/badge/?version=latest)](https://readthedocs.org/projects/cfdtools/)
59
+ [![Slack](https://img.shields.io/static/v1?logo=slack&label=slack&message=contact&style=flat)](https://join.slack.com/t/isae-opendev/shared_invite/zt-obqywf6r-UUuHR4_hc5iTzyL5bFCwpw
60
+ )
61
+
62
+ ### Features
63
+
64
+ - readers: IC3 (v2, v3), GMSH (v2, v4), CGNS (hdf5)
65
+ - writers: IC3 (v2, v3), VTK
66
+ - generic options for command line writers: extrusion
67
+ - generic format command line: `cfdinfo`, `cfdwrite_ic3v3`
68
+ - specific IC3 command line: `ic3brief`
69
+ - specific VTK command line: `vtkbrief`, `vtkpack`
70
+
71
+ ### Installation and usage
72
+
73
+ ```bash
74
+ pip install cfdtools
75
+ ```
76
+
77
+ ### Requirements
78
+
79
+ see [requirements.txt](https://github.com/jgressier/cfdtools/blob/master/requirements.txt)
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ icalreporting/__init__.py
5
+ icalreporting/reporting.py
6
+ icalreporting.egg-info/PKG-INFO
7
+ icalreporting.egg-info/SOURCES.txt
8
+ icalreporting.egg-info/dependency_links.txt
9
+ icalreporting.egg-info/requires.txt
10
+ icalreporting.egg-info/top_level.txt
@@ -0,0 +1,9 @@
1
+ numpy>=1.15
2
+ scipy>=1.6
3
+ h5py>=3.1
4
+ pyvista>=0.38
5
+
6
+ [dev]
7
+ pytest>=6.0
8
+ pytest-cov>=2.11.1
9
+ pylint>=2.6.0
@@ -0,0 +1 @@
1
+ icalreporting
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "icalreporting"
3
+ version = "0.1.0"
4
+ description = "Reporting tools from ical files"
5
+ authors = [{name="J. Gressier", email="jeremie.gressier@isae-supaero.fr"}]
6
+ readme = "README.md"
7
+ license = { file = "LICENSE" }
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "License :: OSI Approved :: MIT License",
11
+ "Natural Language :: English",
12
+ "Operating System :: OS Independent",
13
+ "Programming Language :: Python",
14
+ "Programming Language :: Python :: 3.9",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Topic :: Software Development :: Libraries :: Python Modules" ]
18
+ requires-python = ">=3.9"
19
+ dependencies = [
20
+ "numpy >= 1.15",
21
+ "scipy >= 1.6",
22
+ "h5py >= 3.1", "pyvista >= 0.38" ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/jgressier/icalreporting"
26
+
27
+ [tool.setuptools.packages.find] # to help find cfdtools folder as a package
28
+ include = ["icalreporting*"]
29
+
30
+ [project.optional-dependencies]
31
+ dev = [
32
+ "pytest >= 6.0",
33
+ "pytest-cov >= 2.11.1",
34
+ "pylint >= 2.6.0" ]
35
+
36
+ [build-system]
37
+ requires = ["setuptools>=61.0.0", "wheel"]
38
+ build-backend = "setuptools.build_meta"
39
+
40
+ [tool.pytest.ini_options]
41
+ minversion = "6.0"
42
+ addopts = "--cov -v"
43
+ testpaths = [
44
+ "tests"
45
+ ]
46
+
47
+ [tool.bumpver]
48
+ current_version = "v0.1.0"
49
+ version_pattern = "vMAJOR.MINOR.PATCH"
50
+ commit_message = "bump version {old_version} to {new_version}"
51
+ commit = true
52
+ tag = true
53
+ push = true
54
+
55
+ [tool.bumpver.file_patterns]
56
+ "pyproject.toml" = ['current_version = "{version}"', 'version = "{pep440_version}"']
57
+ "icalreporting/__init__.py" = ['__version__ = "{pep440_version}"']
58
+
59
+ [tool.black]
60
+ line-length = 110
61
+ skip-string-normalization = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+