ya3

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

ya3 (1963B)


      1 #!/usr/bin/env python3
      2 
      3 # Copyright 2018, 2019, 2020 Matthias Balk
      4 #
      5 # This file is part of ya3 (yet another appointment application).
      6 #
      7 # ya3 is free software: you can redistribute it and/or modify it under the
      8 # terms of the GNU Affero General Public License as published by the Free
      9 # Software Foundation, either version 3 of the License, or (at your option) any
     10 # later version.
     11 #
     12 # ya3 is distributed in the hope that it will be useful, but WITHOUT ANY
     13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     14 # A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
     15 # details.
     16 #
     17 # You should have received a copy of the GNU Affero General Public License
     18 # along with ya3.  If not, see <http://www.gnu.org/licenses/>.
     19 
     20 """ya3 -- yet another appointment application"""
     21 
     22 import glob
     23 import os.path
     24 from argparse import ArgumentParser
     25 
     26 import commands
     27 import config
     28 import utils
     29 
     30 parser = ArgumentParser(description='''
     31 ya3 -- yet another appointment application, version {ver}'''.format(
     32         ver=utils.get_ya3_version()))
     33 
     34 parser.add_argument('command',
     35                     choices=['create', 'add', 'print'],
     36                     help='create|add, print')
     37 parser.add_argument('-f', '--filename', required=False,
     38                     help='Optional filename for command "print". Implies -a.')
     39 parser.add_argument('-a', '--all', required=False, action='store_true',
     40                     help='When used with command "print" all events are ' \
     41                             'printed, configured date range is ignored.')
     42 args = parser.parse_args()
     43 
     44 if args.command == 'create' or args.command == 'add':
     45     commands.create_event()
     46 elif args.command == 'print':
     47     if args.filename == None:
     48         commands.print_events(glob.glob(os.path.join(config.CAL_DIR, '*.ics')),
     49                               ignore_configured_range=args.all)
     50     else:
     51         commands.print_events([args.filename], ignore_configured_range=True)