Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rruleset not readable in newer versions (0.9.5) #104

Closed
buster opened this issue Jan 2, 2018 · 1 comment
Closed

rruleset not readable in newer versions (0.9.5) #104

buster opened this issue Jan 2, 2018 · 1 comment

Comments

@buster
Copy link

buster commented Jan 2, 2018

Hello,

i am having a problem with radicale which uses vobject.
As far as i can tell an older version of vobject supported accessing "rruleset" in a VTODO but 0.9.5 doesn't?
I receive the following traceback:

>>> c[0].rruleset
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/vobject/base.py", line 529, in __getattr__
    return self.contents[toVName(name)][0]
KeyError: 'rruleset'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/vobject/base.py", line 531, in __getattr__
    raise AttributeError(name)
AttributeError: rruleset

Is this expected to happen?
I've put example data and what i tried in the radicale issue tracker here: Kozea/Radicale#764

@jcriner-dev
Copy link

buster,

I was having issues when upgrading radicale as well. Everything kept failing on rrules with an UNTIL clause even though it previously worked. I suspect commit 7b2db0e which altered icalendar.py is the culprit. It appears as though the intent was to ignore the timezone in rrules if dtstart was just a date.

However, the check, which was not present in previous versions of vobject, tests ignoretz=isinstance(dtstart, datetime.date). This is True for both datetime.date AND datetime.datetime, so ignoretz=True is passed to dateutil.rrule.rrulestr() which breaks consistency checks when dtstart is timezone aware. From the comments, I think the intent was to only do this if dtstart was just a date. I wonder if the check should be "is date but not datetime". The patch below fixed it for me.

--- ~/python/vobject-0.9.5/vobject/icalendar.py	2017-06-29 14:55:55.000000000 -0400
+++ ~/.virtualenvs/radicale2/lib/python3.4/site-packages/vobject/icalendar.py	2018-04-03 18:42:47.064826576 -0400
@@ -446,11 +446,22 @@
                     # a Ruby iCalendar library escapes semi-colons in rrules,
                     # so also remove any backslashes
                     value = line.value.replace('\\', '')
+                    #rule = rrule.rrulestr(
+                    #    value, dtstart=dtstart,
+                        # If dtstart has no time zone, `until`
+                        # shouldn't get one, either:
+                        #ignoretz=isinstance(dtstart, datetime.date))
+                    # commit 7b2db0e broke rrules from dateutil using until.
+                    # added this hotfix.
+                    is_it_just_a_date = (
+                            isinstance(dtstart, datetime.date) and
+                            not isinstance(dtstart, datetime.datetime)
+                            )
                     rule = rrule.rrulestr(
                         value, dtstart=dtstart,
                         # If dtstart has no time zone, `until`
                         # shouldn't get one, either:
-                        ignoretz=isinstance(dtstart, datetime.date))
+                        ignoretz=is_it_just_a_date)
                     until = rule._until
 
                     if until is not None and isinstance(dtstart,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants