From acb08db451673803f105f9bad72c63676dca60a0 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sun, 15 Dec 2024 16:25:57 +0000 Subject: [PATCH] Fixes #79. Add the package version number to the PRODID string returned in serialized form. --- test_files/simple_2_0_test.ics | 2 +- tests.py | 4 ++-- vobject/__init__.py | 6 +----- vobject/base.py | 4 ++++ vobject/icalendar.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test_files/simple_2_0_test.ics b/test_files/simple_2_0_test.ics index 9e50610..badd055 100644 --- a/test_files/simple_2_0_test.ics +++ b/test_files/simple_2_0_test.ics @@ -1,6 +1,6 @@ BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//PYVOBJECT//NONSGML Version 1//EN +PRODID:-//PYVOBJECT//NONSGML Version %s//EN BEGIN:VEVENT UID:Not very random UID DTSTART:20060509T000000 diff --git a/tests.py b/tests.py index 1991b9a..8b6deb4 100644 --- a/tests.py +++ b/tests.py @@ -12,7 +12,7 @@ from dateutil.tz import tzutc from dateutil.rrule import rrule, rruleset, WEEKLY, MONTHLY -from vobject import base, iCalendar +from vobject import VERSION, base, iCalendar from vobject import icalendar from vobject.base import __behaviorRegistry as behavior_registry @@ -56,7 +56,7 @@ def test_scratchbuild(self): """ CreateCalendar 2.0 format from scratch """ - test_cal = get_test_file("simple_2_0_test.ics") + test_cal = get_test_file("simple_2_0_test.ics") % VERSION cal = base.newFromBehavior('vcalendar', '2.0') cal.add('vevent') cal.vevent.add('dtstart').value = datetime.datetime(2006, 5, 9) diff --git a/vobject/__init__.py b/vobject/__init__.py index 5f857fd..ffd3469 100644 --- a/vobject/__init__.py +++ b/vobject/__init__.py @@ -76,14 +76,10 @@ """ -from .base import newFromBehavior, readOne, readComponents +from .base import VERSION, newFromBehavior, readOne, readComponents from . import icalendar, vcard -# Package version -VERSION = "0.9.9" - - def iCalendar(): return newFromBehavior('vcalendar', '2.0') diff --git a/vobject/base.py b/vobject/base.py index 83239bd..6765608 100644 --- a/vobject/base.py +++ b/vobject/base.py @@ -9,6 +9,10 @@ import six import sys +# Package version +VERSION = "0.9.9" + + # ------------------------------------ Python 2/3 compatibility challenges ---- # Python 3 no longer has a basestring type, so.... try: diff --git a/vobject/icalendar.py b/vobject/icalendar.py index e12f2dd..dcabafc 100644 --- a/vobject/icalendar.py +++ b/vobject/icalendar.py @@ -29,7 +29,7 @@ class NonExistentTimeError(Exception): pytz = Pytz # keeps quantifiedcode happy from . import behavior -from .base import (VObjectError, NativeError, ValidateError, ParseError, +from .base import (VERSION, VObjectError, NativeError, ValidateError, ParseError, Component, ContentLine, logger, registerBehavior, backslashEscape, foldOneLine) @@ -38,7 +38,7 @@ class NonExistentTimeError(Exception): DATENAMES = ("rdate", "exdate") RULENAMES = ("exrule", "rrule") DATESANDRULES = ("exrule", "rrule", "rdate", "exdate") -PRODID = u"-//PYVOBJECT//NONSGML Version 1//EN" +PRODID = u"-//PYVOBJECT//NONSGML Version %s//EN" % VERSION WEEKDAYS = "MO", "TU", "WE", "TH", "FR", "SA", "SU" FREQUENCIES = ('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY',