@@ -13,10 +13,13 @@ def is_naive(dt):
1313 """Determines if a given datetime.datetime is naive."""
1414 return dt .tzinfo is None or dt .tzinfo .utcoffset (dt ) is None
1515
16+
1617def total_seconds (delta ):
1718 """Determines total seconds with python < 2.7 compat."""
1819 # http://stackoverflow.com/questions/3694835/python-2-6-5-divide-timedelta-with-timedelta
19- return (delta .microseconds + (delta .seconds + delta .days * 24 * 3600 ) * 1e6 ) / 1e6
20+ return (delta .microseconds
21+ + (delta .seconds + delta .days * 24 * 3600 ) * 1e6 ) / 1e6
22+
2023
2124def guess_timezone (dt ):
2225 """Attempts to convert a naive datetime to an aware datetime."""
@@ -34,11 +37,13 @@ def guess_timezone(dt):
3437
3538 return dt
3639
40+
3741def remove_trailing_slash (host ):
3842 if host .endswith ('/' ):
39- return host [:- 1 ]
43+ return host [:- 1 ]
4044 return host
4145
46+
4247def clean (item ):
4348 if isinstance (item , Decimal ):
4449 return float (item )
@@ -52,9 +57,11 @@ def clean(item):
5257 else :
5358 return _coerce_unicode (item )
5459
60+
5561def _clean_list (list_ ):
5662 return [clean (item ) for item in list_ ]
5763
64+
5865def _clean_dict (dict_ ):
5966 data = {}
6067 for k , v in six .iteritems (dict_ ):
@@ -68,6 +75,7 @@ def _clean_dict(dict_):
6875 )
6976 return data
7077
78+
7179def _coerce_unicode (cmplx ):
7280 try :
7381 item = cmplx .decode ("utf-8" , "strict" )
@@ -76,6 +84,4 @@ def _coerce_unicode(cmplx):
7684 item .decode ("utf-8" , "strict" )
7785 log .warning ('Error decoding: %s' , item )
7886 return None
79- except :
80- raise
8187 return item
0 commit comments