Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vCategory iterable #610

Closed
niccokunzmann opened this issue Apr 7, 2024 · 3 comments
Closed

Make vCategory iterable #610

niccokunzmann opened this issue Apr 7, 2024 · 3 comments
Labels
feature good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/

Comments

@niccokunzmann
Copy link
Member

vCategory is used to list different categories of events. It would be nice to have an easy use of that.

from icalendar.prop import vCategory
c = vCategory.from_ical("APPOINTMENT,EDUCATION")
cats = list(c) # new feature
assert cats == ["APPOINTMENT", "EDUCATION"]
@niccokunzmann niccokunzmann added feature good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/ labels Apr 7, 2024
@devdanzin
Copy link
Contributor

This seems like a good feature, but is the code example correct? Because from:

def test_prop_vCategory(self):
from icalendar.prop import vCategory
catz = ['cat 1', 'cat 2', 'cat 3']
v_cat = vCategory(catz)
self.assertEqual(v_cat.to_ical(), b'cat 1,cat 2,cat 3')
self.assertEqual(vCategory.from_ical(v_cat.to_ical()), catz)

It seems vCategory.from_ical doesn't return an instance of vCategory, but a list.

So should we work from:

from icalendar.prop import vCategory
c = vCategory(vCategory.from_ical("APPOINTMENT,EDUCATION"))
cats = list(c) # new feature
assert cats == ["APPOINTMENT", "EDUCATION"]

instead?

@niccokunzmann
Copy link
Member Author

niccokunzmann commented Jun 29, 2024 via email

@niccokunzmann
Copy link
Member Author

Fixed in #670.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

No branches or pull requests

2 participants