Skip to content

Commit 1464735

Browse files
tupuirkdarststefanv
authored
Package library (#19)
* Add documentation: README and better test calendar. * example/test_calendar: Add an example of YAML anchors for templates - YAML provides & to label a node, and ways to refer to it. This allows you to make one template event, and copy it many times changing only one property (such as the begin time. - This adds an example of this into example/test_calendar.yaml * Packaging using flit * ics into requirements and update GH action with cache and flit * Add release action * Update readme with package info and dev workflow * Add warning and 0.1rc1 * BSD licensing * Update .gitignore * Apply suggestions from code review Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com> * Better PyPi with token instead of personal password * Remove unnecessary information * Use plain pip to install dev env Co-authored-by: Richard Darst <rkd@zgib.net> Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com>
1 parent eb1300b commit 1464735

11 files changed

Lines changed: 242 additions & 24 deletions

File tree

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup Python 3.10
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: '3.10'
18+
architecture: 'x64'
19+
20+
- name: Install flit
21+
run: pip install flit
22+
23+
- name: Build
24+
run: flit build
25+
26+
- name: Publish to PyPI
27+
env:
28+
FLIT_USERNAME: __token__
29+
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }}
30+
run: |
31+
flit publish
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@ jobs:
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919

20+
- uses: actions/cache@v2
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
26+
2027
- name: Install dependencies
2128
run: |
2229
python -m pip install --upgrade pip
23-
pip install flake8 pytest
24-
pip install -r requirements.txt -r requirements.dev.txt
30+
pip install -r requirements.txt
31+
pip install flit
32+
flit install
2533
2634
- name: Lint
2735
run: pre-commit run --all-files --show-diff-on-failure --color always
2836

2937
- name: Test
3038
run: |
31-
PYTHONPATH=. pytest
39+
pytest

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
*~
22
**/__pycache__
3+
### Python template
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
8+
# Distribution / packaging
9+
dist/
10+
11+
# Unit test / coverage reports
12+
.pytest_cache/
13+
14+
# General
15+
.DS_Store
16+
17+
# IntelliJ project files
18+
.idea
19+
20+
# Environments
21+
.env
22+
.venv
23+
env/
24+
venv/
25+
ENV/
26+
env.bak/
27+
venv.bak/
28+
29+
# Spyder project settings
30+
.spyderproject
31+
.spyproject

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2021--2022, Scientific Python project
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

LICENSE.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1+
![PyPI](https://img.shields.io/pypi/v/yaml2ics?style=for-the-badge)
2+
13
# YAML to iCalendar (ics)
24

3-
Please see `example/test_calendar.yaml` for example entries.
5+
| WARNING: this project is still in beta. Beware of breaking changes! |
6+
|---------------------------------------------------------------------|
7+
8+
Convert YAML files to .ics files which can be imported into other
9+
calendar applications.
10+
11+
Features include:
12+
- Converting single .yaml files, or combining multiple into one .ics
13+
file.
14+
- ics fields: name, summary, description, location, timezone, repeat
15+
- Specify event start+end or start+duration
16+
- Recurring events (basic support)
17+
- All-day events
18+
- Timezone specification (default or per-event)
19+
20+
## Installation
21+
22+
```
23+
pip install yaml2ics
24+
```
25+
26+
**Note:** due to a pending release of a dependency (`ics-py`), an additional
27+
step is required:
28+
29+
```
30+
pip install -r requirements.txt
31+
```
32+
33+
## Usage
434

535
To produce a calendar from a list of events:
636

@@ -14,8 +44,49 @@ To combine lists of events in to a calendar:
1444
python yaml2ics.py example/test_calendar.yaml example/another_calendar.yaml
1545
```
1646

47+
## Syntax
48+
49+
Please see `example/test_calendar.yaml` for a full demo including
50+
explanations. Below is a minimal template that shows the basic idea:
51+
52+
```yaml
53+
name: Calendar Name
54+
timezone: Europe/Helsinki # default timezone for events, optional
55+
56+
events:
57+
- summary: The event title
58+
begin: 2021-09-21 15:00:00
59+
duration:
60+
minutes: 30
61+
location: |
62+
https://meet.jit.si/example
63+
description: |
64+
In this meeting we will ...
65+
```
66+
67+
## Contributing
68+
69+
Contributions are welcomed! This project is still in active development
70+
and should be considered beta.
71+
72+
To install the development version, fork the source of the project and make an
73+
editable install:
74+
75+
```
76+
pip install -r requirements.txt # temporary workaround for ics-py
77+
pip install -e ".[test]"
78+
```
79+
1780
To test:
1881

1982
```
20-
PYTHONPATH=. pytest
83+
pytest
2184
```
85+
86+
[black](https://github.com/psf/black) and other linters are used to auto-format
87+
files (and enforced by CI). To install the git hooks, use `pre-commit install`.
88+
To run the tests/auto-formatting manually, use `pre-commit run
89+
--all-files`.
90+
91+
Releases are automatically pushed on PyPi by the CI when pushing a tag
92+
following `*.*`.

example/test_calendar.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
name: Test Calendar
22
timezone: America/Los_Angeles
3+
# # Include another list of events in with these. Note you can also do
4+
# # this from the command line.
5+
# include:
6+
# - other_calender.ics
37

48
events:
59
- summary: Event of the Century
6-
begin: 2021-09-21 15:00:00
7-
end: 2021-09-21 15:30:00
8-
description: |
9-
Meet the team on the northern side of the field.
10-
11-
- summary: Half-an-hour meeting
12-
begin: 2021-09-23 15:00:00 -07:00
10+
begin: 2021-09-21 15:00:00 # uses default timezone above
1311
duration:
1412
minutes: 30
13+
description: |
14+
Meet the team on the northern side of the field.
1515
location: |
1616
Office 224, Monolith Bldg, Office Block C
1717
18+
- summary: Half-an-hour meeting
19+
begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset
20+
end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset
21+
22+
- summary: Recurring event
23+
begin: 2022-02-21 15:00:00
24+
duration: {minutes: 60}
25+
repeat:
26+
interval:
27+
# seconds, minutes, hours, days, weeks, months, years
28+
weeks: 1
29+
until: 2022-12-31 # required
30+
31+
# All-day event
1832
- summary: Earth Day
1933
begin: 2021-04-22
2034
url: https://earthday.org

pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = ["flit_core >=3.3,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "yaml2ics"
7+
version = "0.1rc1"
8+
requires-python = ">=3.8"
9+
authors = [{name = "The Scientific Python Group"}]
10+
readme = "README.md"
11+
license = {file = "LICENSE"}
12+
classifiers = ["License :: OSI Approved :: BSD License"]
13+
dynamic = ["description"]
14+
15+
dependencies = [
16+
# "ics >=0.8",
17+
"python-dateutil",
18+
"pyyaml",
19+
]
20+
21+
[project.optional-dependencies]
22+
test = [
23+
"pytest",
24+
"black",
25+
"pre-commit",
26+
"flake8"
27+
]
28+
29+
[project.scripts]
30+
yaml2ics = "yaml2ics:main"
31+
32+
[project.urls]
33+
Home = "https://github.com/scientific-python/yaml2ics"
34+
Source = "https://github.com/scientific-python/yaml2ics"
35+
36+
[tool.flit.sdist]
37+
exclude = ["tests/*"]

requirements.dev.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
https://github.com/ics-py/ics-py/archive/refs/heads/main.zip
2-
python-dateutil
3-
pyyaml

0 commit comments

Comments
 (0)