Skip to content

Commit c522b2b

Browse files
committed
Fixes #2 and #3
1 parent a244582 commit c522b2b

File tree

9 files changed

+184
-41
lines changed

9 files changed

+184
-41
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
1+
# This workflow will install Python dependencies, run tests and lint
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

44
name: Testing
55

66
on:
77
push:
8-
branches: [ "master" ]
8+
branches: [ "develop" ]
99
pull_request:
10-
branches: [ "master" ]
10+
branches: [ "develop" ]
1111

1212
permissions:
1313
contents: read
@@ -22,14 +22,15 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v4
25+
- name: Install Poetry
26+
run: pipx install poetry
2527
- name: Set up Python ${{ matrix.python-version }}
2628
uses: actions/setup-python@v5
2729
with:
2830
python-version: ${{ matrix.python-version }}
2931
- name: Install dependencies
3032
run: |
31-
python -m pip install --upgrade pip
32-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
33+
poetry install
3334
- name: Install the code linting and formatting tool Ruff
3435
run: |
3536
pipx install ruff
@@ -38,5 +39,5 @@ jobs:
3839
ruff check --output-format=github .
3940
- name: Test with example.csv
4041
run: |
41-
python csv2ical.py sample.csv test.ics
42+
csv2ical sample.csv test.ics
4243
diff sample.ics test.ics

README.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@
33
[![Testing badge](https://github.com/rlan/csv2ical/actions/workflows/tests.yml/badge.svg)](https://github.com/rlan/csv2ical/actions/workflows/tests.yml)
44
![Python versions](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
55
![MIT license](https://img.shields.io/github/license/rlan/csv2ical)
6+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15024834.svg)](https://doi.org/10.5281/zenodo.15024834)
7+
8+
A CLI tool that converts a CSV file with event details into an iCalendar [ICS](https://docs.fileformat.com/email/ics/) file. The ICS file can then be imported into apps like Google Calendar, Microsoft Outlook, Apple macOS Calendar and etc.
69

7-
Convert a CSV file with event details into an iCalendar ([ICS](https://docs.fileformat.com/email/ics/)) file. The ICS file can then be imported into apps like Google Calendar, Outlook, or macOS Calendar.
810

911
Installation:
1012

1113
```sh
12-
pip install -r requirements.txt
14+
pipx install git+https://github.com/rlan/csv2ical
1315
```
1416

15-
Example:
1617

17-
[`sample.csv`](sample.csv):
18+
Update, if already installed:
1819

19-
```csv
20-
"Subject","Start Date","Start Time","End Date","End Time","Description","Location"
21-
"Harry Potter birthday","1980-07-31","00:00","1980-08-01","00:00","The Chosen One","Godric's Hollow"
22-
"Ron Weasley birthday","1980-03-01","00:00","1980-03-02","00:00","Won-Won","Ottery St Catchpole"
23-
"Hermione Granger birthday","1979-09-19","00:00","1979-09-20","00:00","'Mione",""
20+
```sh
21+
pipx upgrade csv2ical
2422
```
2523

26-
An all-day event starts at midnight and ends at the midnight of the next day. Although `sample.csv` contains only all-day events, e.g. birthdays, any shorter events, e.g. meetings, would also work.
2724

28-
The names in the CSV header row is documentation. It tells the author of the CSV file which column to write the event details. Editing that row has no effect on the output ICS file, but **do not** omit it.
25+
Uninstall:
26+
27+
```sh
28+
pipx uninstall csv2ical
29+
```
30+
2931

3032
Usage:
3133

3234
```sh
33-
python csv2ical.py --help
35+
csv2ical --help
3436
```
3537

3638
```txt
37-
usage: csv2ical.py [-h] input output
39+
usage: csv2ical [-h] input output
3840
3941
positional arguments:
4042
input Input csv file containing calendar events
@@ -44,10 +46,27 @@ optional arguments:
4446
-h, --help show this help message and exit
4547
```
4648

49+
50+
Example:
51+
52+
[`sample.csv`](sample.csv):
53+
54+
```csv
55+
"Subject","Start Date","Start Time","End Date","End Time","Description","Location"
56+
"Harry Potter birthday","1980-07-31","00:00","1980-08-01","00:00","The Chosen One","Godric's Hollow"
57+
"Ron Weasley birthday","1980-03-01","00:00","1980-03-02","00:00","Won-Won","Ottery St Catchpole"
58+
"Hermione Granger birthday","1979-09-19","00:00","1979-09-20","00:00","'Mione",""
59+
```
60+
61+
An all-day event starts at midnight and ends at the midnight of the next day. Although `sample.csv` contains only all-day events, e.g. birthdays, any shorter events, e.g. meetings, would also work.
62+
63+
The names in the CSV header row is documentation. It tells the author of the CSV file which column to write the event details. Editing that row has no effect on the output ICS file, but **do not** omit it.
64+
65+
4766
Reproduce [`sample.ics`](sample.ics):
4867

4968
```sh
50-
python csv2ical.py sample.csv sample.ics
69+
csv2ical sample.csv sample.ics
5170
```
5271

5372
```sh

poetry.lock

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[project]
2+
name = "csv2ical"
3+
description = "A CLI tool that converts a CSV file with event details into an iCalendar ICS file. The ICS file can then be imported into apps like Google Calendar, Outlook, macOS Calendar and etc."
4+
authors = [{ name = "Rick Lan", email = "rlan@users.noreply.github.com" }]
5+
license = { text = "MIT" }
6+
readme = "README.md"
7+
packages = [{include = "csv2ical", from = "src"}]
8+
requires-python = ">=3.7"
9+
dependencies = [
10+
"icalendar>=4.0.1",
11+
]
12+
dynamic = [ "version" ]
13+
14+
[project.scripts]
15+
csv2ical = "csv2ical.cli:main"
16+
17+
[project.urls]
18+
homepage = "https://github.com/rlan/csv2ical"
19+
repository = "https://github.com/rlan/csv2ical"
20+
documentation = "https://github.com/rlan/csv2ical"
21+
"Bug Tracker" = "https://github.com/rlan/csv2ical/issues"
22+
23+
[tool.poetry]
24+
version = "1.0.0"
25+
26+
[build-system]
27+
requires = ["poetry-core>=1.0.0"]
28+
build-backend = "poetry.core.masonry.api"
29+
30+
[tool.ruff.lint]
31+
# 1. Enable flake8-bugbear (`B`) rules, in addition to the defaults.
32+
select = ["E4", "E7", "E9", "F", "B"]
33+
34+
# 2. Avoid enforcing line-length violations (`E501`)
35+
ignore = ["E501"]
36+
37+
# 3. Avoid trying to fix flake8-bugbear (`B`) violations.
38+
unfixable = ["B"]
39+
40+
# 4. Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories.
41+
[tool.ruff.lint.per-file-ignores]
42+
"__init__.py" = ["E402"]
43+
"**/{tests,docs,tools}/*" = ["E402"]
44+
45+
[tool.ruff.format]
46+
docstring-code-format = true

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

ruff.toml

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

src/csv2ical/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .__version__ import __version__ # noqa

src/csv2ical/__version__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0"

csv2ical.py renamed to src/csv2ical/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
import sys
34
import csv
45
from icalendar import Calendar, Event
56
from datetime import datetime
@@ -9,7 +10,7 @@
910
parser = argparse.ArgumentParser(
1011
description=(
1112
"Convert a CSV file with event information to an iCalendar ICS file, which"
12-
" can be imported into Google Calendar, Microsoft Outlook and etc."
13+
" can be imported into Google Calendar, Microsoft Outlook, Apple macOS Calendar and etc."
1314
)
1415
)
1516
parser.add_argument("input", type=str, help="Input CSV file containing calendar events")
@@ -65,9 +66,9 @@ def csv2ical(input_file: str, output_file: str):
6566
out_f.close()
6667

6768

68-
def main(args: argparse.Namespace):
69+
def main():
6970
csv2ical(args.input, args.output)
7071

7172

7273
if __name__ == "__main__":
73-
main(parser.parse_args())
74+
sys.exit(main())

0 commit comments

Comments
 (0)