ics-query 0.1.1a0__py3-none-any.whl → 0.3.1b0__py3-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.
Files changed (36) hide show
  1. ics_query/__init__.py +18 -2
  2. ics_query/__main__.py +15 -0
  3. ics_query/_version.py +2 -2
  4. ics_query/cli.py +455 -23
  5. ics_query/parse.py +41 -4
  6. ics_query/query.py +71 -0
  7. ics_query/tests/conftest.py +15 -0
  8. ics_query/tests/runs/all --tz Singapore one-event.ics -.run +9 -0
  9. ics_query/tests/runs/all three-events.ics -.run +33 -0
  10. ics_query/tests/runs/at 2024-08-20 Berlin-Los-Angeles.ics -.run +23 -0
  11. ics_query/tests/runs/between 20240823 4d recurring-work-events.ics -.run +24 -0
  12. ics_query/tests/runs/calendars/Berlin-Los-Angeles.ics +381 -0
  13. ics_query/tests/runs/calendars/empty-calendar.ics +7 -0
  14. ics_query/tests/runs/calendars/empty-file.ics +0 -0
  15. ics_query/tests/runs/calendars/recurring-work-events.ics +223 -0
  16. ics_query/tests/runs/calendars/simple-journal.ics +15 -0
  17. ics_query/tests/runs/calendars/simple-todo.ics +15 -0
  18. ics_query/tests/runs/calendars/three-events.ics +37 -0
  19. ics_query/tests/runs/first -c VJOURNAL -c VEVENT one-event.ics -.run +9 -0
  20. ics_query/tests/runs/first -c VJOURNAL one-event.ics -.run +0 -0
  21. ics_query/tests/runs/first -c VJOURNAL simple-journal.ics -.run +12 -0
  22. ics_query/tests/runs/first -c VTODO -c VJOURNAL simple-todo.ics -.run +10 -0
  23. ics_query/tests/runs/first -c VTODO simple-todo.ics -.run +10 -0
  24. ics_query/tests/runs/first empty-calendar.ics -.run +0 -0
  25. ics_query/tests/runs/first empty-file.ics -.run +0 -0
  26. ics_query/tests/runs/first recurring-work-events.ics -.run +12 -0
  27. ics_query/tests/test_command_line.py +34 -0
  28. ics_query/tests/test_parse_date.py +23 -5
  29. ics_query/tests/test_parse_timedelta.py +40 -0
  30. ics_query/version.py +33 -3
  31. {ics_query-0.1.1a0.dist-info → ics_query-0.3.1b0.dist-info}/METADATA +247 -51
  32. ics_query-0.3.1b0.dist-info/RECORD +43 -0
  33. ics_query-0.1.1a0.dist-info/RECORD +0 -22
  34. {ics_query-0.1.1a0.dist-info → ics_query-0.3.1b0.dist-info}/WHEEL +0 -0
  35. {ics_query-0.1.1a0.dist-info → ics_query-0.3.1b0.dist-info}/entry_points.txt +0 -0
  36. {ics_query-0.1.1a0.dist-info → ics_query-0.3.1b0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,223 @@
1
+ BEGIN:VCALENDAR
2
+ PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
3
+ VERSION:2.0
4
+ BEGIN:VTIMEZONE
5
+ TZID:Europe/Berlin
6
+ X-TZINFO:Europe/Berlin[2024a]
7
+ BEGIN:STANDARD
8
+ TZOFFSETTO:+010000
9
+ TZOFFSETFROM:+005328
10
+ TZNAME:Europe/Berlin(STD)
11
+ DTSTART:18930401T000000
12
+ RDATE:18930401T000000
13
+ END:STANDARD
14
+ BEGIN:DAYLIGHT
15
+ TZOFFSETTO:+020000
16
+ TZOFFSETFROM:+010000
17
+ TZNAME:Europe/Berlin(DST)
18
+ DTSTART:19160430T230000
19
+ RDATE:19160430T230000
20
+ END:DAYLIGHT
21
+ BEGIN:STANDARD
22
+ TZOFFSETTO:+010000
23
+ TZOFFSETFROM:+020000
24
+ TZNAME:Europe/Berlin(STD)
25
+ DTSTART:19161001T010000
26
+ RDATE:19161001T010000
27
+ END:STANDARD
28
+ BEGIN:DAYLIGHT
29
+ TZOFFSETTO:+020000
30
+ TZOFFSETFROM:+010000
31
+ TZNAME:Europe/Berlin(DST)
32
+ DTSTART:19170416T020000
33
+ RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=3MO;UNTIL=19180415T020000
34
+ END:DAYLIGHT
35
+ BEGIN:STANDARD
36
+ TZOFFSETTO:+010000
37
+ TZOFFSETFROM:+020000
38
+ TZNAME:Europe/Berlin(STD)
39
+ DTSTART:19170917T030000
40
+ RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=3MO;UNTIL=19180916T030000
41
+ END:STANDARD
42
+ BEGIN:DAYLIGHT
43
+ TZOFFSETTO:+020000
44
+ TZOFFSETFROM:+010000
45
+ TZNAME:Europe/Berlin(DST)
46
+ DTSTART:19400401T020000
47
+ RDATE:19400401T020000
48
+ END:DAYLIGHT
49
+ BEGIN:STANDARD
50
+ TZOFFSETTO:+010000
51
+ TZOFFSETFROM:+020000
52
+ TZNAME:Europe/Berlin(STD)
53
+ DTSTART:19421102T030000
54
+ RDATE:19421102T030000
55
+ END:STANDARD
56
+ BEGIN:DAYLIGHT
57
+ TZOFFSETTO:+020000
58
+ TZOFFSETFROM:+010000
59
+ TZNAME:Europe/Berlin(DST)
60
+ DTSTART:19430329T020000
61
+ RDATE:19430329T020000
62
+ END:DAYLIGHT
63
+ BEGIN:DAYLIGHT
64
+ TZOFFSETTO:+020000
65
+ TZOFFSETFROM:+010000
66
+ TZNAME:Europe/Berlin(DST)
67
+ DTSTART:19440403T020000
68
+ RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO;UNTIL=19450402T020000
69
+ END:DAYLIGHT
70
+ BEGIN:DAYLIGHT
71
+ TZOFFSETTO:+030000
72
+ TZOFFSETFROM:+020000
73
+ TZNAME:Europe/Berlin(DST)
74
+ DTSTART:19450524T020000
75
+ RDATE:19450524T020000
76
+ END:DAYLIGHT
77
+ BEGIN:STANDARD
78
+ TZOFFSETTO:+010000
79
+ TZOFFSETFROM:+020000
80
+ TZNAME:Europe/Berlin(STD)
81
+ DTSTART:19431004T030000
82
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1MO;UNTIL=19441002T030000
83
+ END:STANDARD
84
+ BEGIN:DAYLIGHT
85
+ TZOFFSETTO:+020000
86
+ TZOFFSETFROM:+030000
87
+ TZNAME:Europe/Berlin(DST)
88
+ DTSTART:19450924T030000
89
+ RDATE:19450924T030000
90
+ END:DAYLIGHT
91
+ BEGIN:STANDARD
92
+ TZOFFSETTO:+010000
93
+ TZOFFSETFROM:+020000
94
+ TZNAME:Europe/Berlin(STD)
95
+ DTSTART:19451118T030000
96
+ RDATE:19451118T030000
97
+ END:STANDARD
98
+ BEGIN:DAYLIGHT
99
+ TZOFFSETTO:+020000
100
+ TZOFFSETFROM:+010000
101
+ TZNAME:Europe/Berlin(DST)
102
+ DTSTART:19460414T020000
103
+ RDATE:19460414T020000
104
+ END:DAYLIGHT
105
+ BEGIN:DAYLIGHT
106
+ TZOFFSETTO:+020000
107
+ TZOFFSETFROM:+010000
108
+ TZNAME:Europe/Berlin(DST)
109
+ DTSTART:19470406T030000
110
+ RDATE:19470406T030000
111
+ END:DAYLIGHT
112
+ BEGIN:DAYLIGHT
113
+ TZOFFSETTO:+030000
114
+ TZOFFSETFROM:+020000
115
+ TZNAME:Europe/Berlin(DST)
116
+ DTSTART:19470511T030000
117
+ RDATE:19470511T030000
118
+ END:DAYLIGHT
119
+ BEGIN:STANDARD
120
+ TZOFFSETTO:+010000
121
+ TZOFFSETFROM:+020000
122
+ TZNAME:Europe/Berlin(STD)
123
+ DTSTART:19461007T030000
124
+ RDATE:19461007T030000
125
+ END:STANDARD
126
+ BEGIN:DAYLIGHT
127
+ TZOFFSETTO:+020000
128
+ TZOFFSETFROM:+030000
129
+ TZNAME:Europe/Berlin(DST)
130
+ DTSTART:19470629T030000
131
+ RDATE:19470629T030000
132
+ END:DAYLIGHT
133
+ BEGIN:DAYLIGHT
134
+ TZOFFSETTO:+020000
135
+ TZOFFSETFROM:+010000
136
+ TZNAME:Europe/Berlin(DST)
137
+ DTSTART:19480418T020000
138
+ RDATE:19480418T020000
139
+ END:DAYLIGHT
140
+ BEGIN:DAYLIGHT
141
+ TZOFFSETTO:+020000
142
+ TZOFFSETFROM:+010000
143
+ TZNAME:Europe/Berlin(DST)
144
+ DTSTART:19490410T020000
145
+ RDATE:19490410T020000
146
+ END:DAYLIGHT
147
+ BEGIN:STANDARD
148
+ TZOFFSETTO:+010000
149
+ TZOFFSETFROM:+020000
150
+ TZNAME:Europe/Berlin(STD)
151
+ DTSTART:19471005T030000
152
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU;UNTIL=19491002T030000
153
+ END:STANDARD
154
+ BEGIN:DAYLIGHT
155
+ TZOFFSETTO:+020000
156
+ TZOFFSETFROM:+010000
157
+ TZNAME:Europe/Berlin(DST)
158
+ DTSTART:19800406T020000
159
+ RDATE:19800406T020000
160
+ END:DAYLIGHT
161
+ BEGIN:STANDARD
162
+ TZOFFSETTO:+010000
163
+ TZOFFSETFROM:+020000
164
+ TZNAME:Europe/Berlin(STD)
165
+ DTSTART:19800928T030000
166
+ RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU;UNTIL=19950924T030000
167
+ END:STANDARD
168
+ BEGIN:DAYLIGHT
169
+ TZOFFSETTO:+020000
170
+ TZOFFSETFROM:+010000
171
+ TZNAME:Europe/Berlin(DST)
172
+ DTSTART:19810329T020000
173
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU;UNTIL=19960331T020000
174
+ END:DAYLIGHT
175
+ BEGIN:STANDARD
176
+ TZOFFSETTO:+010000
177
+ TZOFFSETFROM:+020000
178
+ TZNAME:Europe/Berlin(STD)
179
+ DTSTART:19961027T030000
180
+ RDATE:19961027T030000
181
+ END:STANDARD
182
+ BEGIN:DAYLIGHT
183
+ TZOFFSETTO:+020000
184
+ TZOFFSETFROM:+010000
185
+ TZNAME:(DST)
186
+ DTSTART:19970330T020000
187
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
188
+ END:DAYLIGHT
189
+ BEGIN:STANDARD
190
+ TZOFFSETTO:+010000
191
+ TZOFFSETFROM:+020000
192
+ TZNAME:(STD)
193
+ DTSTART:19971026T030000
194
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
195
+ END:STANDARD
196
+ END:VTIMEZONE
197
+ BEGIN:VEVENT
198
+ CREATED:20240823T082735Z
199
+ LAST-MODIFIED:20240823T082802Z
200
+ DTSTAMP:20240823T082802Z
201
+ UID:22d43072-b75a-43da-bed0-a5da8a7a6853
202
+ SUMMARY:Weekly Tuesday Morning Meeting
203
+ RRULE:FREQ=WEEKLY
204
+ DTSTART;TZID=Europe/Berlin:20240820T090000
205
+ DTEND;TZID=Europe/Berlin:20240820T100000
206
+ TRANSP:OPAQUE
207
+ X-MOZ-GENERATION:2
208
+ SEQUENCE:1
209
+ END:VEVENT
210
+ BEGIN:VEVENT
211
+ CREATED:20240823T082829Z
212
+ LAST-MODIFIED:20240823T082915Z
213
+ DTSTAMP:20240823T082915Z
214
+ UID:6b85b60c-eb1a-4338-9ece-33541b95bf17
215
+ SUMMARY:Work
216
+ RRULE:FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR
217
+ DTSTART;TZID=Europe/Berlin:20240819T090000
218
+ DTEND;TZID=Europe/Berlin:20240819T170000
219
+ TRANSP:OPAQUE
220
+ X-MOZ-GENERATION:2
221
+ SEQUENCE:1
222
+ END:VEVENT
223
+ END:VCALENDAR
@@ -0,0 +1,15 @@
1
+ BEGIN:VCALENDAR
2
+ VERSION:2.0
3
+ PRODID:-//Example Corp.//CalDAV Client//EN
4
+ BEGIN:VJOURNAL
5
+ UID:19920901T130000Z-123409@host.com
6
+ DTSTAMP:19920901T130000Z
7
+ DTSTART:19920420
8
+ SUMMARY:Yearly Income Tax Report
9
+ DESCRIPTION:We made it this year too. Probably. What's the point of a recurring journal entry? Journals are supposed to describe past events, aren't they?
10
+ RRULE:FREQ=YEARLY
11
+ CLASS:CONFIDENTIAL
12
+ CATEGORIES:FAMILY,FINANCE
13
+ PRIORITY:1
14
+ END:VJOURNAL
15
+ END:VCALENDAR
@@ -0,0 +1,15 @@
1
+ BEGIN:VCALENDAR
2
+ VERSION:2.0
3
+ PRODID:-//Example Corp.//CalDAV Client//EN
4
+ BEGIN:VTODO
5
+ UID:19920901T130000Z-123408@host.com
6
+ DTSTAMP:19920901T130000Z
7
+ DTSTART:19920415T133000Z
8
+ DUE:19920516T045959Z
9
+ SUMMARY:Yearly Income Tax Preparation
10
+ RRULE:FREQ=YEARLY
11
+ CLASS:CONFIDENTIAL
12
+ CATEGORIES:FAMILY,FINANCE
13
+ PRIORITY:1
14
+ END:VTODO
15
+ END:VCALENDAR
@@ -0,0 +1,37 @@
1
+ BEGIN:VCALENDAR
2
+ VERSION:2.0
3
+ PRODID:-//SabreDAV//SabreDAV//EN
4
+ CALSCALE:GREGORIAN
5
+ X-WR-CALNAME:test
6
+ X-APPLE-CALENDAR-COLOR:#e78074
7
+ BEGIN:VTIMEZONE
8
+ TZID:Europe/Berlin
9
+ X-LIC-LOCATION:Europe/Berlin
10
+ BEGIN:DAYLIGHT
11
+ TZOFFSETFROM:+0100
12
+ TZOFFSETTO:+0200
13
+ TZNAME:CEST
14
+ DTSTART:19700329T020000
15
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
16
+ END:DAYLIGHT
17
+ BEGIN:STANDARD
18
+ TZOFFSETFROM:+0200
19
+ TZOFFSETTO:+0100
20
+ TZNAME:CET
21
+ DTSTART:19701025T030000
22
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
23
+ END:STANDARD
24
+ END:VTIMEZONE
25
+ BEGIN:VEVENT
26
+ CREATED:20190303T111937
27
+ DTSTAMP:20190303T111937
28
+ LAST-MODIFIED:20190303T111937
29
+ UID:UYDQSG9TH4DE0WM3QFL2J
30
+ SUMMARY:test4
31
+ CLASS:PUBLIC
32
+ STATUS:CONFIRMED
33
+ RRULE:FREQ=DAILY;COUNT=3;INTERVAL=3
34
+ DTSTART;TZID=Europe/Berlin:20190304T000000
35
+ DTEND;TZID=Europe/Berlin:20190304T010000
36
+ END:VEVENT
37
+ END:VCALENDAR
@@ -0,0 +1,9 @@
1
+ BEGIN:VEVENT
2
+ SUMMARY:test1
3
+ DTSTART;TZID=Europe/Berlin:20190304T080000
4
+ DTEND;TZID=Europe/Berlin:20190304T083000
5
+ DTSTAMP:20190303T111937
6
+ UID:UYDQSG9TH4DE0WM3QFL2J
7
+ CREATED:20190303T111937
8
+ LAST-MODIFIED:20190303T111937
9
+ END:VEVENT
@@ -0,0 +1,12 @@
1
+ BEGIN:VJOURNAL
2
+ CATEGORIES:FAMILY,FINANCE
3
+ CLASS:CONFIDENTIAL
4
+ DESCRIPTION:We made it this year too. Probably. What's the point of a re
5
+ curring journal entry? Journals are supposed to describe past events\, ar
6
+ en't they?
7
+ DTSTAMP:19920901T130000Z
8
+ DTSTART;VALUE=DATE:19920420
9
+ PRIORITY:1
10
+ SUMMARY:Yearly Income Tax Report
11
+ UID:19920901T130000Z-123409@host.com
12
+ END:VJOURNAL
@@ -0,0 +1,10 @@
1
+ BEGIN:VTODO
2
+ CATEGORIES:FAMILY,FINANCE
3
+ CLASS:CONFIDENTIAL
4
+ DTSTAMP:19920901T130000Z
5
+ DTSTART:19920415T133000Z
6
+ DUE:19920516T045959Z
7
+ PRIORITY:1
8
+ SUMMARY:Yearly Income Tax Preparation
9
+ UID:19920901T130000Z-123408@host.com
10
+ END:VTODO
@@ -0,0 +1,10 @@
1
+ BEGIN:VTODO
2
+ CATEGORIES:FAMILY,FINANCE
3
+ CLASS:CONFIDENTIAL
4
+ DTSTAMP:19920901T130000Z
5
+ DTSTART:19920415T133000Z
6
+ DUE:19920516T045959Z
7
+ PRIORITY:1
8
+ SUMMARY:Yearly Income Tax Preparation
9
+ UID:19920901T130000Z-123408@host.com
10
+ END:VTODO
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ BEGIN:VEVENT
2
+ SUMMARY:Work
3
+ DTSTART;TZID=Europe/Berlin:20240819T090000
4
+ DTEND;TZID=Europe/Berlin:20240819T170000
5
+ DTSTAMP:20240823T082915Z
6
+ UID:6b85b60c-eb1a-4338-9ece-33541b95bf17
7
+ SEQUENCE:1
8
+ CREATED:20240823T082829Z
9
+ LAST-MODIFIED:20240823T082915Z
10
+ TRANSP:OPAQUE
11
+ X-MOZ-GENERATION:2
12
+ END:VEVENT
@@ -1,3 +1,18 @@
1
+ # ics-query
2
+ # Copyright (C) 2024 Nicco Kunzmann
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
1
16
  """Test the commmand line."""
2
17
 
3
18
  from ics_query.version import version
@@ -9,6 +24,7 @@ def test_check_program_output(io_testcase: IOTestCase):
9
24
  """Run the test case and check the output."""
10
25
  result = io_testcase.run()
11
26
  print(result.error)
27
+ assert result.exit_code == 0, "The process must not exist with an error."
12
28
  assert result.output == io_testcase.expected_output
13
29
 
14
30
 
@@ -17,3 +33,21 @@ def test_version(run):
17
33
  result = run("--version")
18
34
  assert result.exit_code == 0
19
35
  assert version in result.output
36
+
37
+
38
+ def test_license(run):
39
+ """Check the version is displayed."""
40
+ result = run("--license")
41
+ assert result.exit_code == 0
42
+ assert "Copyright (C) 2024 Nicco Kunzmann" in result.output
43
+ assert "GNU General Public License" in result.output
44
+
45
+
46
+ def test_timezones(run):
47
+ """Check the available timezones."""
48
+ result = run("--available-timezones")
49
+ tz = result.output.split()
50
+ assert result.exit_code == 0
51
+ assert tz.index("Zulu") > tz.index("Pacific/Nauru")
52
+ assert tz.index("Pacific/Nauru") > tz.index("UTC")
53
+ assert tz.index("UTC") > tz.index("localtime")
@@ -1,8 +1,23 @@
1
+ # ics-query
2
+ # Copyright (C) 2024 Nicco Kunzmann
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
1
16
  """This tests parsing input times and dates."""
2
17
 
3
18
  import pytest
4
19
 
5
- from ics_query.parse import InvalidTimeFormat, to_time
20
+ from ics_query.parse import InvalidTimeFormat, to_time, to_time_and_delta
6
21
 
7
22
 
8
23
  @pytest.mark.parametrize(
@@ -43,9 +58,10 @@ from ics_query.parse import InvalidTimeFormat, to_time
43
58
  ("20141010183012", (2014, 10, 10, 18, 30, 12)),
44
59
  ],
45
60
  )
46
- def test_parse_to_date_argument(string_argument, expected_result):
61
+ @pytest.mark.parametrize("parser", [to_time_and_delta, to_time])
62
+ def test_parse_to_date_argument(string_argument, expected_result, parser):
47
63
  """Check that we can properly parse what is accepted."""
48
- result = to_time(string_argument)
64
+ result = parser(string_argument)
49
65
  assert result == expected_result
50
66
 
51
67
 
@@ -53,11 +69,13 @@ def test_parse_to_date_argument(string_argument, expected_result):
53
69
  "dt",
54
70
  [
55
71
  "",
72
+ " ",
56
73
  "132",
57
74
  "12345",
58
75
  ],
59
76
  )
60
- def test_invalid_time_format(dt: str):
77
+ @pytest.mark.parametrize("parser", [to_time_and_delta, to_time])
78
+ def test_invalid_time_format(dt: str, parser):
61
79
  """Check invalid time formats."""
62
80
  with pytest.raises(InvalidTimeFormat):
63
- to_time(dt)
81
+ parser(dt)
@@ -0,0 +1,40 @@
1
+ # ics-query
2
+ # Copyright (C) 2024 Nicco Kunzmann
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ """This tests parsing input times and dates."""
17
+
18
+ from datetime import timedelta
19
+
20
+ import pytest
21
+
22
+ from ics_query.parse import to_time_and_delta
23
+
24
+
25
+ @pytest.mark.parametrize(
26
+ ("string_argument", "expected_result"),
27
+ [
28
+ ("10d", timedelta(days=10)),
29
+ ("10d10h", timedelta(days=10, hours=10)),
30
+ ("1d2h12m33s", timedelta(days=1, hours=2, minutes=12, seconds=33)),
31
+ ("3600s", timedelta(seconds=3600)),
32
+ ("10m", timedelta(minutes=10)),
33
+ ("23h", timedelta(hours=23)),
34
+ ],
35
+ )
36
+ @pytest.mark.parametrize("plus", ["", "+"])
37
+ def test_parse_to_date_argument(string_argument, expected_result, plus):
38
+ """Check that we can properly parse what is accepted."""
39
+ result = to_time_and_delta(plus + string_argument)
40
+ assert result == expected_result
ics_query/version.py CHANGED
@@ -1,16 +1,46 @@
1
- # SPDX-FileCopyrightText: 2024 Nicco Kunzmann and Open Web Calendar Contributors <https://open-web-calendar.quelltext.eu/>
1
+ # ics-query
2
+ # Copyright (C) 2024 Nicco Kunzmann
2
3
  #
3
- # SPDX-License-Identifier: GPL-2.0-only
4
-
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
5
16
  try:
6
17
  from ._version import __version__, __version_tuple__, version, version_tuple
7
18
  except ModuleNotFoundError:
8
19
  __version__ = version = "0.0dev0"
9
20
  __version_tuple__ = version_tuple = (0, 0, "dev0")
21
+ from importlib.metadata import version as get_version
22
+
23
+ cli_version = f"""{__version__}
24
+
25
+ Components:
26
+ """
27
+ modules = [
28
+ "recurring-ical-events",
29
+ "icalendar",
30
+ "pytz",
31
+ "python-dateutil",
32
+ "click",
33
+ "tzdata",
34
+ "x-wr-timezone",
35
+ ]
36
+ modules.sort()
37
+ for module in modules:
38
+ cli_version += f"{module}: {get_version(module)}\n"
10
39
 
11
40
  __all__ = [
12
41
  "__version__",
13
42
  "version",
14
43
  "__version_tuple__",
15
44
  "version_tuple",
45
+ "cli_version",
16
46
  ]