Skip to main content

A Python library to merge iCalendar feeds.

Project description

Python MergeCal

CI Status Documentation Status Test coverage percentage

Poetry Ruff pre-commit

PyPI Version Supported Python versions License


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mergecal-0.3.9.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

mergecal-0.3.9-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file mergecal-0.3.9.tar.gz.

File metadata

  • Download URL: mergecal-0.3.9.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mergecal-0.3.9.tar.gz
Algorithm Hash digest
SHA256 6180af0a5e7f2db61785407aa93144b20759837bfe532dad7c9490d8e7eb9214
MD5 d3c783ed8d01d3e52e49b2358a218b19
BLAKE2b-256 31a5a4a6f646eebd1e995fe0cea4ddd73624ff06874a97eab5240a28429ff6a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mergecal-0.3.9.tar.gz:

Publisher: ci.yml on mergecal/python-mergecal

Attestations:

File details

Details for the file mergecal-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: mergecal-0.3.9-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.7

File hashes

Hashes for mergecal-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2af14d8d17fead16e646f2f83a6f01adbe5d82e2a08aa097358252888fbe86ad
MD5 7ffcd9bbb303d39b48a42a8c90dca0dd
BLAKE2b-256 1128b1c50453a763b57d3f9251e9e7684d92076ec307bcf367affc9ff51ff643

See more details on using hashes here.

Provenance

The following attestation bundles were made for mergecal-0.3.9-py3-none-any.whl:

Publisher: ci.yml on mergecal/python-mergecal

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page