icalreporting 0.1.1__tar.gz → 0.1.3__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.
- {icalreporting-0.1.1 → icalreporting-0.1.3}/LICENSE +1 -1
- {icalreporting-0.1.1 → icalreporting-0.1.3}/PKG-INFO +19 -3
- {icalreporting-0.1.1 → icalreporting-0.1.3}/README.md +18 -2
- icalreporting-0.1.3/icalreporting/__init__.py +1 -0
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting/reporting.py +35 -10
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting.egg-info/PKG-INFO +19 -3
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting.egg-info/SOURCES.txt +2 -1
- {icalreporting-0.1.1 → icalreporting-0.1.3}/pyproject.toml +2 -2
- icalreporting-0.1.3/tests/test_icalimport.py +34 -0
- icalreporting-0.1.1/icalreporting/__init__.py +0 -1
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting.egg-info/dependency_links.txt +0 -0
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting.egg-info/requires.txt +0 -0
- {icalreporting-0.1.1 → icalreporting-0.1.3}/icalreporting.egg-info/top_level.txt +0 -0
- {icalreporting-0.1.1 → icalreporting-0.1.3}/setup.cfg +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: icalreporting
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Reporting tools from ical files
|
|
5
5
|
Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
8
|
-
Copyright (c)
|
|
8
|
+
Copyright (c) 2023 Jérémie GRESSIER
|
|
9
9
|
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
11
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -61,13 +61,29 @@ icalreporting
|
|
|
61
61
|
|
|
62
62
|
### Features
|
|
63
63
|
|
|
64
|
+
- able to load ical files and fill a pandas database
|
|
65
|
+
- parse the pandas database to identify project and creates a worksheet tables
|
|
66
|
+
- export to open document XLSX file
|
|
64
67
|
|
|
65
|
-
### Installation
|
|
68
|
+
### Installation
|
|
66
69
|
|
|
67
70
|
```bash
|
|
68
71
|
pip install --upgrade icalreporting
|
|
69
72
|
```
|
|
73
|
+
This automatic installation will get needed dependencies.
|
|
70
74
|
|
|
71
75
|
### Requirements
|
|
72
76
|
|
|
73
77
|
see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
|
|
78
|
+
|
|
79
|
+
### Usage
|
|
80
|
+
|
|
81
|
+
When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from icalreporting.reporting import Project
|
|
85
|
+
prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
|
|
86
|
+
prj.load_ics() # read files
|
|
87
|
+
wb = prj.workbook() # create workbook
|
|
88
|
+
wb.save("projectA.xlsx") # save it to file
|
|
89
|
+
```
|
|
@@ -13,13 +13,29 @@ icalreporting
|
|
|
13
13
|
|
|
14
14
|
### Features
|
|
15
15
|
|
|
16
|
+
- able to load ical files and fill a pandas database
|
|
17
|
+
- parse the pandas database to identify project and creates a worksheet tables
|
|
18
|
+
- export to open document XLSX file
|
|
16
19
|
|
|
17
|
-
### Installation
|
|
20
|
+
### Installation
|
|
18
21
|
|
|
19
22
|
```bash
|
|
20
23
|
pip install --upgrade icalreporting
|
|
21
24
|
```
|
|
25
|
+
This automatic installation will get needed dependencies.
|
|
22
26
|
|
|
23
27
|
### Requirements
|
|
24
28
|
|
|
25
|
-
see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
|
|
29
|
+
see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
|
|
30
|
+
|
|
31
|
+
### Usage
|
|
32
|
+
|
|
33
|
+
When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from icalreporting.reporting import Project
|
|
37
|
+
prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
|
|
38
|
+
prj.load_ics() # read files
|
|
39
|
+
wb = prj.workbook() # create workbook
|
|
40
|
+
wb.save("projectA.xlsx") # save it to file
|
|
41
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.3"
|
|
@@ -20,8 +20,21 @@ from pathlib import Path
|
|
|
20
20
|
import openpyxl as xl
|
|
21
21
|
from openpyxl.utils.dataframe import dataframe_to_rows
|
|
22
22
|
|
|
23
|
+
_default_startdate = "2020-01-01"
|
|
24
|
+
_default_enddate = "2030-01-01"
|
|
23
25
|
|
|
24
26
|
def ical_to_dframe(filename: Path, startdate: datetime, enddate: datetime):
|
|
27
|
+
"""read a file in ICAL format and create events between 2 dates
|
|
28
|
+
can handle recurrent events
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
filename (Path): path name of ICAL file
|
|
32
|
+
startdate (datetime): starting date for events
|
|
33
|
+
enddate (datetime): ending date (included) for events
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
DataFrame: as member of the class (date, year, month, h_begin, duration, name, description, begin) properties
|
|
37
|
+
"""
|
|
25
38
|
with filename.open() as ics_file:
|
|
26
39
|
calendar = IcsCalendarStream.calendar_from_ics(ics_file.read())
|
|
27
40
|
return pd.DataFrame(
|
|
@@ -41,9 +54,14 @@ def ical_to_dframe(filename: Path, startdate: datetime, enddate: datetime):
|
|
|
41
54
|
)
|
|
42
55
|
|
|
43
56
|
|
|
44
|
-
class Project:
|
|
57
|
+
class Project():
|
|
58
|
+
"""Class Project, can read ICAL file, define tags and create worksheet
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
_WP_model = r"WP[0-9]*[A-Z]*"
|
|
62
|
+
|
|
45
63
|
def __init__(
|
|
46
|
-
self, name: str, folder=None, start: str =
|
|
64
|
+
self, name: str, folder=None, start: str = _default_startdate, end: str = _default_enddate, default_WP="No_WP"
|
|
47
65
|
):
|
|
48
66
|
self._name = name
|
|
49
67
|
self._folder = name if folder is None else folder
|
|
@@ -52,24 +70,28 @@ class Project:
|
|
|
52
70
|
self._default_WP = default_WP
|
|
53
71
|
print(self._end)
|
|
54
72
|
print(f"> init project {self._name} in folder {self._folder}")
|
|
55
|
-
print(f" will include {self._start.date()} to {self._end.date()}")
|
|
73
|
+
print(f" will include {self._start.date()} to {self._end.date()} (not included)")
|
|
56
74
|
|
|
57
75
|
def load_ics(self):
|
|
76
|
+
"""load ICS fils and create pandas dataframe associated to member"""
|
|
58
77
|
framedict = {}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
for filename in list(Path(self._folder).glob("*.ics")):
|
|
78
|
+
filelist = list(Path(self._folder).glob("*.ics"))
|
|
79
|
+
for filename in filelist:
|
|
62
80
|
print(f"- reading {filename}")
|
|
63
81
|
framedict[filename.stem] = ical_to_dframe(filename, self._start, self._end)
|
|
64
82
|
framedict[filename.stem]["Member"] = filename.stem # file name without path nor extension
|
|
83
|
+
if len(filelist) == 0:
|
|
84
|
+
raise FileNotFoundError("no *.ics file found")
|
|
65
85
|
self._dframe = pd.concat(tuple(framedict.values()))
|
|
66
86
|
self._set_wp(default=self._default_WP)
|
|
67
87
|
self._clean_wp()
|
|
68
88
|
|
|
69
89
|
def members(self):
|
|
90
|
+
"""returns set (unordered list) of members"""
|
|
70
91
|
return set(self._dframe["Member"])
|
|
71
92
|
|
|
72
93
|
def work_packages(self):
|
|
94
|
+
"""returns set (unordered list) of Work Packages"""
|
|
73
95
|
return set(self._dframe["WP"])
|
|
74
96
|
|
|
75
97
|
def _df_to_tab(self, wb: xl.Workbook, df, title=None):
|
|
@@ -85,16 +107,18 @@ class Project:
|
|
|
85
107
|
return slot
|
|
86
108
|
|
|
87
109
|
def _set_wp(self, default=None):
|
|
88
|
-
|
|
110
|
+
"""set WP properties using regexp in event name"""
|
|
111
|
+
rewp = re.compile(self._WP_model)
|
|
89
112
|
self._dframe["WP"] = self._dframe["name"].apply(lambda s: rewp.findall(s))
|
|
90
113
|
self._dframe["WP"] = self._dframe["WP"].apply(lambda wplist: wplist[0] if wplist else default)
|
|
91
114
|
|
|
92
115
|
def _clean_wp(self):
|
|
93
|
-
rewp = re.compile(r"
|
|
116
|
+
rewp = re.compile(self._WP_model + r". *-* *")
|
|
94
117
|
self._dframe["name"] = self._dframe["name"].apply(lambda s: rewp.sub("", s))
|
|
95
118
|
return
|
|
96
119
|
|
|
97
120
|
def filter(self, start: str, end: str):
|
|
121
|
+
"""replace DataFrame with selected dates"""
|
|
98
122
|
self._dframe = self._df_slot(start, end)
|
|
99
123
|
|
|
100
124
|
def add_tabdetail_member(self, wb, member: str):
|
|
@@ -109,7 +133,8 @@ class Project:
|
|
|
109
133
|
dfwp = self._dframe[self._dframe["WP"] == wp].loc[
|
|
110
134
|
:, ["date", "Member", "duration", "WP", "name", "year", "month"]
|
|
111
135
|
]
|
|
112
|
-
|
|
136
|
+
monthformat = lambda m : f"{m:02}"
|
|
137
|
+
dfwp["YearMonth"] = dfwp.year.map(str) + "-" + dfwp.month.map(monthformat)
|
|
113
138
|
dfpiv = dfwp.pivot_table(
|
|
114
139
|
values="duration", index="Member", columns="YearMonth", aggfunc="sum"
|
|
115
140
|
).fillna(0)
|
|
@@ -140,7 +165,7 @@ class Project:
|
|
|
140
165
|
|
|
141
166
|
|
|
142
167
|
if __name__ == "__main__":
|
|
143
|
-
prj = Project(name="mambo", folder="examples/
|
|
168
|
+
prj = Project(name="mambo", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
|
|
144
169
|
prj.load_ics() # lecture des .ics
|
|
145
170
|
# prj.filter(start="2023-01-01", end="2023-12-31") # filtre des dates
|
|
146
171
|
wb = prj.workbook() # création du tableur
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: icalreporting
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Reporting tools from ical files
|
|
5
5
|
Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
8
|
-
Copyright (c)
|
|
8
|
+
Copyright (c) 2023 Jérémie GRESSIER
|
|
9
9
|
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
11
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -61,13 +61,29 @@ icalreporting
|
|
|
61
61
|
|
|
62
62
|
### Features
|
|
63
63
|
|
|
64
|
+
- able to load ical files and fill a pandas database
|
|
65
|
+
- parse the pandas database to identify project and creates a worksheet tables
|
|
66
|
+
- export to open document XLSX file
|
|
64
67
|
|
|
65
|
-
### Installation
|
|
68
|
+
### Installation
|
|
66
69
|
|
|
67
70
|
```bash
|
|
68
71
|
pip install --upgrade icalreporting
|
|
69
72
|
```
|
|
73
|
+
This automatic installation will get needed dependencies.
|
|
70
74
|
|
|
71
75
|
### Requirements
|
|
72
76
|
|
|
73
77
|
see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
|
|
78
|
+
|
|
79
|
+
### Usage
|
|
80
|
+
|
|
81
|
+
When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from icalreporting.reporting import Project
|
|
85
|
+
prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
|
|
86
|
+
prj.load_ics() # read files
|
|
87
|
+
wb = prj.workbook() # create workbook
|
|
88
|
+
wb.save("projectA.xlsx") # save it to file
|
|
89
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "icalreporting"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.3"
|
|
4
4
|
description = "Reporting tools from ical files"
|
|
5
5
|
authors = [{name="J. Gressier", email="jeremie.gressier@isae-supaero.fr"}]
|
|
6
6
|
readme = "README.md"
|
|
@@ -45,7 +45,7 @@ testpaths = [
|
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
[tool.bumpver]
|
|
48
|
-
current_version = "v0.1.
|
|
48
|
+
current_version = "v0.1.3"
|
|
49
49
|
version_pattern = "vMAJOR.MINOR.PATCH"
|
|
50
50
|
commit_message = "bump version {old_version} to {new_version}"
|
|
51
51
|
commit = true
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import icalreporting.reporting as ir
|
|
2
|
+
from datetime import datetime, timedelta
|
|
3
|
+
|
|
4
|
+
def test_init():
|
|
5
|
+
prjname = "my_original_name"
|
|
6
|
+
path = "examples/ProjectA"
|
|
7
|
+
project = ir.Project(name=prjname, folder=path)
|
|
8
|
+
assert project._name == prjname
|
|
9
|
+
assert project._folder == path
|
|
10
|
+
for d in (project._start, project._end):
|
|
11
|
+
assert isinstance(d, datetime)
|
|
12
|
+
assert project._start.date().isoformat() == ir._default_startdate
|
|
13
|
+
assert (project._end-timedelta(days=1)).date().isoformat() == ir._default_enddate
|
|
14
|
+
|
|
15
|
+
def test_open():
|
|
16
|
+
prjname = "my_original_name"
|
|
17
|
+
path = "examples/ProjectA"
|
|
18
|
+
project = ir.Project(name=prjname, folder=path)
|
|
19
|
+
project.load_ics()
|
|
20
|
+
assert len(project.members()) == 2
|
|
21
|
+
assert len(project.work_packages()) == 6
|
|
22
|
+
|
|
23
|
+
def test_properties():
|
|
24
|
+
prjname = "my_original_name"
|
|
25
|
+
path = "examples/ProjectA"
|
|
26
|
+
project = ir.Project(name=prjname, folder=path)
|
|
27
|
+
project.load_ics()
|
|
28
|
+
|
|
29
|
+
def test_write_workbook():
|
|
30
|
+
prjname = "my_original_name"
|
|
31
|
+
path = "examples/ProjectA"
|
|
32
|
+
project = ir.Project(name=prjname, folder=path)
|
|
33
|
+
project.load_ics()
|
|
34
|
+
wb = project.workbook()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|