ChurchSong 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stefan Bellon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: ChurchSong
3
+ Version: 0.5.0
4
+ Summary: Download the event agenda from ChurchTool and instantiate a PowerPoint slide template with the names and portraits of service staff.
5
+ Author: Stefan Bellon
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Stefan Bellon
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/sbellon/ChurchSong
29
+ Project-URL: Repository, https://github.com/sbellon/ChurchSong.git
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: Microsoft :: Windows
33
+ Classifier: Operating System :: POSIX :: Linux
34
+ Requires-Python: >=3.13
35
+ Description-Content-Type: text/markdown
36
+ Requires-Dist: alive-progress>=3.2.0
37
+ Requires-Dist: platformdirs>=4.3.6
38
+ Requires-Dist: prettytable>=3.12.0
39
+ Requires-Dist: psutil>=6.1.0; sys_platform == "win32"
40
+ Requires-Dist: pydantic>=2.9.2
41
+ Requires-Dist: python-pptx>=1.0.2
42
+ Requires-Dist: requests>=2.32.3
43
+
44
+ # ChurchSong
45
+
46
+ ## Introduction
47
+
48
+ The main purpose of this tool is to download the event agenda from ChurchTool as well
49
+ as the names of the service staff, preparing a PowerPoint slide with the names and
50
+ portraits to be presented at the beginning of the event.
51
+
52
+ Additionally, the SongBeamer agenda can be modified by placing slides at the opening
53
+ or closing, or after specific keywords. Colors of the SongBeamer captions can also be
54
+ changed.
55
+
56
+ The ChurchTools song database can also be checked for consistency regarding metadata
57
+ as well as present .sng files to contain a background image.
58
+
59
+ ## Prerequisites
60
+
61
+ Python package manager [uv](https://docs.astral.sh/uv/) must be installed and
62
+ accessible via PATH. Easiest way is to follow the steps listed as
63
+ [Standalone Installer](https://docs.astral.sh/uv/getting-started/installation/).
64
+
65
+ ## Installation
66
+
67
+ Simply install ChurchSong by executing `uv install ChurchSong`. Tool `ChurchSong` is
68
+ then available from the command line.
69
+
70
+ You may place `ChurchSong.bat` together with `ChurchSong.ico` somewhere for
71
+ convenience as you can just double-click it to load the upcoming agenda and start
72
+ SongBeamer.
73
+
74
+ ## Configuration
75
+
76
+ ### Config file
77
+
78
+ You need to copy the `config.toml.example` to `%LOCALAPPDATA%\ChurchSong\config.toml`
79
+ and adjust the content accordingly.
80
+
81
+ ### PowerPoint template
82
+
83
+ You need to prepare a PowerPoint template with a slide master which contains
84
+ placeholders for pictures and names for the team members. The ChurchTool's service
85
+ team name has to be put at the PowerPoint base placeholder via the Select Pane
86
+ (Alt-F10).
87
+
88
+ ## Usage
89
+
90
+ ### SongBeamer agenda download
91
+
92
+ To download the upcoming agenda you can just execute `ChurchSong` without any
93
+ switches (e.g. double-click it). To specify a starting date to look for the next event,
94
+ you can specify additional command line arguments `agenda FROM_DATE` as positional
95
+ parameter with `FROM_DATE` in the form `YYYY-MM-DD`.
96
+
97
+ If everything goes well, the agenda is downloaded into the `temp_dir`, the slide is
98
+ created from the template, SongBeamer's `Schedule.col` is adjusted and finally
99
+ SongBeamer itself is launched with the prepared `Schedule.col`.
100
+
101
+ You can keep the `temp_dir` as is (it is added to and overwritten in future
102
+ invocations), but there is also no harm in deleting the `temp_dir` as it is
103
+ automatically re-created.
104
+
105
+ ### ChurchTools song verification
106
+
107
+ With the additional command `songs verify` you can check the songs in the
108
+ ChurchTools song database for specific properties like CCLI number, song name, tags,
109
+ arrangement source, duration and a SongBeamer `.sng` file with the `#BackgroundImage`
110
+ property set.
111
+
112
+ With optional positional argument `FROM_DATE` in the form `YYYY-MM-DD` you can select
113
+ to only check the songs of the next event agenda after `FROM_DATE`.
114
+
115
+ Using command options `--exclude_tags` and/or `--include_tags` you can filter out
116
+ songs with specific tags or only include songs with specific tags in the check.
@@ -0,0 +1,73 @@
1
+ # ChurchSong
2
+
3
+ ## Introduction
4
+
5
+ The main purpose of this tool is to download the event agenda from ChurchTool as well
6
+ as the names of the service staff, preparing a PowerPoint slide with the names and
7
+ portraits to be presented at the beginning of the event.
8
+
9
+ Additionally, the SongBeamer agenda can be modified by placing slides at the opening
10
+ or closing, or after specific keywords. Colors of the SongBeamer captions can also be
11
+ changed.
12
+
13
+ The ChurchTools song database can also be checked for consistency regarding metadata
14
+ as well as present .sng files to contain a background image.
15
+
16
+ ## Prerequisites
17
+
18
+ Python package manager [uv](https://docs.astral.sh/uv/) must be installed and
19
+ accessible via PATH. Easiest way is to follow the steps listed as
20
+ [Standalone Installer](https://docs.astral.sh/uv/getting-started/installation/).
21
+
22
+ ## Installation
23
+
24
+ Simply install ChurchSong by executing `uv install ChurchSong`. Tool `ChurchSong` is
25
+ then available from the command line.
26
+
27
+ You may place `ChurchSong.bat` together with `ChurchSong.ico` somewhere for
28
+ convenience as you can just double-click it to load the upcoming agenda and start
29
+ SongBeamer.
30
+
31
+ ## Configuration
32
+
33
+ ### Config file
34
+
35
+ You need to copy the `config.toml.example` to `%LOCALAPPDATA%\ChurchSong\config.toml`
36
+ and adjust the content accordingly.
37
+
38
+ ### PowerPoint template
39
+
40
+ You need to prepare a PowerPoint template with a slide master which contains
41
+ placeholders for pictures and names for the team members. The ChurchTool's service
42
+ team name has to be put at the PowerPoint base placeholder via the Select Pane
43
+ (Alt-F10).
44
+
45
+ ## Usage
46
+
47
+ ### SongBeamer agenda download
48
+
49
+ To download the upcoming agenda you can just execute `ChurchSong` without any
50
+ switches (e.g. double-click it). To specify a starting date to look for the next event,
51
+ you can specify additional command line arguments `agenda FROM_DATE` as positional
52
+ parameter with `FROM_DATE` in the form `YYYY-MM-DD`.
53
+
54
+ If everything goes well, the agenda is downloaded into the `temp_dir`, the slide is
55
+ created from the template, SongBeamer's `Schedule.col` is adjusted and finally
56
+ SongBeamer itself is launched with the prepared `Schedule.col`.
57
+
58
+ You can keep the `temp_dir` as is (it is added to and overwritten in future
59
+ invocations), but there is also no harm in deleting the `temp_dir` as it is
60
+ automatically re-created.
61
+
62
+ ### ChurchTools song verification
63
+
64
+ With the additional command `songs verify` you can check the songs in the
65
+ ChurchTools song database for specific properties like CCLI number, song name, tags,
66
+ arrangement source, duration and a SongBeamer `.sng` file with the `#BackgroundImage`
67
+ property set.
68
+
69
+ With optional positional argument `FROM_DATE` in the form `YYYY-MM-DD` you can select
70
+ to only check the songs of the next event agenda after `FROM_DATE`.
71
+
72
+ Using command options `--exclude_tags` and/or `--include_tags` you can filter out
73
+ songs with specific tags or only include songs with specific tags in the check.
@@ -0,0 +1,74 @@
1
+ [project]
2
+ name = "ChurchSong"
3
+ version = "0.5.0"
4
+ authors = [{ name = "Stefan Bellon" }]
5
+ description = "Download the event agenda from ChurchTool and instantiate a PowerPoint slide template with the names and portraits of service staff."
6
+ readme = "README.md"
7
+ license = { file = "LICENSE" }
8
+ requires-python = ">=3.13"
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Operating System :: Microsoft :: Windows",
13
+ "Operating System :: POSIX :: Linux",
14
+ ]
15
+ dependencies = [
16
+ "alive-progress>=3.2.0",
17
+ "platformdirs>=4.3.6",
18
+ "prettytable>=3.12.0",
19
+ "psutil>=6.1.0; sys_platform == 'win32'",
20
+ "pydantic>=2.9.2",
21
+ "python-pptx>=1.0.2",
22
+ "requests>=2.32.3",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/sbellon/ChurchSong"
27
+ Repository = "https://github.com/sbellon/ChurchSong.git"
28
+
29
+ [project.scripts]
30
+ ChurchSong = "churchsong.__main__:main"
31
+
32
+ [dependency-groups]
33
+ dev = []
34
+ lint = ["pyright>=1.1.387", "ruff>=0.7.2"]
35
+
36
+ [tool.uv]
37
+ package = true
38
+
39
+ [tool.setuptools]
40
+ license-files = []
41
+
42
+ [tool.pyright]
43
+ venvPath = "."
44
+ venv = ".venv"
45
+ typeCheckingMode = "basic"
46
+
47
+ [tool.ruff]
48
+ line-length = 88
49
+
50
+ [tool.ruff.lint]
51
+ select = ["ALL"]
52
+
53
+ fixable = [
54
+ "I", # isort
55
+ ]
56
+
57
+ ignore = [
58
+ "D", # docstring
59
+ "COM812", # missing-trailing-comma
60
+ ]
61
+
62
+ [tool.ruff.lint.flake8-quotes]
63
+ inline-quotes = "single"
64
+
65
+ [tool.ruff.format]
66
+ quote-style = "single"
67
+
68
+ [tool.ruff.lint.pep8-naming]
69
+ # Allow Pydantic's `@validator` decorator to trigger class method treatment.
70
+ classmethod-decorators = [
71
+ "classmethod",
72
+ "pydantic.validator",
73
+ "pydantic.root_validator",
74
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: ChurchSong
3
+ Version: 0.5.0
4
+ Summary: Download the event agenda from ChurchTool and instantiate a PowerPoint slide template with the names and portraits of service staff.
5
+ Author: Stefan Bellon
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Stefan Bellon
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/sbellon/ChurchSong
29
+ Project-URL: Repository, https://github.com/sbellon/ChurchSong.git
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: Microsoft :: Windows
33
+ Classifier: Operating System :: POSIX :: Linux
34
+ Requires-Python: >=3.13
35
+ Description-Content-Type: text/markdown
36
+ Requires-Dist: alive-progress>=3.2.0
37
+ Requires-Dist: platformdirs>=4.3.6
38
+ Requires-Dist: prettytable>=3.12.0
39
+ Requires-Dist: psutil>=6.1.0; sys_platform == "win32"
40
+ Requires-Dist: pydantic>=2.9.2
41
+ Requires-Dist: python-pptx>=1.0.2
42
+ Requires-Dist: requests>=2.32.3
43
+
44
+ # ChurchSong
45
+
46
+ ## Introduction
47
+
48
+ The main purpose of this tool is to download the event agenda from ChurchTool as well
49
+ as the names of the service staff, preparing a PowerPoint slide with the names and
50
+ portraits to be presented at the beginning of the event.
51
+
52
+ Additionally, the SongBeamer agenda can be modified by placing slides at the opening
53
+ or closing, or after specific keywords. Colors of the SongBeamer captions can also be
54
+ changed.
55
+
56
+ The ChurchTools song database can also be checked for consistency regarding metadata
57
+ as well as present .sng files to contain a background image.
58
+
59
+ ## Prerequisites
60
+
61
+ Python package manager [uv](https://docs.astral.sh/uv/) must be installed and
62
+ accessible via PATH. Easiest way is to follow the steps listed as
63
+ [Standalone Installer](https://docs.astral.sh/uv/getting-started/installation/).
64
+
65
+ ## Installation
66
+
67
+ Simply install ChurchSong by executing `uv install ChurchSong`. Tool `ChurchSong` is
68
+ then available from the command line.
69
+
70
+ You may place `ChurchSong.bat` together with `ChurchSong.ico` somewhere for
71
+ convenience as you can just double-click it to load the upcoming agenda and start
72
+ SongBeamer.
73
+
74
+ ## Configuration
75
+
76
+ ### Config file
77
+
78
+ You need to copy the `config.toml.example` to `%LOCALAPPDATA%\ChurchSong\config.toml`
79
+ and adjust the content accordingly.
80
+
81
+ ### PowerPoint template
82
+
83
+ You need to prepare a PowerPoint template with a slide master which contains
84
+ placeholders for pictures and names for the team members. The ChurchTool's service
85
+ team name has to be put at the PowerPoint base placeholder via the Select Pane
86
+ (Alt-F10).
87
+
88
+ ## Usage
89
+
90
+ ### SongBeamer agenda download
91
+
92
+ To download the upcoming agenda you can just execute `ChurchSong` without any
93
+ switches (e.g. double-click it). To specify a starting date to look for the next event,
94
+ you can specify additional command line arguments `agenda FROM_DATE` as positional
95
+ parameter with `FROM_DATE` in the form `YYYY-MM-DD`.
96
+
97
+ If everything goes well, the agenda is downloaded into the `temp_dir`, the slide is
98
+ created from the template, SongBeamer's `Schedule.col` is adjusted and finally
99
+ SongBeamer itself is launched with the prepared `Schedule.col`.
100
+
101
+ You can keep the `temp_dir` as is (it is added to and overwritten in future
102
+ invocations), but there is also no harm in deleting the `temp_dir` as it is
103
+ automatically re-created.
104
+
105
+ ### ChurchTools song verification
106
+
107
+ With the additional command `songs verify` you can check the songs in the
108
+ ChurchTools song database for specific properties like CCLI number, song name, tags,
109
+ arrangement source, duration and a SongBeamer `.sng` file with the `#BackgroundImage`
110
+ property set.
111
+
112
+ With optional positional argument `FROM_DATE` in the form `YYYY-MM-DD` you can select
113
+ to only check the songs of the next event agenda after `FROM_DATE`.
114
+
115
+ Using command options `--exclude_tags` and/or `--include_tags` you can filter out
116
+ songs with specific tags or only include songs with specific tags in the check.
@@ -0,0 +1,19 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ChurchSong.egg-info/PKG-INFO
5
+ src/ChurchSong.egg-info/SOURCES.txt
6
+ src/ChurchSong.egg-info/dependency_links.txt
7
+ src/ChurchSong.egg-info/entry_points.txt
8
+ src/ChurchSong.egg-info/requires.txt
9
+ src/ChurchSong.egg-info/top_level.txt
10
+ src/churchsong/__init__.py
11
+ src/churchsong/__main__.py
12
+ src/churchsong/configuration.py
13
+ src/churchsong/powerpoint.py
14
+ src/churchsong/utils.py
15
+ src/churchsong/churchtools/__init__.py
16
+ src/churchsong/churchtools/events.py
17
+ src/churchsong/churchtools/song_verification.py
18
+ src/churchsong/songbeamer/__init__.py
19
+ src/churchsong/songbeamer/windows.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ChurchSong = churchsong.__main__:main
@@ -0,0 +1,9 @@
1
+ alive-progress>=3.2.0
2
+ platformdirs>=4.3.6
3
+ prettytable>=3.12.0
4
+ pydantic>=2.9.2
5
+ python-pptx>=1.0.2
6
+ requests>=2.32.3
7
+
8
+ [:sys_platform == "win32"]
9
+ psutil>=6.1.0
@@ -0,0 +1 @@
1
+ churchsong
File without changes
@@ -0,0 +1,205 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import datetime
5
+ import functools
6
+ import importlib.metadata
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+
11
+ from churchsong.churchtools import ChurchToolsAPI
12
+ from churchsong.churchtools.events import ChurchToolsEvent
13
+ from churchsong.churchtools.song_verification import ChurchToolsSongVerification
14
+ from churchsong.configuration import Configuration
15
+ from churchsong.powerpoint import PowerPoint
16
+ from churchsong.songbeamer import SongBeamer
17
+
18
+
19
+ def get_app_version() -> str:
20
+ try:
21
+ return importlib.metadata.version('ChurchSong')
22
+ except (importlib.metadata.PackageNotFoundError, AssertionError):
23
+ return 'unknown'
24
+
25
+
26
+ def cmd_self_info(_args: argparse.Namespace, config: Configuration) -> None:
27
+ sys.stderr.write(f'Config file: {config.config_toml}\n')
28
+ sys.stderr.write(f'Data directory: {config.data_dir}\n')
29
+
30
+
31
+ def cmd_self_update(_args: argparse.Namespace, config: Configuration) -> None:
32
+ config.log.info('Starting ChurchSong update')
33
+ uv = shutil.which('uv')
34
+ if not uv:
35
+ err_msg = 'Cannot find "uv", aborting self update'
36
+ config.log.fatal(err_msg)
37
+ sys.stderr.write(f'{err_msg}\n')
38
+ sys.exit(1)
39
+ try:
40
+ subprocess.run([uv, 'self', 'update'], check=True) # noqa: S603
41
+ subprocess.run([uv, 'tool', 'upgrade', 'ChurchSong'], check=True) # noqa: S603
42
+ except subprocess.CalledProcessError as e:
43
+ config.log.fatal(f'"uv self update" failed: {e}')
44
+ raise
45
+
46
+
47
+ def cmd_agenda(args: argparse.Namespace, config: Configuration) -> None:
48
+ if args.command is None:
49
+ args.from_date = None
50
+
51
+ config.log.info('Starting ChurchSong with FROM_DATE=%s', args.from_date)
52
+ cta = ChurchToolsAPI(config)
53
+ event = cta.get_next_event(args.from_date, agenda_required=True)
54
+ cte = ChurchToolsEvent(cta, event, config)
55
+ service_leads = cte.get_service_leads()
56
+ event_files = cte.download_and_extract_agenda_zip()
57
+
58
+ pp = PowerPoint(config)
59
+ pp.create(service_leads)
60
+ pp.save()
61
+
62
+ sb = SongBeamer(config)
63
+ sb.modify_and_save_agenda(event.start_date, service_leads, event_files)
64
+ sb.launch()
65
+
66
+
67
+ def cmd_songs_verify(args: argparse.Namespace, config: Configuration) -> None:
68
+ config.log.info('Starting song verification')
69
+ cta = ChurchToolsAPI(config)
70
+ ctsv = ChurchToolsSongVerification(cta, config)
71
+ ctsv.verify_songs(
72
+ from_date=args.from_date,
73
+ include_tags=args.include_tags,
74
+ exclude_tags=args.exclude_tags,
75
+ execute_checks=args.execute_checks,
76
+ )
77
+
78
+
79
+ def main() -> None:
80
+ sys.stderr.write('\r\033[2K\r')
81
+ config = Configuration()
82
+ try:
83
+ config.log.debug('Parsing command line with args: %s', sys.argv)
84
+ parser = argparse.ArgumentParser(
85
+ prog='ChurchSong',
86
+ description='Download ChurchTools event agenda and import into SongBeamer.',
87
+ allow_abbrev=False,
88
+ )
89
+ parser.set_defaults(func=functools.partial(cmd_agenda, config=config))
90
+ subparsers = parser.add_subparsers(
91
+ dest='command',
92
+ help='possible commands, use --help to get detailed help',
93
+ )
94
+ parser_agenda = subparsers.add_parser(
95
+ 'agenda',
96
+ help='create SongBeamer agenda',
97
+ allow_abbrev=False,
98
+ )
99
+ parser_agenda.add_argument(
100
+ 'from_date',
101
+ metavar='FROM_DATE',
102
+ type=datetime.date.fromisoformat,
103
+ nargs='?',
104
+ help='search in ChurchTools for next event >= FROM_DATE (YYYY-MM-DD)',
105
+ )
106
+ parser_agenda.set_defaults(func=functools.partial(cmd_agenda, config=config))
107
+ parser_songs = subparsers.add_parser(
108
+ 'songs',
109
+ help='operate on the ChurchTools songs',
110
+ allow_abbrev=False,
111
+ )
112
+ subparser_songs = parser_songs.add_subparsers(
113
+ dest='subcommand',
114
+ help='commands to execute on the ChurchTools song database',
115
+ required=True,
116
+ )
117
+ parser_songs_verify = subparser_songs.add_parser(
118
+ 'verify',
119
+ help='check all songs for inconsistent and incomplete data and then exit',
120
+ allow_abbrev=False,
121
+ )
122
+ parser_songs_verify.add_argument(
123
+ '--exclude_tags',
124
+ metavar='TAG',
125
+ action='extend',
126
+ nargs='+',
127
+ help='list of song tags that should be excluded from verification',
128
+ )
129
+ parser_songs_verify.add_argument(
130
+ '--include_tags',
131
+ metavar='TAG',
132
+ action='extend',
133
+ nargs='+',
134
+ help='list of song tags that should be included in verification',
135
+ )
136
+ parser_songs_verify.add_argument(
137
+ '--execute_checks',
138
+ metavar='CHECK_NAME',
139
+ action='extend',
140
+ nargs='+',
141
+ help=(
142
+ 'list of checks that should be performed (header names of result table)'
143
+ ),
144
+ )
145
+ parser_songs_verify.add_argument(
146
+ 'from_date',
147
+ metavar='FROM_DATE',
148
+ type=datetime.date.fromisoformat,
149
+ nargs='?',
150
+ help='verify only songs of next event >= FROM_DATE (YYYY-MM-DD)',
151
+ )
152
+ parser_songs_verify.set_defaults(
153
+ func=functools.partial(cmd_songs_verify, config=config)
154
+ )
155
+ parser_self = subparsers.add_parser(
156
+ 'self',
157
+ help='operate on the ChurchSong application itself',
158
+ allow_abbrev=False,
159
+ )
160
+ subparser_self = parser_self.add_subparsers(
161
+ dest='subcommand',
162
+ help='commands to execute on the ChurchSong application itself',
163
+ required=True,
164
+ )
165
+ parser_self_update = subparser_self.add_parser(
166
+ 'info',
167
+ help='info about the ChurchSong application',
168
+ allow_abbrev=False,
169
+ )
170
+ parser_self_update.set_defaults(
171
+ func=functools.partial(cmd_self_info, config=config)
172
+ )
173
+ parser_self_update = subparser_self.add_parser(
174
+ 'update',
175
+ help='updates the ChurchSong application',
176
+ allow_abbrev=False,
177
+ )
178
+ parser_self_update.set_defaults(
179
+ func=functools.partial(cmd_self_update, config=config)
180
+ )
181
+ parser_self_version = subparser_self.add_parser(
182
+ 'version',
183
+ help="show program's version number and exit",
184
+ allow_abbrev=False,
185
+ )
186
+ parser_self_version.set_defaults(
187
+ func=lambda _: sys.stdout.write(f'{get_app_version()}\n')
188
+ )
189
+ parser.add_argument(
190
+ '-v', '--version', action='version', version=get_app_version()
191
+ )
192
+ args = parser.parse_args()
193
+ try:
194
+ args.func(args)
195
+ except KeyboardInterrupt:
196
+ sys.stdout.write('Aborted.\n')
197
+ sys.exit(1)
198
+
199
+ except Exception as e:
200
+ config.log.fatal(e, exc_info=True)
201
+ raise
202
+
203
+
204
+ if __name__ == '__main__':
205
+ main()