ya3

ya3 -- yet another appointment application
Log | Files | Refs

commit 7478d6ca1abd589b795257f0b141a7678d5a3d08
parent e9c7e06890f837b6a8b22c6352ea6de3a91f8088
Author: Matthias Balk <mbalk@mbalk.de>
Date:   Fri,  4 Sep 2020 16:28:19 +0200

command 'print' takes an optional filename to print

If the filename is omitted, behavior is as before (print everything in
configured directory which is in configured range).

Diffstat:
MREADME.rst | 1-
Msrc/commands.py | 6++++--
Msrc/ya3 | 7++++++-
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst @@ -14,7 +14,6 @@ Features Features to be implemented ~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ya3 parse <file> or ya3 print [file] to print a specified calendar file - Support for recurrence (like birthdays). See https://www.kanzaki.com/docs/ical/rrule.html - ... diff --git a/src/commands.py b/src/commands.py @@ -1,4 +1,4 @@ -# Copyright 2018, 2019 Matthias Balk +# Copyright 2018, 2019, 2020 Matthias Balk # # This file is part of ya3 (yet another appointment application). # @@ -90,9 +90,11 @@ def _conv2local(dt): return dt.astimezone(gettz()) -def print_events(icsfilenames): +def print_events(icsfilenames, ignore_configured_range=False): def _is_in_range(event): + if ignore_configured_range: + return True start = _conv2local(event.dtstart.value) end = _conv2local(event.dtend.value) return (end >= datetime.now(gettz()) - config.MAX_AGE and diff --git a/src/ya3 b/src/ya3 @@ -31,9 +31,14 @@ parser = ArgumentParser() parser.add_argument('command', choices=['create', 'add', 'print'], help='create|add, print') +parser.add_argument('-f', '--filename', required=False, + help='optional filename for command "print"') args = parser.parse_args() if args.command == 'create' or args.command == 'add': commands.create_event() elif args.command == 'print': - commands.print_events(glob.glob(os.path.join(config.CAL_DIR, '*.ics'))) + if args.filename == None: + commands.print_events(glob.glob(os.path.join(config.CAL_DIR, '*.ics'))) + else: + commands.print_events([args.filename], ignore_configured_range=True)