A Python library to merge iCalendar feeds.
Project description
Python MergeCal
Documentation: https://mergecal.readthedocs.io
Source Code: https://github.com/mergecal/python-mergecal
A Python library to merge iCalendar feeds.
Installation
Install this via pip (or your favorite package manager):
pip install mergecal
Usage
Python API
You can use MergeCal in your Python code as follows:
>>> from mergecal import merge_calendars
>>> from icalendar import Calendar
# Load your calendars
# CALENDARS = pathlib.Path("to/your/calendar/directory")
>>> calendar1 = Calendar.from_ical((CALENDARS / "one_event.ics").read_bytes())
>>> calendar2 = Calendar.from_ical((CALENDARS / "another_event.ics").read_bytes())
# Merge the calendars
>>> merged_calendar : Calendar = merge_calendars([calendar1, calendar2])
# Write the merged calendar to a file
>>> with (CALENDARS / "merged_calendar.ics").open("wb") as f:
... f.write(merged_calendar.to_ical())
559
# The merged calendar will contain all the events of both calendars
>>> [str(event["SUMMARY"]) for event in calendar1.walk("VEVENT")]
['Event 1']
>>> [str(event["SUMMARY"]) for event in calendar2.walk("VEVENT")]
['Event 2']
>>> [str(event["SUMMARY"]) for event in merged_calendar.walk("VEVENT")]
['Event 1', 'Event 2']
Command Line Interface (CLI)
MergeCal also provides a command-line interface for easy merging of calendar files:
# Basic usage
mergecal calendar1.ics calendar2.ics -o merged_calendar.ics
# Specifying custom PRODID
mergecal calendar1.ics calendar2.ics -o merged_calendar.ics --prodid "-//My Organization//MergeCal 1.0//EN"
For more options and information, use the help command:
mergecal --help
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Copier and the browniebroke/pypackage-template project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mergecal-0.3.2.tar.gz
.
File metadata
- Download URL: mergecal-0.3.2.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a789c729e68ce4ed3e920c6322a73e607f1c722c5c4015515fd94eef460a0d3 |
|
MD5 | bdac895e99259647080f482bc5f1f6dc |
|
BLAKE2b-256 | c5a441d724a2abeb4e55252e852169a575cb71e4ededf5af435cc9b14197f14d |
File details
Details for the file mergecal-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: mergecal-0.3.2-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f898692e3fb813adb315e90de102e3f6343b76322441a82def993a6c1e20c137 |
|
MD5 | 79a05fe8395dc399ef6d1036808c3cbb |
|
BLAKE2b-256 | 48678a38f96ca4272592ba1a398241005f580a6b187441e6eb884a26496fa902 |