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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Provide an ical CLI script #226

Open
tomschr opened this issue Feb 8, 2020 · 5 comments
Open

Idea: Provide an ical CLI script #226

tomschr opened this issue Feb 8, 2020 · 5 comments

Comments

@tomschr
Copy link
Contributor

tomschr commented Feb 8, 2020

Situation

Actually I'm not sure if this is really something which could be addressed in this project. Maybe there are already other tools which does that. So it's just an crazy idea. 馃槈

From a user perspective, it could be convenient, to have a script (name it ical if you wish) which could print, search, or query all events.

I think, it might still be useful as the ical script uses this library; the user can see, if the ics file can be successfully parsed and all events are correctly recognized. Could also help developers as they don't have to start an interactive Python session or write a separate script to parse their calendar files.

Proposed Solution

If you think, this is an interesting idea, the ical script could support several subcommands:

  • ical validate ICALFILE: validates the ical file or show all the errors.
  • ical view ICALFILE: pretty-prints the ical file
  • ical merge ICALFILE1 ICALFILE2: combines two ical files into one
  • ical search CONDITION ICALFILE: searches for a event and expects a condition (for example, list all events which are between January and February).
  • and probably much more. 馃槈
@N-Coder
Copy link
Member

N-Coder commented Mar 15, 2020

Some further possible ideas

  • filtering events based on their attributes, e.g. their category
  • adding / updating / removing attributes, e.g. setting the category or dropping all private information
  • converting between Free/Busy information and detailed Events
  • dropping duplicate Events
  • convert the data between ics representation, a JSON dump of our own objects, and the JSON or XML-based jCal and xCal

The conversion between different formats can also be helpful for testing that we actually correctly parse data (e.g. in unit tests comparing the actual conversion result with some pre-defined / hand-made / externally-converted expectation).
For the validation part, I guess we wanted to have different levels of strictness in the library for quite some time (see e.g. #56 and #195 / 363159b).
Once we have support for that, validation should just be parsing the file with the highest strictness level, while for normal day-to-day usage the library is less strict and helps users handling weird files by instead filling in sensible defaults whenever possible.

If you want to see all these operations / subcommands in a very generic way, this kind of gives you a directed acyclic graph of operations to be applied on one or multiple streams of events / todos / availability slots. But that might be over-engineering. 馃槈

To get to something more practical; in addition to running the operations once as a command line script, one could use a website to do these automatically. This way, you can generate a simple link that points to an always up-to-date ics calendar generated based on the operations you configured. This is the use-case I'm currently following, as I eventually want to be able to merge all my different calendars into a single link, that has categories applied depending on the source of an event. Then, instead of setting up each calendar on all of my devices, I just need to add this single file. Moreover, I can derive a further calendar from this merged one, that publicly shows my availability without publishing any private information.
But that's probably for some separate project building on ics.py, once I'm done with my changes here.

@ifuchs
Copy link

ifuchs commented Apr 26, 2021

Can anyone provide a sample script which can search an ics for an event that contains a given string in the title or an event on a specific date?

@N-Coder
Copy link
Member

N-Coder commented Apr 26, 2021

for event in calendar.events:
    if "Party" in event.name:
        print("馃帀", event)

The answer to your second question is in the API docs: Timeline.on

PS: using a discussion would be a better place for such "how do I" questions than hijacking a semi-related issue.

@tomschr
Copy link
Contributor Author

tomschr commented Apr 27, 2021

Some further possible ideas [...]

Niko, that's a great list! 馃憤 I'm sure we will find other helpful use cases.

To sort with, maybe we could group them into essential and advanced commands? Just to make the implementation easier. With additional PRs we could enhance this functionality.

Would that work? 馃檪

@perette
Copy link
Contributor

perette commented Oct 1, 2022

This isn't quite everything you want, but queue2ics.py (man page) in DCloud. It'll convert ICS files to "queue" format, which is human readable (especially if combined with now, a shell script, a change which wouldn't be too hard). It'll combine ICS files (example: queue2ics -s work.ics -s personal.ics -o combined.ics). It can output a calendar to HTML. The begin and end flags (-b and -e) can select date ranges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants