Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ and I do try to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.h
### Changed

* Shell tab completion scripts (bash, zsh, fish) now ship with the package. They work without shell configuration for system-wide installs (and for bash user/venv installs with bash-completion 2.12+); see the README for other setups. The `make install-completion` targets are gone.
* icalendar 6.2.0 or newer is required.

### Fixed

* `interactive set-task-attribs` (also run by `interactive manage-tasks`): a task marked `completed!` at one prompt was asked about again at the next one, and answering `completed!` there crashed on the already-completed task. Regression in v1.2.0.
* `list-categories` and timewarrior time tracking crashed on a task with more than one CATEGORIES line. https://github.com/pycalendar/plann/issues/71

## v1.2.0 - 2026-09-16

Expand Down
4 changes: 1 addition & 3 deletions plann/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ def __select(ctx, extend_objects=False, all=None, uid=[], abort_on_missing_uid=N
def _categories_in_use(objs):
categories = set()
for obj in objs:
cats = obj.icalendar_component.get('categories')
if cats:
categories.update(cats.cats)
categories.update(str(x) for x in obj.icalendar_component.categories if x)
return categories

def _cats(ctx):
Expand Down
4 changes: 2 additions & 2 deletions plann/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def add_time_tracking_timew(obj, start=None, end=None):
comp = _icalendar_component(obj)
tags = ['plann-export']

if 'categories' in comp:
for cat in comp['categories'].cats:
for cat in comp.categories:
if cat:
tags.append(f'category:{cat}')
tags.append(f'uid:{comp["uid"]}')
tags.append(f'summary:{_summary(obj)}')
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"sortedcontainers",
"dateparser>=1.2",
"python-dateutil",
"icalendar",
"icalendar>=6.2.0",
"icalendar_searcher",
]

Expand Down
19 changes: 19 additions & 0 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,22 @@ def test_procrastinate_has_no_breakpoint():
source = _inspect.getsource(_procrastinate)
assert 'breakpoint()' not in source
assert 'inspect.stack()' not in source


## RFC 5545 allows CATEGORIES more than once; icalendar then returns a list.
## https://github.com/pycalendar/plann/issues/71
todo_multicats = todo.replace('STATUS:NEEDS-ACTION\n', 'STATUS:NEEDS-ACTION\nCATEGORIES:\nCATEGORIES:foo\nCATEGORIES:bar,baz\n')

def test_categories_in_use_multiple_lines():
from plann.commands import _categories_in_use
obj = Todo(data=todo_multicats)
assert _categories_in_use([obj]) == {'foo', 'bar', 'baz'}

@patch("plann.lib.subprocess.run")
def test_add_time_tracking_timew_multiple_category_lines(mock_run):
obj = Todo(data=todo_multicats)
obj.parent = Calendar()
obj.parent.extra_config = {'time_tracking': ['timewarrior']}
add_time_tracking_timew(obj, datetime(2020, 2, 20, 20, 2), datetime(2020, 2, 20, 20, 20))
cmd_arr = mock_run.mock_calls[0].args[0]
assert [x for x in cmd_arr if x.startswith('category:')] == ['category:foo', 'category:bar', 'category:baz']
Loading