Skip to content

Commit

Permalink
Turn exceptions from invalid dates into squelchable warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed Jul 2, 2012
1 parent b16abd5 commit fc8e6d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='tmdb3',
version='0.6.5',
version='0.6.6',
description='TheMovieDB.org APIv3 interface',
long_description="Object-oriented interface to TheMovieDB.org's v3 API.",
packages=['tmdb3']
Expand Down
16 changes: 14 additions & 2 deletions tmdb3/tmdb_api.py
Expand Up @@ -22,7 +22,7 @@
Preliminary API specifications can be found at
http://help.themoviedb.org/kb/api/about-3"""

__version__="v0.6.5"
__version__="v0.6.6"
# 0.1.0 Initial development
# 0.2.0 Add caching mechanism for API queries
# 0.2.1 Temporary work around for broken search paging
Expand All @@ -48,6 +48,7 @@
# 0.6.3 Add Studio search
# 0.6.4 Add Genre list and associated Movie search
# 0.6.5 Prevent data from being blanked out by subsequent queries
# 0.6.6 Turn date processing errors into mutable warnings

from request import set_key, Request
from util import Datapoint, Datalist, Datadict, Element, NameRepr, SearchRepr
Expand All @@ -64,7 +65,18 @@
DEBUG = False

def process_date(datestr):
return datetime.date(*[int(x) for x in datestr.split('-')])
try:
return datetime.date(*[int(x) for x in datestr.split('-')])
except TypeError:
import sys
import warnings
import traceback
_,_,tb = sys.exc_info()
f,l,_,_ = traceback.extract_tb(tb)[-1]
warnings.warn_explicit(('"{0}" is not a supported date format. '
'Please fix upstream data at http://www.themoviedb.org.')\
.format(datestr), Warning, f, l)
return None

class Configuration( Element ):
images = Datapoint('images')
Expand Down

0 comments on commit fc8e6d1

Please sign in to comment.