Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
# for error classes selected below.

[flake8]
max-line-length = 80
max-line-length = 88
select = C,E,F,W,B,B950
ignore = E501, W503
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- '*.*'
- "*.*"

jobs:
release:
Expand All @@ -14,8 +14,8 @@ jobs:
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
python-version: "3.10"
architecture: "x64"

- name: Install flit
run: pip install flit
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
flit install
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
flit install

- name: Lint
run: pre-commit run --all-files --show-diff-on-failure --color always
- name: Lint
run: pre-commit run --all-files --show-diff-on-failure --color always

- name: Test
run: |
pytest
- name: Test
run: |
pytest
33 changes: 28 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,44 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: check-ast
- id: mixed-line-ending
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-json
- id: check-toml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
pass_filenames: true

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
files: \.(html|md|yml|yaml)
args: [--prose-wrap=preserve]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# YAML to iCalendar (ics)

| WARNING: this project is still in beta. Beware of breaking changes! |
|---------------------------------------------------------------------|
| ------------------------------------------------------------------- |

Convert YAML files to .ics files which can be imported into other
calendar applications.

Features include:

- Converting single .yaml files, or combining multiple into one .ics
file.
- ics fields: name, summary, description, location, timezone, repeat
Expand Down Expand Up @@ -47,11 +48,11 @@ python yaml2ics.py example/test_calendar.yaml example/another_calendar.yaml
## Syntax

Please see `example/test_calendar.yaml` for a full demo including
explanations. Below is a minimal template that shows the basic idea:
explanations. Below is a minimal template that shows the basic idea:

```yaml
name: Calendar Name
timezone: Europe/Helsinki # default timezone for events, optional
timezone: Europe/Helsinki # default timezone for events, optional

events:
- summary: The event title
Expand Down Expand Up @@ -84,8 +85,7 @@ pytest

[black](https://github.com/psf/black) and other linters are used to auto-format
files (and enforced by CI). To install the git hooks, use `pre-commit install`.
To run the tests/auto-formatting manually, use `pre-commit run
--all-files`.
To run the tests/auto-formatting manually, use `pre-commit run --all-files`.

Releases are automatically pushed on PyPi by the CI when pushing a tag
following `*.*`.
12 changes: 6 additions & 6 deletions example/test_calendar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ timezone: America/Los_Angeles

events:
- summary: Event of the Century
begin: 2021-09-21 15:00:00 # uses default timezone above
begin: 2021-09-21 15:00:00 # uses default timezone above
duration:
minutes: 30
description: |
Expand All @@ -16,22 +16,22 @@ events:
Office 224, Monolith Bldg, Office Block C

- summary: 15-minute meeting with timezone
timezone: America/New_York # symbolic timezone offset
timezone: America/New_York # symbolic timezone offset
begin: 2021-09-23 15:00:00
end: 2021-09-23 15:30:00

- summary: Half-an-hour meeting
begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset
end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset
begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset
end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset

- summary: Recurring event
begin: 2022-02-21 15:00:00
duration: {minutes: 60}
duration: { minutes: 60 }
repeat:
interval:
# seconds, minutes, hours, days, weeks, months, years
weeks: 1
until: 2022-12-31 # required
until: 2022-12-31 # required

# All-day event
- summary: Earth Day
Expand Down
2 changes: 1 addition & 1 deletion yaml2ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def files_to_events(files: list) -> (ics.Calendar, str):
if hasattr(f, "read"):
calendar_yaml = yaml.load(f.read(), Loader=yaml.FullLoader)
else:
calendar_yaml = yaml.load(open(f, "r"), Loader=yaml.FullLoader)
calendar_yaml = yaml.load(open(f), Loader=yaml.FullLoader)
tz = calendar_yaml.get("timezone", None)
if tz is not None:
tz = gettz(tz)
Expand Down