icalendar-events-cli 1.0.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
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Sebastian Waldvogel
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,249 @@
1
+ Metadata-Version: 2.1
2
+ Name: icalendar-events-cli
3
+ Version: 1.0.0
4
+ Summary: Command-line tool to read events from a iCalendar (ICS)
5
+ Author-Email: Sebastian Waldvogel <sebastian@waldvogels.de>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/waldbaer/icalendar-events-cli
8
+ Requires-Python: >=3.9
9
+ Requires-Dist: tzlocal==5.2
10
+ Requires-Dist: pytz==2024.2
11
+ Requires-Dist: recurring-ical-events==3.4.1
12
+ Requires-Dist: requests>=2.32.3
13
+ Requires-Dist: requests-file>=2.1.0
14
+ Requires-Dist: jsonargparse>=4.36.0
15
+ Requires-Dist: rich-argparse>=1.6.0
16
+ Requires-Dist: pydantic>=2.10.5
17
+ Description-Content-Type: text/markdown
18
+
19
+ [![PyPI version](https://badge.fury.io/py/icalendar-events-cli.svg)](https://badge.fury.io/py/icalendar-events-cli)
20
+ [![MIT License](https://img.shields.io/github/license/waldbaer/icalendar-events-cli?style=flat-square)](https://opensource.org/licenses/MIT)
21
+ [![GitHub issues open](https://img.shields.io/github/issues/waldbaer/icalendar-events-cli?style=flat-square)](https://github.com/waldbaer/icalendar-events-cli/issues)
22
+ [![GitHub Actions](https://github.com/waldbaer/icalendar-events-cli/actions/workflows/python-pdm.yml/badge.svg?branch=master)](https://github.com/waldbaer/icalendar-events-cli/actions/workflows/python-pdm.yml)
23
+
24
+
25
+ # Command-line tool to read icalendar events
26
+
27
+ ## Introduction
28
+
29
+ This command-line tool allows users to query and filter [iCalendar (RFC 5545)](https://icalendar.org/RFC-Specifications/iCalendar-RFC-5545/) calendars. It leverages the excellent [recurring-ical-events](https://github.com/niccokunzmann/python-recurring-ical-events) library for parsing and querying the calendar contents.
30
+
31
+ Leveraging the powerful [jsonargparse](https://jsonargparse.readthedocs.io/) library, this tool supports configuration and control via command-line parameters or a JSON configuration file.
32
+
33
+ ## Features ##
34
+ - Download and parse iCalendar files
35
+ - from remote HTTP URL (`https://<path to icalendar server>`)
36
+ - from local file URL (`file://<abs. path to local ICS file>`)
37
+ - configurable encoding
38
+ - Filtering
39
+ - by start- and end-date range
40
+ - by event summary, description or location text (RegEx match)
41
+ - Different Outputs
42
+ - Formats: JSON, human-readable (pretty printed)
43
+ - Targets: shell (stdout), file
44
+
45
+ ## Changelog
46
+ Changes can be followed at [CHANGELOG.md](https://github.com/waldbaer/icalendar-events-cli/blob/master/CHANGELOG.md).
47
+
48
+ ## Requirements ##
49
+
50
+ - [Python 3.9](https://www.python.org/)
51
+ - [pip](https://pip.pypa.io/) or [pipx](https://pipx.pypa.io/stable/)
52
+
53
+ For development:
54
+ - [python-pdm (package dependency manager)](https://pdm-project.org/)
55
+
56
+ ## Setup
57
+
58
+ ### With pip / pipx
59
+ ```
60
+ pip install icalendar-events-cli
61
+ pipx install icalendar-events-cli
62
+ ```
63
+
64
+ ### Setup directly from github repo / clone
65
+ ```
66
+ git clone git@github.com:waldbaer/icalendar-events-cli.git
67
+ cd icalendar-events-cli
68
+
69
+ python -m venv .venv
70
+ source ./.venv/bin/activate
71
+ pip install .
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ All parameters can be provided either as command-line arguments or through a JSON configuration file (default: `config.json`).
77
+ A combination of both methods is also supported.
78
+
79
+ A common approach is to define the calendar URL and HTTP authentication credentials in the JSON configuration file,
80
+ while specifying filters as command-line arguments.
81
+ Alternatively, you can define all credentials via command-line parameters or include the applied filters directly in the
82
+ JSON configuration file.
83
+
84
+ The results of all executed queries are returned in human-readable (pretty-printed) or
85
+ machine-readable JSON format.
86
+ This output can be displayed directly on the shell (stdout) or saved to a file.
87
+
88
+ The machine-readable JSON output format is designed for seamless integration with automation
89
+ platforms, such as [Node-RED](https://nodered.org/), which typically execute the
90
+ `icalendar-events-cli` tool.
91
+
92
+
93
+
94
+ ### Examples
95
+
96
+ #### Example 1: Query Public Holiday Calendar
97
+
98
+ - Use human-readable output format
99
+ - Pass all parameters as command-line arguments
100
+
101
+ ```
102
+ icalendar-events-cli --calendar.url https://www.thunderbird.net/media/caldata/autogen/GermanHolidays.ics \
103
+ --filter.start-date $(date +%Y)-01-01T02:00:00+02:00 \
104
+ --filter.end-date $(date +%Y)-12-31T02:00:00+01:00 \
105
+ --filter.summary ".*(Weihnacht|Oster).*"
106
+
107
+ Start Date: 2025-01-01T02:00:00+02:00
108
+ End Date: 2025-12-31T02:00:00+01:00
109
+ Summary Filter: .*(Weihnacht|Oster).*
110
+ Number of Events: 3
111
+
112
+ 2025-04-20T00:00:00+02:00 -> 2025-04-20T23:59:59+02:00 [86399 sec] | Ostersonntag (Brandenburg) | Description: Common local holiday - Der Ostersonntag ist laut der christlichen Bibel ein Feiertag in Deutschland, um die Auferstehung Jesu Christi zu feiern.
113
+ 2025-04-21T00:00:00+02:00 -> 2025-04-21T23:59:59+02:00 [86399 sec] | Ostermontag | Description: Christian - Viele Menschen in Deutschland begehen jährlich den Ostermontag am Tag nach dem Ostersonntag. Es ist in allen Bundesstaaten ein Feiertag.
114
+ 2025-12-25T00:00:00+01:00 -> 2025-12-25T23:59:59+01:00 [86399 sec] | Weihnachten | Description: Christian - Der Weihnachtstag markiert die Geburt Jesu Christi und ist ein gesetzlicher Feiertag in Deutschland. Es ist jedes Jahr am 25. Dezember.
115
+ ```
116
+
117
+ #### Example 2: Query School Vacation Calendar
118
+
119
+ The machine-readable JSON output format is designed for seamless integration with automation platforms, such as [Node-RED](https://nodered.org/), which typically execute the `icalendar-events-cli` tool.
120
+
121
+ - Use JSON output format++
122
+ - Mixed parameter configuration: Pass only end-date as command-line argument.
123
+
124
+ Create `school-summer-vacation.json` containing calendar URL, summary filter and output format settings:
125
+ ```
126
+ {
127
+ "calendar" : {
128
+ "url" : "https://www.feiertage-deutschland.de/kalender-download/ics/schulferien-baden-wuerttemberg.ics",
129
+ "verify_url": true
130
+ },
131
+ "filter": {
132
+ "summary": "Sommer.*"
133
+ },
134
+ "output": {
135
+ "format": "json"
136
+ }
137
+ }
138
+ ```
139
+
140
+ Query the calendar for summer vacation until end of next year:
141
+ ```
142
+ icalendar-events-cli --config school-summer-vacation.json --filter.end-date $(($(date +%Y) + 1))-12-31T23:59:59
143
+
144
+ {
145
+ "filter": {
146
+ "start-date": "2025-01-25T11:09:20+01:00",
147
+ "end-date": "2026-12-31T23:59:59+01:00",
148
+ "summary": "Sommer.*"
149
+ },
150
+ "events": [
151
+ {
152
+ "start-date": "2025-07-31T00:00:00+02:00",
153
+ "end-date": "2025-09-13T23:59:59+02:00",
154
+ "summary": "Sommerferien Baden-Württemberg 2025",
155
+ "description": "Schulferien 2025: https://www.feiertage-deutschland.de/schulferien/2025/",
156
+ "location": "BW"
157
+ },
158
+ {
159
+ "start-date": "2026-07-30T00:00:00+02:00",
160
+ "end-date": "2026-09-12T23:59:59+02:00",
161
+ "summary": "Sommerferien Baden-Württemberg 2026",
162
+ "description": "Schulferien 2026: https://www.feiertage-deutschland.de/schulferien/2026/",
163
+ "location": "BW"
164
+ }
165
+ ]
166
+ }
167
+ ```
168
+
169
+
170
+ ### All Available Parameters and Configuration Options
171
+
172
+ Details about all available options:
173
+
174
+ ```
175
+ Usage: icalendar-events-cli [-h] [--version] [-c CONFIG] --calendar.url URL [--calendar.verify-url {true,false}]
176
+ [--calendar.user USER] [--calendar.password PASSWORD] [--calendar.encoding ENCODING]
177
+ [-s START_DATE] [-e END_DATE] [-f SUMMARY] [--filter.description DESCRIPTION]
178
+ [--filter.location LOCATION] [--output.format {human_readable,json}] [-o FILE]
179
+
180
+ Command-line tool to read events from a iCalendar (ICS) files. | Version 1.0.0 | Copyright 2023-2025
181
+
182
+ Default Config File Locations:
183
+ ['./config.json'], Note: no existing default config file found.
184
+
185
+ Options:
186
+ -h, --help Show this help message and exit.
187
+ --version Print version and exit.
188
+ -c, --config CONFIG Path to JSON configuration file.
189
+ --calendar.url URL URL of the iCalendar (ICS).
190
+ Also URLs to local files with schema file://<absolute path to local file> are supported. (required, type: None)
191
+ --calendar.verify-url {true,false}
192
+ Configure SSL verification of the URL (type: None, default: True)
193
+ --calendar.user USER Username for calendar URL HTTP authentication (basic authentication) (type: None, default: None)
194
+ --calendar.password PASSWORD
195
+ Password for calendar URL HTTP authentication (basic authentication) (type: None, default: None)
196
+ --calendar.encoding ENCODING
197
+ Encoding of the calendar (default: UTF-8)
198
+ -s, --filter.start-date START_DATE
199
+ Start date/time of event filter by time (ISO format). Default: now (type: datetime_isoformat, default: now)
200
+ -e, --filter.end-date END_DATE
201
+ End date/time of event filter by time (ISO format). Default: end of today (type: datetime_isoformat, default: end of today)
202
+ -f, --filter.summary SUMMARY
203
+ RegEx to filter calendar events based on the summary attribute. (type: regex_type, default: None)
204
+ --filter.description DESCRIPTION
205
+ RegEx to filter calendar events based on the description attribute. (type: regex_type, default: None)
206
+ --filter.location LOCATION
207
+ RegEx to filter calendar events based on the location attribute. (type: regex_type, default: None)
208
+ --output.format {human_readable,json}
209
+ Output format. (type: None, default: human_readable)
210
+ -o, --output.file FILE
211
+ Path of JSON output file. If not set the output is written to console / stdout (type: None, default: None)
212
+ ```
213
+
214
+
215
+ ## Development
216
+
217
+ ### Setup environment
218
+
219
+ ```
220
+ pdm install --dev
221
+ ```
222
+
223
+ ### Format / Linter / Tests
224
+
225
+ ```
226
+ # Check code style
227
+ pdm run format
228
+
229
+ # Check linter
230
+ pdm run lint
231
+
232
+ # Run tests
233
+ pdm run tests
234
+ ```
235
+
236
+ ### Publish
237
+
238
+ ```
239
+ # API token will be requested interactively as password
240
+ pdm publish -u __token__
241
+
242
+ # or to test.pypi.org
243
+ pdm publish --repository testpypi -u __token__
244
+ ```
245
+
246
+ ## Acknowledgments
247
+ Special thanks to [recurring-ical-events](https://github.com/niccokunzmann/python-recurring-ical-events) for providing
248
+ the core library that powers this tool.
249
+
@@ -0,0 +1,231 @@
1
+ [![PyPI version](https://badge.fury.io/py/icalendar-events-cli.svg)](https://badge.fury.io/py/icalendar-events-cli)
2
+ [![MIT License](https://img.shields.io/github/license/waldbaer/icalendar-events-cli?style=flat-square)](https://opensource.org/licenses/MIT)
3
+ [![GitHub issues open](https://img.shields.io/github/issues/waldbaer/icalendar-events-cli?style=flat-square)](https://github.com/waldbaer/icalendar-events-cli/issues)
4
+ [![GitHub Actions](https://github.com/waldbaer/icalendar-events-cli/actions/workflows/python-pdm.yml/badge.svg?branch=master)](https://github.com/waldbaer/icalendar-events-cli/actions/workflows/python-pdm.yml)
5
+
6
+
7
+ # Command-line tool to read icalendar events
8
+
9
+ ## Introduction
10
+
11
+ This command-line tool allows users to query and filter [iCalendar (RFC 5545)](https://icalendar.org/RFC-Specifications/iCalendar-RFC-5545/) calendars. It leverages the excellent [recurring-ical-events](https://github.com/niccokunzmann/python-recurring-ical-events) library for parsing and querying the calendar contents.
12
+
13
+ Leveraging the powerful [jsonargparse](https://jsonargparse.readthedocs.io/) library, this tool supports configuration and control via command-line parameters or a JSON configuration file.
14
+
15
+ ## Features ##
16
+ - Download and parse iCalendar files
17
+ - from remote HTTP URL (`https://<path to icalendar server>`)
18
+ - from local file URL (`file://<abs. path to local ICS file>`)
19
+ - configurable encoding
20
+ - Filtering
21
+ - by start- and end-date range
22
+ - by event summary, description or location text (RegEx match)
23
+ - Different Outputs
24
+ - Formats: JSON, human-readable (pretty printed)
25
+ - Targets: shell (stdout), file
26
+
27
+ ## Changelog
28
+ Changes can be followed at [CHANGELOG.md](https://github.com/waldbaer/icalendar-events-cli/blob/master/CHANGELOG.md).
29
+
30
+ ## Requirements ##
31
+
32
+ - [Python 3.9](https://www.python.org/)
33
+ - [pip](https://pip.pypa.io/) or [pipx](https://pipx.pypa.io/stable/)
34
+
35
+ For development:
36
+ - [python-pdm (package dependency manager)](https://pdm-project.org/)
37
+
38
+ ## Setup
39
+
40
+ ### With pip / pipx
41
+ ```
42
+ pip install icalendar-events-cli
43
+ pipx install icalendar-events-cli
44
+ ```
45
+
46
+ ### Setup directly from github repo / clone
47
+ ```
48
+ git clone git@github.com:waldbaer/icalendar-events-cli.git
49
+ cd icalendar-events-cli
50
+
51
+ python -m venv .venv
52
+ source ./.venv/bin/activate
53
+ pip install .
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ All parameters can be provided either as command-line arguments or through a JSON configuration file (default: `config.json`).
59
+ A combination of both methods is also supported.
60
+
61
+ A common approach is to define the calendar URL and HTTP authentication credentials in the JSON configuration file,
62
+ while specifying filters as command-line arguments.
63
+ Alternatively, you can define all credentials via command-line parameters or include the applied filters directly in the
64
+ JSON configuration file.
65
+
66
+ The results of all executed queries are returned in human-readable (pretty-printed) or
67
+ machine-readable JSON format.
68
+ This output can be displayed directly on the shell (stdout) or saved to a file.
69
+
70
+ The machine-readable JSON output format is designed for seamless integration with automation
71
+ platforms, such as [Node-RED](https://nodered.org/), which typically execute the
72
+ `icalendar-events-cli` tool.
73
+
74
+
75
+
76
+ ### Examples
77
+
78
+ #### Example 1: Query Public Holiday Calendar
79
+
80
+ - Use human-readable output format
81
+ - Pass all parameters as command-line arguments
82
+
83
+ ```
84
+ icalendar-events-cli --calendar.url https://www.thunderbird.net/media/caldata/autogen/GermanHolidays.ics \
85
+ --filter.start-date $(date +%Y)-01-01T02:00:00+02:00 \
86
+ --filter.end-date $(date +%Y)-12-31T02:00:00+01:00 \
87
+ --filter.summary ".*(Weihnacht|Oster).*"
88
+
89
+ Start Date: 2025-01-01T02:00:00+02:00
90
+ End Date: 2025-12-31T02:00:00+01:00
91
+ Summary Filter: .*(Weihnacht|Oster).*
92
+ Number of Events: 3
93
+
94
+ 2025-04-20T00:00:00+02:00 -> 2025-04-20T23:59:59+02:00 [86399 sec] | Ostersonntag (Brandenburg) | Description: Common local holiday - Der Ostersonntag ist laut der christlichen Bibel ein Feiertag in Deutschland, um die Auferstehung Jesu Christi zu feiern.
95
+ 2025-04-21T00:00:00+02:00 -> 2025-04-21T23:59:59+02:00 [86399 sec] | Ostermontag | Description: Christian - Viele Menschen in Deutschland begehen jährlich den Ostermontag am Tag nach dem Ostersonntag. Es ist in allen Bundesstaaten ein Feiertag.
96
+ 2025-12-25T00:00:00+01:00 -> 2025-12-25T23:59:59+01:00 [86399 sec] | Weihnachten | Description: Christian - Der Weihnachtstag markiert die Geburt Jesu Christi und ist ein gesetzlicher Feiertag in Deutschland. Es ist jedes Jahr am 25. Dezember.
97
+ ```
98
+
99
+ #### Example 2: Query School Vacation Calendar
100
+
101
+ The machine-readable JSON output format is designed for seamless integration with automation platforms, such as [Node-RED](https://nodered.org/), which typically execute the `icalendar-events-cli` tool.
102
+
103
+ - Use JSON output format++
104
+ - Mixed parameter configuration: Pass only end-date as command-line argument.
105
+
106
+ Create `school-summer-vacation.json` containing calendar URL, summary filter and output format settings:
107
+ ```
108
+ {
109
+ "calendar" : {
110
+ "url" : "https://www.feiertage-deutschland.de/kalender-download/ics/schulferien-baden-wuerttemberg.ics",
111
+ "verify_url": true
112
+ },
113
+ "filter": {
114
+ "summary": "Sommer.*"
115
+ },
116
+ "output": {
117
+ "format": "json"
118
+ }
119
+ }
120
+ ```
121
+
122
+ Query the calendar for summer vacation until end of next year:
123
+ ```
124
+ icalendar-events-cli --config school-summer-vacation.json --filter.end-date $(($(date +%Y) + 1))-12-31T23:59:59
125
+
126
+ {
127
+ "filter": {
128
+ "start-date": "2025-01-25T11:09:20+01:00",
129
+ "end-date": "2026-12-31T23:59:59+01:00",
130
+ "summary": "Sommer.*"
131
+ },
132
+ "events": [
133
+ {
134
+ "start-date": "2025-07-31T00:00:00+02:00",
135
+ "end-date": "2025-09-13T23:59:59+02:00",
136
+ "summary": "Sommerferien Baden-Württemberg 2025",
137
+ "description": "Schulferien 2025: https://www.feiertage-deutschland.de/schulferien/2025/",
138
+ "location": "BW"
139
+ },
140
+ {
141
+ "start-date": "2026-07-30T00:00:00+02:00",
142
+ "end-date": "2026-09-12T23:59:59+02:00",
143
+ "summary": "Sommerferien Baden-Württemberg 2026",
144
+ "description": "Schulferien 2026: https://www.feiertage-deutschland.de/schulferien/2026/",
145
+ "location": "BW"
146
+ }
147
+ ]
148
+ }
149
+ ```
150
+
151
+
152
+ ### All Available Parameters and Configuration Options
153
+
154
+ Details about all available options:
155
+
156
+ ```
157
+ Usage: icalendar-events-cli [-h] [--version] [-c CONFIG] --calendar.url URL [--calendar.verify-url {true,false}]
158
+ [--calendar.user USER] [--calendar.password PASSWORD] [--calendar.encoding ENCODING]
159
+ [-s START_DATE] [-e END_DATE] [-f SUMMARY] [--filter.description DESCRIPTION]
160
+ [--filter.location LOCATION] [--output.format {human_readable,json}] [-o FILE]
161
+
162
+ Command-line tool to read events from a iCalendar (ICS) files. | Version 1.0.0 | Copyright 2023-2025
163
+
164
+ Default Config File Locations:
165
+ ['./config.json'], Note: no existing default config file found.
166
+
167
+ Options:
168
+ -h, --help Show this help message and exit.
169
+ --version Print version and exit.
170
+ -c, --config CONFIG Path to JSON configuration file.
171
+ --calendar.url URL URL of the iCalendar (ICS).
172
+ Also URLs to local files with schema file://<absolute path to local file> are supported. (required, type: None)
173
+ --calendar.verify-url {true,false}
174
+ Configure SSL verification of the URL (type: None, default: True)
175
+ --calendar.user USER Username for calendar URL HTTP authentication (basic authentication) (type: None, default: None)
176
+ --calendar.password PASSWORD
177
+ Password for calendar URL HTTP authentication (basic authentication) (type: None, default: None)
178
+ --calendar.encoding ENCODING
179
+ Encoding of the calendar (default: UTF-8)
180
+ -s, --filter.start-date START_DATE
181
+ Start date/time of event filter by time (ISO format). Default: now (type: datetime_isoformat, default: now)
182
+ -e, --filter.end-date END_DATE
183
+ End date/time of event filter by time (ISO format). Default: end of today (type: datetime_isoformat, default: end of today)
184
+ -f, --filter.summary SUMMARY
185
+ RegEx to filter calendar events based on the summary attribute. (type: regex_type, default: None)
186
+ --filter.description DESCRIPTION
187
+ RegEx to filter calendar events based on the description attribute. (type: regex_type, default: None)
188
+ --filter.location LOCATION
189
+ RegEx to filter calendar events based on the location attribute. (type: regex_type, default: None)
190
+ --output.format {human_readable,json}
191
+ Output format. (type: None, default: human_readable)
192
+ -o, --output.file FILE
193
+ Path of JSON output file. If not set the output is written to console / stdout (type: None, default: None)
194
+ ```
195
+
196
+
197
+ ## Development
198
+
199
+ ### Setup environment
200
+
201
+ ```
202
+ pdm install --dev
203
+ ```
204
+
205
+ ### Format / Linter / Tests
206
+
207
+ ```
208
+ # Check code style
209
+ pdm run format
210
+
211
+ # Check linter
212
+ pdm run lint
213
+
214
+ # Run tests
215
+ pdm run tests
216
+ ```
217
+
218
+ ### Publish
219
+
220
+ ```
221
+ # API token will be requested interactively as password
222
+ pdm publish -u __token__
223
+
224
+ # or to test.pypi.org
225
+ pdm publish --repository testpypi -u __token__
226
+ ```
227
+
228
+ ## Acknowledgments
229
+ Special thanks to [recurring-ical-events](https://github.com/niccokunzmann/python-recurring-ical-events) for providing
230
+ the core library that powers this tool.
231
+
@@ -0,0 +1,123 @@
1
+ [project]
2
+ name = "icalendar-events-cli"
3
+ dynamic = []
4
+ description = "Command-line tool to read events from a iCalendar (ICS)"
5
+ authors = [
6
+ { name = "Sebastian Waldvogel", email = "sebastian@waldvogels.de" },
7
+ ]
8
+ readme = "README.md"
9
+ requires-python = ">=3.9"
10
+ dependencies = [
11
+ "tzlocal==5.2",
12
+ "pytz==2024.2",
13
+ "recurring-ical-events==3.4.1",
14
+ "requests>=2.32.3",
15
+ "requests-file>=2.1.0",
16
+ "jsonargparse>=4.36.0",
17
+ "rich-argparse>=1.6.0",
18
+ "pydantic>=2.10.5",
19
+ ]
20
+ version = "1.0.0"
21
+
22
+ [project.license]
23
+ text = "MIT"
24
+
25
+ [project.scripts]
26
+ icalendar-events-cli = "icalendar_events_cli.__main__:cli"
27
+
28
+ [project.urls]
29
+ Repository = "https://github.com/waldbaer/icalendar-events-cli"
30
+
31
+ [build-system]
32
+ requires = [
33
+ "pdm-backend",
34
+ ]
35
+ build-backend = "pdm.backend"
36
+
37
+ [dependency-groups]
38
+ lint = [
39
+ "ruff>=0.8.3",
40
+ ]
41
+ pytest = [
42
+ "pytest-cov>=6.0.0",
43
+ "pytest_httpserver>=1.1.0",
44
+ ]
45
+ docs = [
46
+ "mkdocs>=1.6.1",
47
+ "mkdocs-material>=9.5.49",
48
+ ]
49
+
50
+ [tool.pdm]
51
+ distribution = true
52
+
53
+ [tool.pdm.version]
54
+ source = "scm"
55
+
56
+ [tool.pdm.scripts]
57
+ lint = "ruff check ."
58
+ format = "ruff format ."
59
+ docs = "mkdocs serve"
60
+ tests = "pytest --cov-report term-missing --cov=icalendar_events_cli --cov-fail-under=100 --verbose"
61
+
62
+ [tool.ruff]
63
+ include = [
64
+ "**/*.py",
65
+ "**/*.pyi",
66
+ "**/pyproject.toml",
67
+ ]
68
+ line-length = 120
69
+
70
+ [tool.ruff.lint]
71
+ select = [
72
+ "ARG",
73
+ "ANN",
74
+ "B",
75
+ "C4",
76
+ "D",
77
+ "DOC",
78
+ "E",
79
+ "F",
80
+ "I",
81
+ "W",
82
+ "UP",
83
+ ]
84
+ extend-select = [
85
+ "DOC",
86
+ ]
87
+ preview = true
88
+ ignore = [
89
+ "UP006",
90
+ "UP035",
91
+ ]
92
+
93
+ [tool.ruff.lint.per-file-ignores]
94
+ "tests/**" = [
95
+ "PLC2701",
96
+ ]
97
+
98
+ [tool.ruff.lint.pydocstyle]
99
+ convention = "google"
100
+
101
+ [tool.pylint]
102
+ load-plugins = [
103
+ "pylint.extensions.docparams",
104
+ ]
105
+
106
+ [tool.pylint.format]
107
+ max-line-length = 120
108
+
109
+ [tool.pylint.main]
110
+ ignore-paths = [
111
+ ".venv",
112
+ ".git",
113
+ "__pypackages__",
114
+ "tests/_temp",
115
+ "tests",
116
+ ]
117
+ accept-no-param-doc = "no"
118
+ accept-no-raise-doc = "no"
119
+ accept-no-yields-doc = "no"
120
+ default-docstring-type = "google"
121
+
122
+ [tool.mypy]
123
+ strict = true
@@ -0,0 +1 @@
1
+ """Module init."""
@@ -0,0 +1,59 @@
1
+ """Commandline interface entry point."""
2
+
3
+ # ---- Imports --------------------------------------------------------------------------------------------------------
4
+ import importlib.metadata
5
+ import os
6
+ from typing import Optional
7
+
8
+ from .argparse import parse_config
9
+ from .downloader import download_ics
10
+ from .icalendar import filter_events, parse_calendar
11
+ from .output import output_events
12
+
13
+ # ---- Module Meta-Data ------------------------------------------------------------------------------------------------
14
+ __prog__ = "icalendar-events-cli"
15
+ __dist_name__ = "icalendar_events_cli"
16
+ __copyright__ = "Copyright 2023-2025"
17
+ __author__ = "Sebastian Waldvogel"
18
+
19
+ # ---- Main -----------------------------------------------------------------------------------------------------------
20
+
21
+
22
+ def cli(arg_list: Optional[list[str]] = None) -> int:
23
+ """Main command line handling entry point.
24
+
25
+ Arguments:
26
+ arg_list: Optional list of command line arguments. Only needed for testing.
27
+ Productive __main__ will call the API without any argument.
28
+
29
+ Returns:
30
+ Numeric exit code
31
+ """
32
+ try:
33
+ config = parse_config(
34
+ prog=__prog__,
35
+ version=importlib.metadata.version(__dist_name__),
36
+ copy_right=__copyright__,
37
+ author=__author__,
38
+ arg_list=arg_list,
39
+ )
40
+ return _main_logic(config)
41
+
42
+ except SystemExit as e:
43
+ return e.code
44
+
45
+ except BaseException as e: # pylint: disable=broad-exception-caught;reason=Explicitely capture all exceptions thrown during execution.
46
+ print(
47
+ f"ERROR: Any error has occured!{os.linesep}{os.linesep}Exception: {str(e)}"
48
+ # f"Detailed Traceback: {traceback.format_exc()}"
49
+ )
50
+ return 1
51
+
52
+
53
+ def _main_logic(config: dict) -> int:
54
+ calendar_ics = download_ics(config.calendar)
55
+ events = parse_calendar(calendar_ics, config.filter)
56
+ events = filter_events(events, config.filter, config.calendar.encoding)
57
+ output_events(events, config)
58
+
59
+ return os.EX_OK