pimutils / pimutils/khal

Missing fields in json formatter

Open
#1,323 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.1k
Forks
233
Avg merge
1h 44m
Merged PRs (30d)
1

Description

Describe the bug
As of now some available fields can't be displayed when using --json flag, e.g "attendees"

To Reproduce

khal list --json attendees today today
[{}, {}] # List will vary depending on your calendars

Expected behavior

I should obtain a json-formatted list of list of attendees like:

khal list --json attendees today today
[{"attendees": ""}, {"attendees": "attendee1, attendee2"}]

OS, version, khal version and how you installed it:

  • The output of khal --version: khal, version 0.11.3.dev160+g214886d
  • Installation method [e.g. PyPI, git, OS repo]: pip install git+https://github.com/pimutils/khal
  • python version: 3.12
  • OS: Darwin Kernel Version 22.5.0
  • Your khal config file
[default]
default_calendar = <redacted>
highlight_event_days = True

[view]
event_view_always_visible = True
  • The versions of your other python packages
$ pip freeze
pip freeze
atomicwrites==1.4.1
click==8.1.7
click-log==0.4.0
configobj==5.0.8
icalendar==5.0.10
khal @ git+https://github.com/pimutils/khal@214886de48bf706f897592cd01a9de6250ba3df4
python-dateutil==2.8.2
pytz==2023.3.post1
pyxdg==0.28
six==1.16.0
tzlocal==5.2
urwid==2.2.3

Additional context
The additionnal attributes are available but are ignored because of the CONTENT_ATTRIBUTES var at https://github.com/pimutils/khal/blob/master/khal/utils.py#L218

For my needs I manually patched like so:

diff --git a/khal/utils.py b/khal/utils.py
index 78f525b..41d40c9 100644
--- a/khal/utils.py
+++ b/khal/utils.py
@@ -223,7 +223,7 @@ CONTENT_ATTRIBUTES = ['start', 'start-long', 'start-date', 'start-date-long',
                       'start-style', 'end-style', 'to-style', 'start-end-time-style',
                       'end-necessary', 'end-necessary-long', 'repeat-symbol', 'repeat-pattern',
                       'title', 'organizer', 'description', 'location', 'all-day', 'categories',
-                      'uid', 'url', 'calendar', 'calendar-color', 'status', 'cancelled']
+                      'uid', 'url', 'calendar', 'calendar-color', 'status', 'cancelled', 'attendees']


 def json_formatter(fields)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in khal/utils.py at CONTENT_ATTRIBUTES and json_formatter, then run the reported khal list --json attendees today today command to confirm the missing field. Done means the JSON output includes attendees for events with and without attendees, while preserving the existing output for other fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.