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

Use logging instead of printing to stdout. #35

Merged
merged 2 commits into from
Aug 26, 2016
Merged
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
25 changes: 14 additions & 11 deletions vobject/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from __future__ import print_function

import codecs
import datetime
import logging
import random # for generating a UID
import six
import socket
import string
import codecs

from dateutil import rrule, tz
import six

try:
import pytz
Expand All @@ -29,8 +30,8 @@ class NonExistentTimeError(Exception):

from . import behavior
from .base import (VObjectError, NativeError, ValidateError, ParseError,
Component, ContentLine, logger, registerBehavior,
backslashEscape, foldOneLine, str_)
Component, ContentLine, logger, registerBehavior,
backslashEscape, foldOneLine, str_)


# ------------------------------- Constants ------------------------------------
Expand Down Expand Up @@ -76,9 +77,9 @@ def getTzid(tzid, smart=True):
tz = timezone(tzid)
registerTzid(toUnicode(tzid), tz)
except UnknownTimeZoneError as e:
print("Error: {0}".format(e))
logging.error(e)
except ImportError as e:
print("Error: {0}".format(e))
logging.error(e)
return tz

utc = tz.tzutc()
Expand Down Expand Up @@ -428,11 +429,11 @@ def getrruleset(self, addRDate = False):
dtstart = self.due.value
else:
# if there's no dtstart, just return None
print('failed to get dtstart with VTODO')
logging.error('failed to get dtstart with VTODO')
return None
except (AttributeError, KeyError):
# if there's no due, just return None
print('failed to find DUE at all.')
logging.error('failed to find DUE at all.')
return None

# a Ruby iCalendar library escapes semi-colons in rrules,
Expand Down Expand Up @@ -1646,7 +1647,7 @@ def error(msg):
if strict:
raise ParseError(msg)
else:
print(msg)
logging.error(msg)

# vars which control state machine
charIterator = enumerate(s)
Expand Down Expand Up @@ -1698,7 +1699,8 @@ def error(msg):

else:
state = "error"
error("error: unknown state: '{0!s}' reached in {1!s}".format(state, s))
error("unknown state: '{0!s}' reached in {1!s}".format(state, s))


def stringToDurations(s, strict=False):
"""
Expand Down Expand Up @@ -1815,7 +1817,8 @@ def error(msg):

else:
state = "error"
error("error: unknown state: '{0!s}' reached in {1!s}".format(state, s))
error("unknown state: '{0!s}' reached in {1!s}".format(state, s))


def parseDtstart(contentline, allowSignatureMismatch=False):
"""
Expand Down