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

Fix import and agendaupdate to handle encoding errors more gracefully #705

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v4.4.0
* Fix lots of bugs by switching from deprecaetd oauth2client to
* Fix lots of bugs by switching from deprecated oauth2client to
google_auth_oauthlib
* Handle encoding/decoding errors more gracefully by replacing with
placeholder chars instead of blowing up
* Fix `--lineart` option failing with unicode errors
* `quick` command now prompts for which calendar to use when ambiguous
* Fix --nodeclined option failing on events with aliased email
Expand Down
10 changes: 8 additions & 2 deletions gcalcli/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ def get_argument_parser():
help='update calendar from agenda TSV file',
description='Update calendar from agenda TSV file.')
agendaupdate.add_argument(
'file', type=argparse.FileType('r'), nargs='?', default=sys.stdin)
'file',
type=argparse.FileType('r', errors='replace'),
nargs='?',
default=sys.stdin)

sub.add_parser(
'updates',
Expand Down Expand Up @@ -395,7 +398,10 @@ def get_argument_parser():
'must be specified. Reads from stdin when no file argument is '
'provided.')
_import.add_argument(
'file', type=argparse.FileType('r'), nargs='?', default=None)
'file',
type=argparse.FileType('r', errors='replace'),
nargs='?',
default=None)
_import.add_argument(
'--verbose', '-v', action='count', help='Be verbose on imports')
_import.add_argument(
Expand Down
6 changes: 1 addition & 5 deletions tests/test_gcalcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from json import load
import re

import pytest
from dateutil.tz import tzutc

from gcalcli.argparsers import (
Expand Down Expand Up @@ -274,14 +273,11 @@ def test_modify_event(PatchedGCalI):
gcal._edit_event, opts.text, opts.start, opts.end) == 0


@pytest.mark.skipif(
os.name == 'nt',
reason='Known unicode encode/decode issue, see insanum/gcalcli#387.')
def test_import(PatchedGCalI):
cal_names = parse_cal_names(['[email protected]'])
gcal = PatchedGCalI(cal_names=cal_names, default_reminders=True)
vcal_path = TEST_DATA_DIR + '/vv.txt'
assert gcal.ImportICS(icsFile=open(vcal_path))
assert gcal.ImportICS(icsFile=open(vcal_path, errors='replace'))


def test_parse_reminder():
Expand Down
Loading