Giter Club home page Giter Club logo

vobject's Issues

vcard: Base64 encoding breaks if object is binary: AttributeError: 'bytes' object has no attribute 'encode'

vcard base64 encoding is broken

PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZ...
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/usr/lib/python3.4/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 993, in defaultSerialize
    child.serialize(outbuf, lineLength, validate=False)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/usr/lib/python3.4/site-packages/vobject/vcard.py", line 227, in serialize
    VCardTextBehavior.serialize(obj, buf, lineLength, validate)
  File "/usr/lib/python3.4/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 1001, in defaultSerialize
    obj.behavior.encode(obj)
  File "/usr/lib/python3.4/site-packages/vobject/vcard.py", line 152, in encode
    line.value = codecs.encode(line.value.encode(coding), "base64").decode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'

version 0.8.2 fails test suite

Hi,

I've been working on a package for GNU Guix that depends on vobject. When 0.8.1c was removed from PyPi, I tried updating to 0.8.2. Unfortunately, this version of vobject fails its test suite.

I'm building with python-2.7.10, pyicu-1.8, and dateutil-2.4.2.

I've included the failing portion of the build log below. Please let me know if I can provide more information.

phase `build' succeeded after 0.1 seconds
starting phase `check'
running "python setup.py" with command "test" and parameters ()
running test
running egg_info
writing requirements to vobject.egg-info/requires.txt
writing vobject.egg-info/PKG-INFO
writing top-level names to vobject.egg-info/top_level.txt
writing dependency_links to vobject.egg-info/dependency_links.txt
writing entry points to vobject.egg-info/entry_points.txt
reading manifest file 'vobject.egg-info/SOURCES.txt'
writing manifest file 'vobject.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 75, in <module>
    Topic :: Text Processing""".strip().splitlines()
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/gnu/store/fr88c7i5vwdzdnsjlmf9nxhmsmfbw4pr-python2-setuptools-18.3.1/lib/python2.7/site-packages/setuptools-18.3.1-py2.7.egg/setuptools/command/test.py", line 142, in run
  File "/gnu/store/fr88c7i5vwdzdnsjlmf9nxhmsmfbw4pr-python2-setuptools-18.3.1/lib/python2.7/site-packages/setuptools-18.3.1-py2.7.egg/setuptools/command/test.py", line 122, in with_project_on_sys_path
  File "/gnu/store/fr88c7i5vwdzdnsjlmf9nxhmsmfbw4pr-python2-setuptools-18.3.1/lib/python2.7/site-packages/setuptools-18.3.1-py2.7.egg/setuptools/command/test.py", line 163, in run_tests
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/gnu/store/plpfbrhpfidc2nsnclm3d4zc5d1815a0-python-2.7.10/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
ImportError: No module named test_vobject
phase `check' failed after 0.2 seconds
builder for `/gnu/store/za9r10l4qakjk7jhykl8fb80863s1smf-python2-vobject-0.8.2.drv' failed with exit code 1
@ build-failed /gnu/store/za9r10l4qakjk7jhykl8fb80863s1smf-python2-vobject-0.8.2.drv - 1 builder for `/gnu/store/za9r10l4qakjk7jhykl8fb80863s1smf-python2-vobject-0.8.2.drv' failed with exit code 1
guix build: error: build failed: build of `/gnu/store/za9r10l4qakjk7jhykl8fb80863s1smf-python2-vobject-0.8.2.drv' failed

PHOTO Property is stripped of base64 data

I have also posted this in Kozea/Radicale#648

Using vdirsyncer to send the following vcard to radicale 2.0.0 and vobject 0.9.4.1

$cat ~/.contacts/personal/dgv1qx53rhbj74q91nm0u5wansopz0xgrfex.vcf
BEGIN:VCARD
VERSION:4.0
UID:dgv1qx53rhbj74q91nm0u5wansopz0xgrfex
EMAIL;TYPE=home:[email protected]
FN:Dormire Cansado
N:Cansado;Dormire;;;
REV:20170626T215407Z
PHOTO:data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4XYsRXhpZgAATU0AKgAAAAgACQEPAAIAAAAJAAAAegEQAAIAAAAHAAAAhA......
.....98UqVKh+wnu//9k=
END:VCARD

I get this on the server:

#cat personal/dgv1qx53rhbj74q91nm0u5wansopz0xgrfex.vcf
BEGIN:VCARD
VERSION:4.0
UID:dgv1qx53rhbj74q91nm0u5wansopz0xgrfex
EMAIL;TYPE=home:[email protected]
FN:Dormire Cansado
N:Cansado;Dormire;;;
PHOTO:data:image/jpeg\;base64
REV:20170626T215407Z
END:VCARD

And of course the photo is not seen on any client synchronizing this.

This is trying to get a base64 encoded picture on a version 4.0 vcard. When I try to use a version 3.0 I hit the error in #59 and #39

Urgent pypi problem

As of today, it's now no longer possible to pip install vobject version 0.8.1c

(testenv2.7) :/tmp/testenv2.7$ pip install vobject==0.8.1c
Collecting vobject==0.8.1c
  Could not find a version that satisfies the requirement vobject==0.8.1c (from versions: 0.8.1c-dist, 0.2.3, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.5.0, 0.6.6)
No matching distribution found for vobject==0.8.1c

This has been working for many many months and suddenly it doesn't. Now, if you just do pip install vobject it works but it installs version 0.6.6. Which is ancient.

And I can't install the new file with the word "dist" in it:

(testenv2.7) :/tmp/testenv2.7$ pip install vobject==0.8.1c-dist
Collecting vobject==0.8.1c-dist
  Downloading vobject-0.8.1c-dist.tar.gz (55kB)
    100% |████████████████████████████████| 57kB 944kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/1x/2hf5hbs902q54g3bgby5bzt40000gn/T/pip-build-mmoKUh/vobject/setup.py", line 43, in <module>
        from ez_setup import use_setuptools
    ImportError: No module named ez_setup

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/1x/2hf5hbs902q54g3bgby5bzt40000gn/T/pip-build-mmoKUh/vobject

Calendar Properties should be prior to any calendar component

From https://tools.ietf.org/html/rfc5545#section-3.7:

   They SHOULD be specified after the "BEGIN:VCALENDAR"
   delimiter string and prior to any calendar component.

Unfortunately Outlook seems to ignore properties that are specified after components: Kozea/Radicale#697 (comment)

Test

import vobject
s="""\
BEGIN:VCALENDAR
X-WR-CALNAME:test
BEGIN:VEVENT
END:VEVENT
END:VCALENDAR
"""
print(vobject.readOne(s).serialize())

Result:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PYVOBJECT//NONSGML Version 1//EN
BEGIN:VEVENT
UID:20170905T152211Z - 65144@laptop
DTSTAMP:20170905T152211Z
END:VEVENT
X-WR-CALNAME:test
END:VCALENDAR

The calendar property X-WR-CALNAME is specified after the calendar component VEVENT.

j.add('org') creates a list instead of a string

When creating a 'title' entry, for exemple, j.add('title') creates an object defined as this:

j.title -> ContentLine: <TITLE{}>
j.title.value -> str: ''

But, when creating a 'org' entry, j.add('org') creates an array like this:

j.org -> ContentLine: <ORG{}['']>
j.org.value -> <class 'list'>: ['']

So, this means that doing this:
j.org.value = "My organization"
you will get this:
j.org.value -> <class 'list'>: ['M', 'y', ' ', 'o', 'r', 'g', 'a', 'n', 'i', 'z', 'a', 't', 'i', 'o', 'n']

I'm using python 3.4
vobject 0.9.4.1
IDE: LiClipse 3.3 running over Eclipse 4.6.1
OS: Debian 8.0

How to create multi-value entries for e.g. TEL?

Thanks for improving the documentation about multi-value entries (see #78, #79). When rethinking this, I found a few more places for improvement:

1. How to create multi-value entries

The example from the documentation only shows a simple entry. This is an example for adding a second entry:

>>> import vobject
>>> j = vobject.vCard()
>>> e1 = j.add('email')
>>> j.email.value = '[email protected]'  # intentionally using a different way here
>>> e2 = j.add('email')
>>> e2.value = "[email protected]"
>>> e1
<EMAIL{}[email protected]>
>>> e2
<EMAIL{}[email protected]>
>>> j.email
<EMAIL{}[email protected]>

2. How to determine if an entry is multi-valued?

According to this test, it seems that email entries (and presumable tel etc.) are always lists:

>>> k = vobject.vCard()
>>> k.add('email')
<EMAIL{}>
>>> k.contents['email'].__class__
<class 'list'>

Please documents this and also which entries are lists.

vobject chokes on '<TRIGGER{}PT>'

Parsing an event from a Zimbra server, vobject chokes on the definition of a TRIGGER as PT. PT normally would start a DURATION, but here none is specified.

Would it make sense to accept this input and interpret it as "no trigger"?

Serializing a vcard with base64 encoded picture results in: TypeError: 'str' does not support the buffer interface

While moving to Radicale 2.0.0rc which is turning to use vobject it turned out that serialization of vcards having a picture inside result in:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/usr/lib/python3.4/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 993, in defaultSerialize
    child.serialize(outbuf, lineLength, validate=False)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/usr/lib/python3.4/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 1001, in defaultSerialize
    obj.behavior.encode(obj)
  File "/usr/lib/python3.4/site-packages/vobject/vcard.py", line 154, in encode
    line.value = backslashEscape(line.value)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 1190, in backslashEscape
    s = s.replace("\\","\\\\").replace(";","\;").replace(",","\,")
TypeError: 'str' does not support the buffer interface

vcard contents:
X-MS-CARDPICTURE;TYPE=JPEG;ENCODING=BASE64:/9j/4A...
once the line is removed serialization works proper

Used Python version: 3.4

Serialize photo - AttributeError: 'bytes' object has no attribute 'encode'

Hi,

I have been using vobject 0.7.1 with python 2.7 since 2008. I am trying to update my script to python 3.5 with vobject 0.9.3.

I have a local file that I want to add to a vCard object. The enclosed code below worked in the 2.7 version but fails now.

#!/usr/bin/env python

import base64
import os
import vobject
import unittest
import urllib.request

class TestVcardPhotoSerialize(unittest.TestCase):

    def setUp(self):
        self.card=vobject.vCard()
        self.card.add('n')
        self.card.n.value=vobject.vcard.Name(family="Thecat",given="Felix")
        self.card.add('fn')
        self.card.fn.value="Felix Thecat"
        if not os.path.isfile("felix-229.png"):
            urllib.request.urlretrieve("https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Felix_the_cat.svg/229px-Felix_the_cat.svg.png","felix-229.png")

    def test_add_photo_serialize_27(self):
        """add a photo and serialize (worked with the python 2.7 version)"""
        self.card.add('photo')
        photo_fh=open("felix-229.png",'rb')
        self.card.photo.value = photo_fh.read()
        self.card.photo.encoding_param = "b"
        self.card.photo.type_param = "PNG"
        photo_fh.close()
        print(self.card.serialize())
        # AttributeError: 'bytes' object has no attribute 'encode'

if __name__ == '__main__':
    unittest.main()

Here is the log:

(ps2vcard) 172-17-96-87:ps2vcard matthew$ ./test_vcard_photo.py
EE
======================================================================
ERROR: test_add_photo_serialize_27 (__main__.TestVcardPhotoSerialize)
add a photo and serialize (worked with the python 2.7 version)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./test_vcard_photo.py", line 28, in test_add_photo_serialize_27
    print(self.card.serialize())
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/base.py", line 993, in defaultSerialize
    child.serialize(outbuf, lineLength, validate=False)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/vcard.py", line 227, in serialize
    VCardTextBehavior.serialize(obj, buf, lineLength, validate)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/base.py", line 1001, in defaultSerialize
    obj.behavior.encode(obj)
  File "/Users/matthew/Library/virtualenvs/ps2vcard/lib/python3.5/site-packages/vobject/vcard.py", line 152, in encode
    line.value = codecs.encode(line.value.encode(coding), "base64").decode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'

What's the right way to do this now?

Changed behviour in 0.9.x from unicode to str

While looking into this calypso issue in Debian:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841247

I noticed that 0.9.x returns str where 0.8 used unicode:

0.8.x:

$ python bla.py 
 <type 'unicode'>
 Universitetet i Tromsø
 <type 'unicode'>
 Forrest Gump

0.9.x:

    $ python bla.py 
    <type 'str'>
    Traceback (most recent call last):
      File "bla.py", line 11, in <module>
    print u"%s" % i.getChildValue("fn")
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128)

This is python 2.7. Code:

#!/usr/bin/python

import vobject
import codecs

path = 'tests/data/import.vcard'

o = vobject.readComponents(codecs.open(path, encoding='utf-8').read())
for i in o:
    print u"%s" % type(i.getChildValue("fn"))
    print u"%s" % i.getChildValue("fn")
    #self.import_item(new_item, path)

ics file used:

  https://github.com/agx/calypso/blob/master/tests/data/import.vcard

Is this a known regression or a desired change in behaviour?

autogenerate DTSTAMP

Feature Request:

It would be nice if vcalendar would autogenerate and insert the DTSTAMP properties when serializing like it adds PRODID and UID properties.

Absence of the DTSTAMP will make the resulting icalendar objects non-compliant and some clients won't read them properly.

How to access multi-type entries for e.g. TEL?

I could not find an example how to access and how to set multi-type entries like

TEL;TYPE=work:+49-…
TEL;TYPE=cell,work:+49-…
TEL;TYPE=fax,work:+49-…

Can you please add an example? Thanks.

Example for access multi-value entries is wrong

The example for accessing multi-value entries (see #79) is wrong. Iterating over v.contents gives the keys of the content-entries, not the content:

>>> for tel in v.contents:
...     print(tel)
... 
email
fn
tel
version
n

I assume this should read

>>> for tel in v.contents['tel']:
...    print(tel)
... 
<TEL{'TYPE': ['WORK', 'VOICE']}(111) 555-1212>
<TEL{'TYPE': ['HOME', 'VOICE']}(404) 555-1212>

Same a few lines below.

Time zone parsing error

I'm trying to generate an iCalendar string with timezone data on the dtstart element. The code runs fine when I pass in a naive python datetime object, but when I pass in datetime object with a pytz/tzinfo component, the serialize method crashes with the following error:

.../python2.7/site-packages/pytz/tzinfo.pyc in localize(self, dt, is_dst)
    325             # If we refuse to guess, raise an exception.
    326             if is_dst is None:
--> 327                 raise NonExistentTimeError(dt)
    328 
    329             # If we are forcing the pre-DST side of the DST transition, we

NonExistentTimeError: 2000-04-02 02:00:00

following the stack trace, the error occurs after vobject calls pytz during the serialize call:

.../python2.7/site-packages/vobject/icalendar.pyc in test(dt)
   1863     assert transitionTo in ('daylight', 'standard')
   1864     if transitionTo == 'daylight':
-> 1865         def test(dt): return tzinfo.dst(dt) != zeroDelta
   1866     elif transitionTo == 'standard':
   1867         def test(dt): return tzinfo.dst(dt) == zeroDelta

This smells like a bug in the internal implementation to me, especially since the datetime returned in the error is over 15 years removed from the dates I'm working with.

Python 3 compatibility

Installation fails on Python 3:

$ pip install vobject
Collecting vobject
  Downloading vobject-0.6.6.tar.gz (53kB)
    100% |████████████████████████████████| 57kB 3.0MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-rcah3vyp/vobject/setup.py", line 31, in <module>
        from ez_setup import use_setuptools
      File "/tmp/pip-build-rcah3vyp/vobject/ez_setup/__init__.py", line 94
        except pkg_resources.VersionConflict, e:
                                            ^
    SyntaxError: invalid syntax

AttributeError: 'datetime.date' object has no attribute 'tzinfo'

Hi, I get the exception below from inside 'radical' during parsing a ical file. A DTSTAMP value is parsed as datetime.date, but later vobject accesses the tzinfo attribute. tzinfo is only available for datetime-objects with a time component.

File ".local/lib/python3.4/site-packages/vobject/base.py", line 1125, in readComponents
     component.transformChildrenToNative()
File ".local/lib/python3.4/site-packages/vobject/base.py", line 674, in transformChildrenToNative
     child.transformChildrenToNative()
File ".local/lib/python3.4/site-packages/vobject/base.py", line 673, in transformChildrenToNative
     child = child.transformToNative()
File ".local/lib/python3.4/site-packages/vobject/base.py", line 198, in transformToNative
     raise ParseError(msg, lineNumber)
 vobject.base.ParseError: At line 8: In transformToNative, unhandled exception on line 8: <class 'AttributeError'>: 'datetime.date' object has no attribute 'tzinfo' (<DTSTAMP{'VALUE': ['DATE']}20170916>)```

Attribute access to multi-value entries should give a list

Currently attribute access to multi-value entries always return a single entry.

>>> j = vobject.vCard()
>>> j.add('email').value = '[email protected]'
>>> j.add('email').value = "[email protected]"
>>> j.email
<EMAIL{}[email protected]>

While this is convenient if a vCard contains a single e-mail-address (or tel, etc.), this is gives a wrong notion about what these entries are. Esp. this leads to an asymmetric behavior, since for accessing a entries, one needs to use a completely different way to access:

>>> v.fn
<FN{}Jeffrey Harris>
>>> v.tel
<TEL{'TYPE': ['WORK', 'VOICE']}(111) 555-1212>
>>> v.contents['tel']
[<TEL{'TYPE': ['WORK', 'VOICE']}(111) 555-1212>, <TEL{'TYPE': ['HOME', 'VOICE']}(404) 555-1212>]

What would you expect

I'd expect the tel attribute (and email, etc.) to return a list:

>>> v.tel
[<TEL{'TYPE': ['WORK', 'VOICE']}(111) 555-1212>, <TEL{'TYPE': ['HOME', 'VOICE']}(404) 555-1212>]

Return children as unicode

I'm trying this:

from StringIO import StringIO
import caldav
import datetime
import vobject

client = caldav.DAVClient(
            url='http://teste.com',
            proxy=None,
            username='username',
            password='password')
url = 'http://url.calendar'
calendar = caldav.objects.Calendar(client=client, url=url)
events = calendar.date_search(datetime.datetime(2016, 4, 7, 0, 0),
                              datetime.datetime(2016, 4, 7, 20, 59, 59))
for event in events:
    data = event._data
    g2 = StringIO(data)
    cal = vobject.readOne(g2.read())
    vevent = cal.vevent
    summary = vevent.getChildValue('summary', '')

The variable summary is always string. It would be nice if I could choose for all children be unicode.

Failing unit-tests

When trying to update the package on Fedora, I ran into this error in the test suite:

======================================================================
FAIL: test_general_behavior (tests.TestBehaviors)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/vobject-0.9.4.1/tests.py", line 225, in test_general_behavior
    'VTIMEZONE', 'VTODO']
AssertionError: Lists differ: ['', [234 chars]Y', 'HCALENDAR', 'LABEL', 'LAST-MODIFIED', 'LO[291 chars]ODO'] != ['', [234 chars]Y', 'LABEL', 'LAST-MODIFIED', 'LOCATION', 'MET[278 chars]ODO']
First differing element 23:
'HCALENDAR'
'LABEL'
First list contains 1 additional elements.
First extra element 52:
'VTODO'
Diff is 740 characters long. Set self.maxDiff to None to see it.

The full log is available there: https://kojipkgs.fedoraproject.org//work/tasks/7622/17427622/build.log

Would you have an idea of what is going on?

Thanks :)

Parsing Error in "ATTENDEE" line

Hi, the following link fails to parse:

vobject.base.ParseError: At line 12: Failed to parse line:
ATTENDEE;RSVP=TRUE;CN=John Doe;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;SCHEDULE-STATUS="3.7;Invalid Calendar User";INVALID CALENDAR USER":mailto:[email protected]

VCard: Parse Error with multiline list-type notes

I categorize my contacts via VCard's notes field. I enter them as lists, such as:

- List1
- List2
- List3

When I enter such a VCard, it will fail to parse:

VCARD:

s = """
BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//Mac OS X 10.11.3//EN
N:XXX;;;
FN:XX XX
EMAIL;type=INTERNET;type=HOME;type=pref:[email protected]
TEL;type=CELL;type=VOICE;type=pref:+4915773321986
ADR;type=HOME;type=pref:;;;Berlin;Berlin;;Germany
BDAY:1986-11-17
UID:e0355606-117f-4388-bb6d-eda3a1f6449d
X-ABUID:E0355606-117F-4388-BB6D-EDA3A1F6449D:ABPerson
NOTE:- List1\n- List2 \n- List3
END:VCARD
"""

COMMAND:

from vobject import vCard, readOne
v = readOne(s)

ERROR:

---------------------------------------------------------------------------
ParseError                                Traceback (most recent call last)
<ipython-input-21-61222ae13dcb> in <module>()
----> 1 v = readOne(s)

/usr/local/lib/python3.5/site-packages/vobject/base.py in readOne(stream, validate, transform, ignoreUnreadable, allowQP)
   1096     """
   1097     return next(readComponents(stream, validate, transform, ignoreUnreadable,
-> 1098                                allowQP))
   1099 
   1100 

/usr/local/lib/python3.5/site-packages/vobject/base.py in readComponents(streamOrString, validate, transform, ignoreUnreadable, allowQP)
   1040                     continue
   1041             else:
-> 1042                 vline = textLineToContentLine(line, n)
   1043             if vline.name == "VERSION":
   1044                 versionLine = vline

/usr/local/lib/python3.5/site-packages/vobject/base.py in textLineToContentLine(text, n)
    880 
    881 def textLineToContentLine(text, n=None):
--> 882     return ContentLine(*parseLine(text, n), **{'encoded':True,
    883                                                'lineNumber' : n})
    884 

/usr/local/lib/python3.5/site-packages/vobject/base.py in parseLine(line, lineNumber)
    769     match = line_re.match(line)
    770     if match is None:
--> 771         raise ParseError("Failed to parse line: {0!s}".format(line), lineNumber)
    772     # Underscores are replaced with dash to work around Lotus Notes
    773     return (match.group('name').replace('_','-'),

ParseError: At line 14: Failed to parse line: - List2 

Parser fails with non ASCII characters in TZNAME

The following will raise an exception:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vobject

vcard = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ddaysoftware.com//NONSGML DDay.iCal 1.0//EN
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:19701002T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=3;BYMINUTE=0;BYMONTH=10
TZNAME:Mitteleuropäische Zeit
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700301T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3
TZNAME:Mitteleuropäische Sommerzeit
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
CLASS:PUBLIC
DTEND;VALUE=DATE:20160303
DTSTAMP:20160301T120402Z
DTSTART;VALUE=DATE:20160302
PRIORITY:5
SEQUENCE:0
SUMMARY:Termin aus Outlook
TRANSP:TRANSPARENT
UID:d26f530f-1d5d-46c9-ac39-264a24276357
END:VEVENT
END:VCALENDAR
"""

# This makes the card parsable
# vcard = vcard.replace('Mitteleuropäische Sommerzeit', 'CET')
# vcard = vcard.replace('Mitteleuropäische Zeit', 'CET')

print vcard

vobject.readOne(vcard)

Unable to parse ics file

Im new to python and I am unable to parse the following ics file

If I manually remove the VTIMEZONE section it works. Seems to have something to do with DTSTART

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TEST//TEST//EN
BEGIN:VTIMEZONE
TZID:UTC+11
BEGIN:STANDARD
DTSTART;VALUE=DATE:20170101
TZNAME:UTC+11
TZOFFSETFROM:+1100
TZOFFSETTO:+1100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:TESTING
DTEND;TZID=UTC+11:20170228T233000
DTSTAMP:20170227T064302Z
DTSTART;TZID=UTC+11:20170228T230000
RESOURCES:Court 4
SEQUENCE:0
STATUS:Confirmed
SUMMARY:TESTIN
UID:1961094_636238800000000000
END:VEVENT
END:VCALENDAR

VCARD components cannot contain more than 1 FN despite Specification

According to the vCard Format Specification (RFC 6350), the FN identification property has a carnality of 1* --that is 1 or more. However, if I add more than 1, I cannot add a value for the second FN and attempting to serialize it produces the object.base.ValidateError message which gives name to this issue.

Question: What Python type is parsed VCard? Custom dictionary?

When I parse a VCard via v = readOne(s)- of course after defining the VCard (see below) and importing the right module via from vobject import vCard, readOne, I get an object that I have no clue what Python type it is.

v.contents looks a lot like a dictionary, but I do not understand what the <XXX parts in it mean.

V.CONTENTS

{'adr': [<ADR{'TYPE': ['HOME', 'pref']}
  Berlin, Berlin 
  Germany>],
 'bday': [<BDAY{}1986-11-17>],
 'email': [<EMAIL{'TYPE': ['INTERNET', 'HOME', 'pref']}[email protected]>],
 'fn': [<FN{}XX XX>],
 'n': [<N{}   XXX >],
 'prodid': [<PRODID{}-//Apple Inc.//Mac OS X 10.11.3//EN>],
 'tel': [<TEL{'TYPE': ['CELL', 'VOICE', 'pref']}+4915773321986>],
 'uid': [<UID{}e0355606-117f-4388-bb6d-eda3a1f6449d>],
 'version': [<VERSION{}3.0>],
 'x-abuid': [<X-ABUID{}E0355606-117F-4388-BB6D-EDA3A1F6449D:ABPerson>]}

VCARD

s = """
BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//Mac OS X 10.11.3//EN
N:XXX;;;
FN:XX XX
EMAIL;type=INTERNET;type=HOME;type=pref:[email protected]
TEL;type=CELL;type=VOICE;type=pref:+4915773321986
ADR;type=HOME;type=pref:;;;Berlin;Berlin;;Germany
BDAY:1986-11-17
UID:e0355606-117f-4388-bb6d-eda3a1f6449d
X-ABUID:E0355606-117F-4388-BB6D-EDA3A1F6449D:ABPerson
END:VCARD
"""

vcard encoding error: KeyError: 'ENCODING'

Found in case of QUOTED-PRINTABLE vcards:

2016-10-16 20:01:22,601 - [7f3062f17700] ERROR: Exception details:
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/radicale/storage.py", line 760, in get
    item = vobject.readOne(text)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 1130, in readOne
    allowQP))
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 1074, in readComponents
    vline = textLineToContentLine(line, n)
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 913, in textLineToContentLine
    'lineNumber' : n})
  File "/usr/lib/python3.4/site-packages/vobject/base.py", line 337, in __init__
    self.value = codecs.decode(self.value.encode("utf-8"), "quoted-printable").decode(self.params['ENCODING'])
KeyError: 'ENCODING'

Example:
LABEL;HOME;PREF;ENCODING=QUOTED-PRINTABLE:ABCstr. 22=0D=0A=0D=0A12345 Ort

There is a bug in the coding sequence:

        qp = False
        if 'ENCODING' in self.params:
            if 'QUOTED-PRINTABLE' in self.params['ENCODING']:
                qp = True
                self.params['ENCODING'].remove('QUOTED-PRINTABLE')
                if 0==len(self.params['ENCODING']):
                    del self.params['ENCODING']
        if 'QUOTED-PRINTABLE' in self.singletonparams:
            qp = True
            self.singletonparams.remove('QUOTED-PRINTABLE')
        if qp:
            self.value = codecs.decode(self.value.encode("utf-8"), "quoted-printable").decode(self.params['ENCODING'])

"If qp" is reached in case of QUOTED-PRINTABLE, self.params['ENCODING'] is not always filled

RDATE not working: getrruleset returns empty generator

If RDATE is used, getrruleset returns an empty generator.

Example:

import vobject
s="""\
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
BEGIN:VTIMEZONE
TZID:Europe/Paris
BEGIN:STANDARD
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:event
DTSTART;TZID=Europe/Paris:20170601T080000
DTEND;TZID=Europe/Paris:20170601T090000
CREATED:20170601T060000Z
DTSTAMP:20170601T060000Z
LAST-MODIFIED:20170601T060000Z
RDATE;TZID=Europe/Paris:20170701T080000
SUMMARY:event
TRANSP:OPAQUE
X-MOZ-GENERATION:1
END:VEVENT
END:VCALENDAR"""
o = vobject.readOne(s)
r = o.vevent.getrruleset(addRDate=True)
print(list(r))

Output: []

About RFC and `add()`

Hello,

  1. Does this library support vCard-generation with all the options/details found here: RFC ?

  2. Can all the options for the add function be added to the documentation? I see a number of the options here: link, but it would be helpful to be able to reference all the options for add via the documentation.

prints to standard out on invalid timezone

vobject currently prints to standard out when it encounters an invalid timezone. It would be great if it could e.g. use a logger instead so the message could be silenced.

Serializing iCalendar throws NonExistentTimeError when using pytz timezones

Are pytz timezones meant to be supported for event times when generating an iCalendar?
(This is probably the same as the original issue reported in #18.)

The code below throws a pytz.NonExistentTimeError in the serialize call, while attempting to automatically generate the VTIMEZONE block for TZID=America/Los_Angeles:

from datetime import datetime
import vobject
import pytz

ical = vobject.iCalendar()
vevent = ical.add('vevent')
vevent.add('dtstart').value = datetime(
    2016, 5, 26, 14, 30, tzinfo=pytz.timezone("America/Los_Angeles"))
ical.serialize()  # NonExistentTimeError: 2000-04-02 02:00:00

If not, would pytz support be a reasonable addition to propose? (It seems to be Django's preferred tz source.) Or is there a strong preference for dateutil timezones with vobject?

Python 2.7.11; vobject==0.9.2; python-dateutil==2.5.3; six==1.10.0; pytz==2016.4

Traceback (most recent call last):
  File "...lib/python2.7/site-packages/vobject/base.py", line 254, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "...lib/python2.7/site-packages/vobject/behavior.py", line 152, in serialize
    cls.generateImplicitParameters(obj)
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 921, in generateImplicitParameters
    obj.add(TimezoneComponent(tzinfo=getTzid(tzid)))
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 97, in __init__
    self.tzinfo = tzinfo
  File "...lib/python2.7/site-packages/vobject/base.py", line 542, in __setattr__
    prop.fset(self, value)
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 171, in settzinfo
    transition = getTransition(transitionTo, year, tzinfo)
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 1878, in getTransition
    uncorrected = firstTransition(generateDates(year, month, day), test)
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 1836, in firstTransition
    if not test(dt):
  File "...lib/python2.7/site-packages/vobject/icalendar.py", line 1865, in test
    def test(dt): return tzinfo.dst(dt) != zeroDelta
  File "...lib/python2.7/site-packages/pytz/tzinfo.py", line 447, in dst
    dt = self.localize(dt, is_dst)
  File "...lib/python2.7/site-packages/pytz/tzinfo.py", line 327, in localize
    raise NonExistentTimeError(dt)
NonExistentTimeError: 2000-04-02 02:00:00

unsupported DTSTART parm: VALUE=DATE-TIME

Unable to parse ICS file, below, it is a recurring event, generated with android's calendar app. Using vobject version 0.9.2 from pip.

cal =`vobject.readOne(data)

Trackback

Traceback (most recent call last):
  File "/home/.../main.py", line 17, in <module>
    cal = vobject.readOne(data)
  File "/usr/local/lib/python2.7/dist-packages/vobject/base.py", line 1129, in readOne
    allowQP))
  File "/usr/local/lib/python2.7/dist-packages/vobject/base.py", line 1101, in readComponents
    component.transformChildrenToNative()
  File "/usr/local/lib/python2.7/dist-packages/vobject/base.py", line 660, in transformChildrenToNative
    child = child.transformToNative()
  File "/usr/local/lib/python2.7/dist-packages/vobject/base.py", line 196, in transformToNative
    raise ParseError(msg, lineNumber)
vobject.base.ParseError: "In transformToNative, unhandled exception on line None: <type 'exceptions.ValueError'>: unsupported DTSTART parm: VALUE=DATE-TIME"

ICS Source

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VTIMEZONE
TZID:Europe/London
BEGIN:DAYLIGHT
DTSTART;VALUE=DATE-TIME:20160327T020000
TZNAME:BST
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
END:DAYLIGHT
BEGIN:STANDARD
DTSTART;VALUE=DATE-TIME:20161030T010000
TZNAME:GMT
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Supervisor Meeting
DTSTART;TZID=Europe/London;VALUE=DATE-TIME:20160623T110000
DTEND;TZID=Europe/London;VALUE=DATE-TIME:20160623T120000
DTSTAMP;VALUE=DATE-TIME:20160621T141052Z
UID:6HJBFNNANM7HBTHEMV1TW52RLFWLTBTV44JN
RRULE:FREQ=WEEKLY
END:VEVENT
END:VCALENDAR

Decode error in vcard.py line 139 with python 3.x

Hi,

line 139 in vard.py needs changes.

133         if line.encoded:
134             if 'BASE64' in line.singletonparams:
135                 line.singletonparams.remove('BASE64')
136                 line.encoding_param = cls.base64string
137             encoding = getattr(line, 'encoding_param', None)
138             if encoding:

139                 line.value = base64.b64decode(line.value)

140             else:
141                 line.value = stringToTextValues(line.value)[0]
142             line.encoded=False

I do not know, if this is ok for python 2.7 as well. So I did not make a PR here.

The error is that "str" dows not have an attribute "decode"

Parsing error: X-ALT-DESC with HTML

Parsing the enclosed event error1.txt fails with vobject.base.ParseError: At line 248: Failed to parse line: <HTML>. Relevant part is:

SEQUENCE:0
TRANSP:OPAQUE
X-ALT-DESC:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
…

Yes, the continuation lines are not indented.

vcard objects don't format datetime objects for serialisation

Hi,
When trying to serialise() a card with a date time for BDAY I'm seeing a validation error. prettyPrint works quite fine.
I had a look in git but only see reference to BDAY in the test corpus.
https://github.com/eventable/vobject/blob/master/vobject/vcard.py
http://eventable.github.io/vobject/ mentions that using date time objects works, does that refer specifically to the calendar side?

Example output from pretty print (yes, real information replaced):

 VCARD
    BDAY: 1999-01-25 00:00:00
    NOTE: Imported from N900 via awful mangling script
    REV: 2017-08-26 11:15:36.637242
    FN: Karl Goetz
    N:  Karl Goetz   

Error from serialise

(n900-migrations) Karls-Air:.calendar kgoetz$ python migrate_calendar.py 
Traceback (most recent call last):
  File "migrate_calendar.py", line 196, in <module>
    export_to_vcard(current_data)
  File "migrate_calendar.py", line 184, in export_to_vcard
    print card.serialize()
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/base.py", line 254, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/behavior.py", line 166, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/base.py", line 1007, in defaultSerialize
    child.serialize(outbuf, lineLength, validate=False)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/base.py", line 254, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/behavior.py", line 166, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/base.py", line 1015, in defaultSerialize
    obj.behavior.encode(obj)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/vcard.py", line 161, in encode
    line.value = backslashEscape(line.value)
  File "/Users/kgoetz/virtualenvs/n900-migrations/lib/python2.7/site-packages/vobject/base.py", line 1216, in backslashEscape
    s = s.replace("\\", "\\\\").replace(";", "\;").replace(",", "\,")
TypeError: an integer is required

Update:
I realised I hadn't included any code.

def export_to_vcard(data):
  """Take data from sqlite and convert it to a vcard file"""
  # data is a list.
  card = vobject.vCard()
  card.add('fn')
  card.fn.value = data[6] # string
  card.add('bday')
  card.bday.value = data[4] # date time object
  card.add('note')
  card.note.value = 'Imported from N900 via awful mangling script'
  card.add('rev')
  card.rev.value = datetime.datetime.now()
  print card.serialize()

repeated serialization of vcard corrupts organization value

Repeated serialization of a card corrupts the organization value of a vcard as there appears to be a missing line in OrgBehavior.transformToNative

I would have expected

obj.value = splitFields(obj.value) 

before

obj.isNative = True
return obj

The difference in results with the line added can be seen below:
BEFORE

one: 
BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:Company X;Division Y;Business Unit Z
END:VCARD

two:
 BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:C;o;m;p;a;n;y; ;X;\;;D;i;v;i;s;i;o;n; ;Y;\;;B;u;s;i;n;e;s;s; ;U;n;i;t; 
 ;Z
END:VCARD

three
BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:C;\;;o;\;;m;\;;p;\;;a;\;;n;\;;y;\;; ;\;;X;\;;\\;\;;\;;D;\;;i;\;;v;\;;i;
 \;;s;\;;i;\;;o;\;;n;\;; ;\;;Y;\;;\\;\;;\;;B;\;;u;\;;s;\;;i;\;;n;\;;e;\;;s;
 \;;s;\;; ;\;;U;\;;n;\;;i;\;;t;\;; ;\;;Z
END:VCARD

AFTER

one: 
BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:Company X;Division Y;Business Unit Z
END:VCARD

two:
BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:Company X;Division Y;Business Unit Z
END:VCARD

three
BEGIN:VCARD
VERSION:3.0
FN:Bar\, Foo
N:Bar;Foo;;;
ORG:Company X;Division Y;Business Unit Z
END:VCARD

python crash after typing cal = vobject.iCalendar()

I've downloaded this and run the setup and tests. I get this after running python tests.py:
.............vobject.base ERROR Skipped line 6, message: At line 6: Failed to parse line: X-BAD/SLASH:TRUE

.......................

Ran 36 tests in 0.263s

OK

If I try a very basic item:

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import vobject
cal = vobject.iCalendar()
Segmentation fault: 11

I get a crash right away. I'm assuming it has something to do with the failed test?
Has anyone seen this before? Any idea what I do to fix this?

Do you need help with maintenance?

It appears that this library contains some super-critical bugs such as #51, though PRs take a long time to get merged. Do you need help with maintaining this library?

KeyError: 'ENCODING'

Recent changes mean some vcf files now fail to parse

[Sun Sep 04 17:15:29.244163 2016] [wsgi:error] [pid 24799] Traceback (most recent call last):
[Sun Sep 04 17:15:29.244206 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/calypso/calypso/webdav.py", line 270, in insert_file
[Sun Sep 04 17:15:29.244245 2016] [wsgi:error] [pid 24799]     item = self.read_file(path)
[Sun Sep 04 17:15:29.244283 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/calypso/calypso/webdav.py", line 265, in read_file
[Sun Sep 04 17:15:29.244335 2016] [wsgi:error] [pid 24799]     item = Item(text, None, path, self.urlpath)
[Sun Sep 04 17:15:29.244375 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/calypso/calypso/webdav.py", line 80, in **init**
[Sun Sep 04 17:15:29.244412 2016] [wsgi:error] [pid 24799]     self.object = vobject.readOne(text)
[Sun Sep 04 17:15:29.244451 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/vobject/vobject/base.py", line 1130, in readOne
[Sun Sep 04 17:15:29.244494 2016] [wsgi:error] [pid 24799]     allowQP))
[Sun Sep 04 17:15:29.244523 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/vobject/vobject/base.py", line 1074, in readComponents
[Sun Sep 04 17:15:29.244548 2016] [wsgi:error] [pid 24799]     vline = textLineToContentLine(line, n)
[Sun Sep 04 17:15:29.244571 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/vobject/vobject/base.py", line 913, in textLineToContentLine
[Sun Sep 04 17:15:29.244595 2016] [wsgi:error] [pid 24799]     'lineNumber' : n})
[Sun Sep 04 17:15:29.244619 2016] [wsgi:error] [pid 24799]   File "/home/jelmer/vobject/vobject/base.py", line 337, in **init**
[Sun Sep 04 17:15:29.244643 2016] [wsgi:error] [pid 24799]     self.value = codecs.decode(self.value.encode("utf-8"), "quoted-printable").decode(self.params['ENCODING'])
KeyError: 'ENCODING'

This makes sense when reading the code. In base.py:330, if 'ENCODING' is set to just 'QUOTED-PRINTABLE', that item is first removed from the list and then 'ENCODING' itself is removed because it is empty.

tests.py missing in pypi distfile

README.md explains that to run the tests one should call python tests.py, but tests.py is missing from the pypi distfile. Please add it.

RRULE: Gracefully handle offset-naive and offset-aware datetimes

The following code fails with TypeError: can't compare offset-naive and offset-aware datetimes.

event = """
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART;VALUE=DATE:20130117
DTEND;VALUE=DATE:20130118
RRULE:FREQ=WEEKLY;UNTIL=20130330T230000Z;BYDAY=TH
SUMMARY:Meeting
END:VEVENT
END:VCALENDAR
""".strip()

import vobject

ev = vobject.readOne(event).vevent
ev.getrruleset(addRDate=True)

Traceback:

  File "…/site-packages/vobject/icalendar.py", line 501, in getrruleset
    if rruleset._rrule[-1][0] != adddtstart:
  File "…site-packages/dateutil/rrule.py", line 159, in __getitem__
    res = advance_iterator(gen)
  File "…/site-packages/dateutil/rrule.py", line 860, in _iter
    if until and res > until:
TypeError: can't compare offset-naive and offset-aware datetimes

Actual values are:

  • res = datetime.datetime(2013, 1, 17, 0, 0) from DTSTART;VALUE=DATE:20130117
  • until = datetime.datetime(2013, 3, 30, 23, 0, tzinfo=tzutc()) from RRULE:FREQ=WEEKLY;UNTIL=20130330T230000Z;BYDAY=TH

ics_diff doesn't work under py3

I get this stack trace:

Traceback (most recent call last):
  File "/home/luc/.local/bin/ics_diff", line 11, in <module>
    load_entry_point('vobject==0.9.4.1', 'console_scripts', 'ics_diff')()
  File "/home/luc/.local/lib/python3.6/site-packages/vobject/ics_diff.py", line 194, in main
    cal1 = readOne(file(ics_file1))
NameError: name 'file' is not defined

As you can see I am useing python3.6 and vobject 0.9.4.1 (installed with pip).

Serializing of vcard with base64 encoded attribute still fails

The recent vobject release 0.9.3 fixed the base64 encoding error during import of a vcard file. But the
export of that same file still fails with the following error message:

Traceback (most recent call last):
  [...]
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/khard-0.11.2-py3.5.egg/khard/carddav_object.py", line 1414, in write_to_file
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/base.py", line 993, in defaultSerialize
    child.serialize(outbuf, lineLength, validate=False)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/base.py", line 255, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/vcard.py", line 227, in serialize
    VCardTextBehavior.serialize(obj, buf, lineLength, validate)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/behavior.py", line 162, in serialize
    out = base.defaultSerialize(transformed, buf, lineLength)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/base.py", line 1001, in defaultSerialize
    obj.behavior.encode(obj)
  File "/home/eric/.virtualenvs/khard/lib/python3.5/site-packages/vobject/vcard.py", line 152, in encode
    line.value = codecs.encode(line.value.encode(coding), "base64").decode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'

I get new lines within the url (maybe if they are too long)

Hi,

I use vobject to generate vCards for persons on a website.
Each person has its own detail page which is located for example on

https://example.org/about-us/our-team/firstname-lastname

but this example is a short one, I have one url with a length of 84 chars for a person where I experience this behaviour.

I have proved the generated strings again and again but the new line appears only in the output string of the serialize function. Even the value field of the url list item of the vobject does not have new lines.

The whole part after the new line is ignored and the url does not work

Wrong offsets applied when PyTZ timezones are used

When vobject is used with the PyTZ database of time zones, parsing of date lines yields the wrong time offset. This is because the PyTZ timezones actually are collections of offsets with different validity according to the Olson DB.

vobject directly calls the datetime.datetime constructor which does not know about these subtleties. A line

DTSTART;TZID=Europe/Berlin:20160924T222000

leads to the equivalent of

datetime(2016,9,24,22,20, tzinfo=pytz.timezone('Europe/Berlin'))

that actually yields

2016-09-24 22:20:00+00:53

because the historically first time zone (Berlin local time, valid until March 1893) is used instead of the current one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.