From e32ed93dd4ed31a22637209f2735ac19098c9bcf Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Fri, 28 Oct 2022 13:11:58 +0200 Subject: bugfix - setup.py imported calendar-cli to check for metadata, this broke due to missing dependencies. metadata now pushed out in a separate file --- cal.py | 4 +++- calendar-cli.py | 27 ++++++++------------------- metadata.py | 13 +++++++++++++ setup.py | 11 +++++------ 4 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 metadata.py diff --git a/cal.py b/cal.py index bad85ad..f143cf9 100755 --- a/cal.py +++ b/cal.py @@ -20,13 +20,15 @@ https://github.com/tobixen/calendar-cli/issues/88 ## This file aims to be smaller than the old calendar-cli while ## offering more featuores. -from calendar_cli import __version__ +from metadata import metadata +__version__ = metadata["version"] import click import os import caldav #import isodate import dateutil +import dateutil.parser import datetime import re from icalendar import prop diff --git a/calendar-cli.py b/calendar-cli.py index 0877f0a..49ef9e5 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -38,6 +38,8 @@ import urllib3 from getpass import getpass from six import PY3 +from metadata import metadata + UTC = pytz.utc #UTC = zoneinfo.ZoneInfo('UTC') @@ -60,19 +62,6 @@ try: except NameError: unicode = str -__version__ = "0.13.0" -__author__ = "Tobias Brox" -__author_short__ = "tobixen" -__copyright__ = "Copyright 2013-2021, Tobias Brox and contributors" -#__credits__ = [] -__license__ = "GPLv3+" -__license_url__ = "http://www.gnu.org/licenses/gpl-3.0-standalone.html" -__maintainer__ = "Tobias Brox" -__author_email__ = "t-calendar-cli@tobixen.no" -__status__ = "Development" -__product__ = "calendar-cli" -__description__ = "high-level cli against caldav servers" - def _date(ts): """ helper function to get a date out of a Date or Datetime object. @@ -372,7 +361,7 @@ def create_alarm(message, relative_timedelta): def calendar_add(caldav_conn, args): cal = Calendar() - cal.add('prodid', '-//{author_short}//{product}//{language}'.format(author_short=__author_short__, product=__product__, language=args.language)) + cal.add('prodid', '-//{author_short}//{product}//{language}'.format(language=args.language, **metadata)) cal.add('version', '2.0') event = Event() ## read timestamps from arguments @@ -443,7 +432,7 @@ def calendar_delete(caldav_conn, args): def journal_add(caldav_conn, args): ## TODO: copied from todo_add, should probably be consolidated cal = Calendar() - cal.add('prodid', '-//{author_short}//{product}//{language}'.format(author_short=__author_short__, product=__product__, language=args.language)) + cal.add('prodid', '-//{author_short}//{product}//{language}'.format(language=args.language, **metadata)) cal.add('version', '2.0') journal = Journal() ## TODO: what does the cryptic comment here really mean, and why was the dtstamp commented out? dtstamp is required according to the RFC. @@ -467,7 +456,7 @@ def todo_add(caldav_conn, args): else: uid = uuid.uuid1() cal = Calendar() - cal.add('prodid', '-//{author_short}//{product}//{language}'.format(author_short=__author_short__, product=__product__, language=args.language)) + cal.add('prodid', '-//{author_short}//{product}//{language}'.format(language=args.language, **metadata)) cal.add('version', '2.0') todo = Todo() todo.add('dtstamp', _now()) @@ -808,7 +797,7 @@ def main(): # We make this parser with add_help=False so that # it doesn't parse -h and print help. conf_parser = argparse.ArgumentParser( - prog=__product__, + prog=metadata["product"], description=__doc__, # printed with -h/--help # Don't mess with format of description formatter_class=argparse.RawDescriptionHelpFormatter, @@ -822,7 +811,7 @@ def main(): conf_parser.add_argument("--interactive-config", help="Interactively ask for configuration", action="store_true") args, remaining_argv = conf_parser.parse_known_args() - conf_parser.add_argument("--version", action='version', version='%%(prog)s %s' % __version__) + conf_parser.add_argument("--version", action='version', version='%%(prog)s %s' % metadata["version"]) config = {} @@ -854,7 +843,7 @@ def main(): # Don't suppress add_help here so it will handle -h parser = argparse.ArgumentParser( description=__doc__, - prog=__product__, + prog=metadata["product"], # Inherit options from config_parser parents=[conf_parser] ) diff --git a/metadata.py b/metadata.py new file mode 100644 index 0000000..1d46a69 --- /dev/null +++ b/metadata.py @@ -0,0 +1,13 @@ +metadata = { + "version": "0.14.0dev", + "author": "Tobias Brox", + "author_short": "tobixen", + "copyright": "Copyright 2013-2022, Tobias Brox and contributors", + "license": "GPLv3+", + "license_url": "http://www.gnu.org/licenses/gpl-3.0-standalone.html", + "maintainer": "Tobias Brox", + "author_email": "t-calendar-cli@tobixen.no", + "status": "Development", + "product": "calendar-cli", + "description": "high-level cli against caldav servers", +} diff --git a/setup.py b/setup.py index 0d91b62..afff7e5 100644 --- a/setup.py +++ b/setup.py @@ -5,12 +5,11 @@ import os from setuptools import setup, find_packages -import calendar_cli as my_script +import metadata -metadata = {} +metadata_ = {} for attribute in ('version', 'author', 'author_email', 'license'): - if hasattr(my_script, '__%s__' % attribute): - metadata[attribute] = getattr(my_script, '__%s__' % attribute) + metadata_[attribute] = getattr(metadata, '__%s__' % attribute) setup( name='calendar-cli', @@ -32,7 +31,7 @@ setup( py_modules=['cal'], install_requires=[ 'icalendar', - 'caldav>=0.10.0dev', + 'caldav>=0.10', # 'isodate', 'pytz', ## pytz is supposed to be obsoleted, but see https://github.com/collective/icalendar/issues/333 'tzlocal', @@ -44,5 +43,5 @@ setup( 'kal = cal:cli', ], }, - **metadata + **metadata_ ) -- cgit v1.2.3