icalreporting 0.3.0__tar.gz → 0.4.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.
Files changed (30) hide show
  1. {icalreporting-0.3.0 → icalreporting-0.4.0}/PKG-INFO +69 -28
  2. icalreporting-0.4.0/README.md +79 -0
  3. icalreporting-0.4.0/icalreporting/__init__.py +1 -0
  4. icalreporting-0.4.0/icalreporting/_cli.py +124 -0
  5. icalreporting-0.4.0/icalreporting/reporting.py +776 -0
  6. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/PKG-INFO +69 -28
  7. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/SOURCES.txt +1 -0
  8. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/entry_points.txt +2 -0
  9. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/requires.txt +1 -0
  10. {icalreporting-0.3.0 → icalreporting-0.4.0}/pyproject.toml +8 -4
  11. icalreporting-0.4.0/tests/test_Hyperplanning.py +70 -0
  12. icalreporting-0.4.0/tests/test_IndividualReporting.py +237 -0
  13. icalreporting-0.4.0/tests/test_Project.py +77 -0
  14. icalreporting-0.4.0/tests/test_cli.py +83 -0
  15. icalreporting-0.4.0/tests/test_icalimport.py +75 -0
  16. icalreporting-0.4.0/tests/test_icaltools.py +119 -0
  17. icalreporting-0.3.0/README.md +0 -41
  18. icalreporting-0.3.0/icalreporting/__init__.py +0 -1
  19. icalreporting-0.3.0/icalreporting/_cli.py +0 -62
  20. icalreporting-0.3.0/icalreporting/reporting.py +0 -287
  21. icalreporting-0.3.0/tests/test_Hyperplanning.py +0 -35
  22. icalreporting-0.3.0/tests/test_Project.py +0 -34
  23. icalreporting-0.3.0/tests/test_cli.py +0 -25
  24. icalreporting-0.3.0/tests/test_icalimport.py +0 -26
  25. icalreporting-0.3.0/tests/test_icaltools.py +0 -58
  26. {icalreporting-0.3.0 → icalreporting-0.4.0}/LICENSE +0 -0
  27. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting/icaltools.py +0 -0
  28. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/dependency_links.txt +0 -0
  29. {icalreporting-0.3.0 → icalreporting-0.4.0}/icalreporting.egg-info/top_level.txt +0 -0
  30. {icalreporting-0.3.0 → icalreporting-0.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: icalreporting
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Reporting tools from ical files
5
5
  Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
6
6
  License: MIT License
@@ -34,6 +34,7 @@ Classifier: Programming Language :: Python :: 3.9
34
34
  Classifier: Programming Language :: Python :: 3.10
35
35
  Classifier: Programming Language :: Python :: 3.11
36
36
  Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
37
38
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
38
39
  Requires-Python: >=3.9
39
40
  Description-Content-Type: text/markdown
@@ -41,49 +42,89 @@ License-File: LICENSE
41
42
  Requires-Dist: pandas>=2.1
42
43
  Requires-Dist: openpyxl>=3.1
43
44
  Requires-Dist: ical>=4.5
45
+ Requires-Dist: icalendar
44
46
  Provides-Extra: dev
45
47
  Requires-Dist: pytest>=6.0; extra == "dev"
46
48
  Requires-Dist: pytest-cov>=2.11.1; extra == "dev"
47
49
  Requires-Dist: pylint>=2.6.0; extra == "dev"
50
+ Dynamic: license-file
48
51
 
49
- icalreporting
50
- -----
52
+ # icalreporting
51
53
 
52
- [![PyPi Version](https://img.shields.io/pypi/v/icalreporting.svg?style=flat)](https://pypi.org/project/icalreporting)
53
- [![PyPI pyversions](https://img.shields.io/pypi/pyversions/icalreporting.svg?style=flat)](https://pypi.org/pypi/icalreporting/)
54
- [![GitHub stars](https://img.shields.io/github/stars/jgressier/icalreporting.svg?style=flat&logo=github&label=Stars&logoColor=white)](https://github.com/jgressier/icalreporting)
55
- [![PyPi downloads](https://img.shields.io/pypi/dm/icalreporting.svg?style=flat)](https://pypistats.org/packages/icalreporting)
56
- [![codecov](https://img.shields.io/codecov/c/github/jgressier/icalreporting.svg?style=flat)](https://codecov.io/gh/jgressier/icalreporting)
54
+ [![PyPI version](https://img.shields.io/pypi/v/icalreporting.svg?style=flat)](https://pypi.org/project/icalreporting)
55
+ [![Python versions](https://img.shields.io/pypi/pyversions/icalreporting.svg?style=flat)](https://pypi.org/project/icalreporting)
56
+ [![Coverage](https://img.shields.io/codecov/c/github/jgressier/icalreporting.svg?style=flat)](https://codecov.io/gh/jgressier/icalreporting)
57
57
 
58
- [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d32cf67a5fa242c88bb1568277f1d60e)](https://app.codacy.com/gh/jgressier/icalreporting/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Doc](https://readthedocs.org/projects/icalreporting/badge/?version=latest)](https://readthedocs.org/projects/icalreporting/)
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
58
+ `icalreporting` converts iCalendar (`.ics`) files into pandas-based activity reports and Excel
59
+ workbooks. It expands recurring events and treats each ICS filename stem as a project member.
63
60
 
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
61
+ ## Installation
67
62
 
68
- ### Installation
63
+ Requires Python 3.9 or later.
69
64
 
70
65
  ```bash
71
66
  pip install --upgrade icalreporting
72
67
  ```
73
- This automatic installation will get needed dependencies.
74
68
 
75
- ### Requirements
69
+ ## Project report
70
+
71
+ Place one ICS file per member in a directory. Work-package tags such as `WP2` are read from
72
+ event summaries.
73
+
74
+ ```python
75
+ from icalreporting.reporting import Project
76
+
77
+ project = Project(
78
+ name="Big Project",
79
+ folder="calendars",
80
+ start="2023-01-01",
81
+ end="2023-12-31",
82
+ )
83
+ project.load_ics()
84
+ project.workbook().save("report.xlsx")
85
+ ```
86
+
87
+ The workbook contains a global summary, member details, and monthly work-package totals.
88
+ All-day events are reported as 8-hour working days starting at 09:00.
76
89
 
77
- see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
90
+ `Hyperplanning` provides the same workflow for course calendars, grouped by course and
91
+ teaching type.
78
92
 
79
- ### Usage
93
+ ## Individual weekly report
80
94
 
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.
95
+ `IndividualReporting` expects one calendar whose summaries follow
96
+ `SECTOR/SUBSECTOR optional comment`.
82
97
 
83
98
  ```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
99
+ from icalreporting.reporting import IndividualReporting
100
+
101
+ report = IndividualReporting("My activity", "examples/indiv-reporting")
102
+ report.load_ics() # overlaps are corrected by shortening the first event
103
+ report.workbook().save("individual-report.xlsx")
89
104
  ```
105
+
106
+ Weeks run Sunday–Saturday. The workbook puts totals first, groups detail columns by sector then
107
+ subsector, and lists excluded malformed summaries in an `Unclassified` tab. It also reports hours
108
+ outside Monday–Friday 07:00–19:00.
109
+
110
+ ## Miscellaneous tools available through Command line
111
+
112
+ ```bash
113
+ icalcheck calendar.ics
114
+ icalclean calendar.ics # writes calendar.cleaned.ics
115
+
116
+ # One ICS file per project member
117
+ icalproject calendars project-report.xlsx --start 2023-01-01 --end 2023-12-31
118
+
119
+ # Exactly one ICS file, with SECTOR/SUBSECTOR summaries
120
+ icalindividual my-calendar individual-report.xlsx
121
+ ```
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ pip install -e ".[dev]"
127
+ pytest
128
+ ```
129
+
130
+ Released under the MIT License.
@@ -0,0 +1,79 @@
1
+ # icalreporting
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/icalreporting.svg?style=flat)](https://pypi.org/project/icalreporting)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/icalreporting.svg?style=flat)](https://pypi.org/project/icalreporting)
5
+ [![Coverage](https://img.shields.io/codecov/c/github/jgressier/icalreporting.svg?style=flat)](https://codecov.io/gh/jgressier/icalreporting)
6
+
7
+ `icalreporting` converts iCalendar (`.ics`) files into pandas-based activity reports and Excel
8
+ workbooks. It expands recurring events and treats each ICS filename stem as a project member.
9
+
10
+ ## Installation
11
+
12
+ Requires Python 3.9 or later.
13
+
14
+ ```bash
15
+ pip install --upgrade icalreporting
16
+ ```
17
+
18
+ ## Project report
19
+
20
+ Place one ICS file per member in a directory. Work-package tags such as `WP2` are read from
21
+ event summaries.
22
+
23
+ ```python
24
+ from icalreporting.reporting import Project
25
+
26
+ project = Project(
27
+ name="Big Project",
28
+ folder="calendars",
29
+ start="2023-01-01",
30
+ end="2023-12-31",
31
+ )
32
+ project.load_ics()
33
+ project.workbook().save("report.xlsx")
34
+ ```
35
+
36
+ The workbook contains a global summary, member details, and monthly work-package totals.
37
+ All-day events are reported as 8-hour working days starting at 09:00.
38
+
39
+ `Hyperplanning` provides the same workflow for course calendars, grouped by course and
40
+ teaching type.
41
+
42
+ ## Individual weekly report
43
+
44
+ `IndividualReporting` expects one calendar whose summaries follow
45
+ `SECTOR/SUBSECTOR optional comment`.
46
+
47
+ ```python
48
+ from icalreporting.reporting import IndividualReporting
49
+
50
+ report = IndividualReporting("My activity", "examples/indiv-reporting")
51
+ report.load_ics() # overlaps are corrected by shortening the first event
52
+ report.workbook().save("individual-report.xlsx")
53
+ ```
54
+
55
+ Weeks run Sunday–Saturday. The workbook puts totals first, groups detail columns by sector then
56
+ subsector, and lists excluded malformed summaries in an `Unclassified` tab. It also reports hours
57
+ outside Monday–Friday 07:00–19:00.
58
+
59
+ ## Miscellaneous tools available through Command line
60
+
61
+ ```bash
62
+ icalcheck calendar.ics
63
+ icalclean calendar.ics # writes calendar.cleaned.ics
64
+
65
+ # One ICS file per project member
66
+ icalproject calendars project-report.xlsx --start 2023-01-01 --end 2023-12-31
67
+
68
+ # Exactly one ICS file, with SECTOR/SUBSECTOR summaries
69
+ icalindividual my-calendar individual-report.xlsx
70
+ ```
71
+
72
+ ## Development
73
+
74
+ ```bash
75
+ pip install -e ".[dev]"
76
+ pytest
77
+ ```
78
+
79
+ Released under the MIT License.
@@ -0,0 +1 @@
1
+ __version__ = "0.4.0"
@@ -0,0 +1,124 @@
1
+ import argparse
2
+ import sys
3
+ from pathlib import Path
4
+
5
+ from icalreporting.reporting import IndividualReporting, Project
6
+ from icalreporting.icaltools import IcalFile
7
+
8
+ def _parseargs(argv, helpmsg=""):
9
+ try:
10
+ if argv is None:
11
+ argv = sys.argv[1:] # mimic argparse
12
+ filename = argv[0]
13
+ except IndexError:
14
+ print(helpmsg)
15
+ return True, argv
16
+ return False, argv
17
+
18
+ def icalcheck(argv=None): # argv for tests
19
+ error, argv = _parseargs(argv, helpmsg="usage: icalcheck <filename>")
20
+ if error:
21
+ return not error
22
+ filename = argv[0]
23
+ _default_engine = 'icalendar'
24
+ if _default_engine not in IcalFile._engines:
25
+ raise NotImplementedError(f"{_default_engine} engine not available")
26
+ # some info/stats/check with default engine
27
+ print(f"> checking ICAL file: {filename}")
28
+ file = IcalFile(filename, engine=_default_engine, verbose=False)
29
+ try:
30
+ file.read()
31
+ except FileNotFoundError as e:
32
+ print(f"Error reading file: {e}")
33
+ return False
34
+ print(f". number of events: {file.nevents()}")
35
+ # check all engine can read file
36
+ print("> check all reader engines")
37
+ for engine in IcalFile._engines:
38
+ print(f"- engine: {engine}")
39
+ file = IcalFile(filename, engine=engine, verbose=False)
40
+ try:
41
+ file.read()
42
+ except Exception as e:
43
+ print(f"Error reading file with engine {engine}: {e}")
44
+ error = True
45
+ print("> done")
46
+ return not error # for pytest
47
+
48
+ def icalclean(argv=None):
49
+ error, argv = _parseargs(argv, helpmsg="usage: icalclean <filename>")
50
+ if error:
51
+ return not error
52
+ filename = argv[0]
53
+ file = IcalFile(filename, engine='icalendar')
54
+ try:
55
+ file.read()
56
+ except FileNotFoundError as e:
57
+ print(f"Error reading file: {e}")
58
+ return False
59
+ print(f"- number of events: {file.nevents()}")
60
+ print(f"- normalizing timezones if necessary")
61
+ file.normalize_vtimezone()
62
+ print(f"- cleaning useless fields")
63
+ file.clean_events()
64
+ file.write(file._filename.with_suffix('.cleaned.ics'))
65
+ print("> done")
66
+ return not error # for pytest
67
+
68
+
69
+ def _report_parser(prog, description, include_default_wp=False):
70
+ parser = argparse.ArgumentParser(prog=prog, description=description)
71
+ parser.add_argument("folder", type=Path, help="folder containing ICS calendar files")
72
+ parser.add_argument("output", type=Path, help="XLSX workbook to create")
73
+ parser.add_argument("--start", default="2020-01-01", help="first included date (YYYY-MM-DD)")
74
+ parser.add_argument("--end", default="2030-01-01", help="last included date (YYYY-MM-DD)")
75
+ if include_default_wp:
76
+ parser.add_argument(
77
+ "--default-wp",
78
+ default="No_WP",
79
+ help="work-package label for events without a WP tag (default: No_WP)",
80
+ )
81
+ return parser
82
+
83
+
84
+ def icalproject(argv=None):
85
+ """Create a project XLSX workbook from ICS files in a folder."""
86
+ parser = _report_parser(
87
+ "icalproject",
88
+ "Create a project XLSX workbook from one ICS file per member.",
89
+ include_default_wp=True,
90
+ )
91
+ arguments = parser.parse_args(argv)
92
+ project = Project(
93
+ arguments.folder.name,
94
+ folder=arguments.folder,
95
+ start=arguments.start,
96
+ end=arguments.end,
97
+ default_WP=arguments.default_wp,
98
+ )
99
+ project.load_ics()
100
+ project.workbook().save(arguments.output)
101
+ print(f"Workbook written to {arguments.output}")
102
+ return True
103
+
104
+
105
+ def icalindividual(argv=None):
106
+ """Create an individual weekly XLSX workbook from one ICS file."""
107
+ parser = _report_parser(
108
+ "icalindividual",
109
+ "Create an individual weekly XLSX workbook from exactly one ICS file.",
110
+ )
111
+ parser.add_argument("--timezone", default="Europe/Paris", help="IANA timezone (default: Europe/Paris)")
112
+ arguments = parser.parse_args(argv)
113
+ report = IndividualReporting(
114
+ arguments.folder.name,
115
+ folder=arguments.folder,
116
+ start=arguments.start,
117
+ end=arguments.end,
118
+ timezone_name=arguments.timezone,
119
+ )
120
+ report.load_ics()
121
+ report.workbook().save(arguments.output)
122
+ print(f"Workbook written to {arguments.output}")
123
+ print(f"Detected {len(report._overlaps)} overlapping event pair(s)")
124
+ return True