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

ValueError: unsupported property: X-LIC-LOCATION #1185

Open
marc1uk opened this issue Jan 10, 2022 · 1 comment · May be fixed by #1273
Open

ValueError: unsupported property: X-LIC-LOCATION #1185

marc1uk opened this issue Jan 10, 2022 · 1 comment · May be fixed by #1273

Comments

@marc1uk
Copy link

marc1uk commented Jan 10, 2022

python3
Python 3.5.3 (default, Nov  4 2021, 15:29:10) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dateutil.tz import *;
>>> tz = tzical('/home/me/cln2stbb4dk6ur39chgnig37e9nnas1eeon66obccln68obi5pjmurr7dhiisorfdk@virtual.ics')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/.local/lib/python3.5/site-packages/dateutil/tz/tz.py", line 1279, in __init__
    self._parse_rfc(fobj.read())
  File "/home/me/.local/lib/python3.5/site-packages/dateutil/tz/tz.py", line 1449, in _parse_rfc
    raise ValueError("unsupported property: "+name)
ValueError: unsupported property: X-LIC-LOCATION

Any suggestions? The ics file i'm trying to import is just a google calendar standard one of public holidays.

@danieljnchen
Copy link

I ran into the same issue myself -- the problem is that the tzical class doesn't support non-standard properties, as defined by RFC 5545. Google Calendar is one such vendor that likes to add these experimental properties into their timezone definitions (and their icalendar files in general); here is a simple example that reproduces this issue:

from dateutil.tz import tzical
from io import StringIO

# timezone definition from a Google Calendar ICS event
vtimezone = "BEGIN:VTIMEZONE\r\nTZID:America/New_York\r\nX-LIC-LOCATION:America/New_York\r\nBEGIN:DAYLIGHT\r\nDTSTART:19700308T020000\r\nRRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3\r\nTZNAME:EDT\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0400\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nDTSTART:19701101T020000\r\nRRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11\r\nTZNAME:EST\r\nTZOFFSETFROM:-0400\r\nTZOFFSETTO:-0500\r\nEND:STANDARD\r\nEND:VTIMEZONE"

with StringIO(vtimezone) as tz_file:
    tz = tzical(tz_file)  # ValueError

RFC 5545 specifies that

Applications MUST ignore x-param and iana-param values they don't recognize.

and additionally includes x-prop as a valid property of a VTIMEZONE component (source), so I believe that this is a bug that dateutil should handle. It should be pretty simple to fix this; I'll make a PR.

In the meantime, you can get your code working by parsing out the non-standard properties before passing your file to tzical:

import re
from dateutil.tz import tzical
from io import StringIO

timezone_file = "your_timezone_file.ics"
with open(timezone_file, "r") as f:
    vtimezone = f.read()

# NOTE: this doesn't handle line folding
# If you want to handle experimental attributes that are on lines that may
# be folded, refer to this code:
# https://github.com/dateutil/dateutil/blob/master/src/dateutil/tz/tz.py#L1335
clean_vtimezone = re.sub("X-.+?(\r\n|\n)", "", vtimezone)
with StringIO(clean_vtimezone) as tz_file:
    tz = tzical(tz_file)

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

Successfully merging a pull request may close this issue.

2 participants