Skip to content

Commit

Permalink
Remove dead utils code
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jan 8, 2019
1 parent 4725366 commit d9bcc48
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
2 changes: 0 additions & 2 deletions marshmallow/compat.py
Expand Up @@ -13,7 +13,6 @@
urlparse = urlparse
text_type = unicode
binary_type = str
string_types = (str, unicode)
unicode = unicode
basestring = basestring
iterkeys = lambda d: d.iterkeys()
Expand All @@ -27,7 +26,6 @@
urlparse = urllib.parse
text_type = str
binary_type = bytes
string_types = (str,)
unicode = str
basestring = (str, bytes)
iterkeys = lambda d: d.keys()
Expand Down
34 changes: 0 additions & 34 deletions marshmallow/utils.py
Expand Up @@ -10,9 +10,7 @@
import re
import time
import types
import warnings
from calendar import timegm
from decimal import Decimal, ROUND_HALF_EVEN, Context, Inexact
from email.utils import formatdate, parsedate
from pprint import pprint as py_pprint

Expand Down Expand Up @@ -60,11 +58,6 @@ def is_iterable_but_not_string(obj):
)


def is_indexable_but_not_string(obj):
"""Return True if ``obj`` is indexable but isn't a string."""
return not hasattr(obj, 'strip') and hasattr(obj, '__getitem__')


def is_collection(obj):
"""Return True if ``obj`` is a collection type, e.g list, tuple, queryset."""
return is_iterable_but_not_string(obj) and not isinstance(obj, Mapping)
Expand All @@ -83,27 +76,6 @@ def is_keyed_tuple(obj):
"""
return isinstance(obj, tuple) and hasattr(obj, '_fields')

def float_to_decimal(f):
"""Convert a floating point number to a Decimal with no loss of information.
See: https://docs.python.org/release/2.6.7/library/decimal.html#decimal-faq
"""
n, d = f.as_integer_ratio()
numerator, denominator = Decimal(n), Decimal(d)
ctx = Context(prec=60)
result = ctx.divide(numerator, denominator)
while ctx.flags[Inexact]:
ctx.flags[Inexact] = False
ctx.prec *= 2
result = ctx.divide(numerator, denominator)
return result


ZERO_DECIMAL = Decimal()

def decimal_to_fixed(value, precision):
"""Convert a `Decimal` to a fixed-precision number as a string."""
return text_type(value.quantize(precision, rounding=ROUND_HALF_EVEN))


def to_marshallable_type(obj, field_names=None):
"""Helper for converting an object to a dictionary only if it is not
Expand Down Expand Up @@ -141,7 +113,6 @@ def pprint(obj, *args, **kwargs):

# From pytz: http://pytz.sourceforge.net/
ZERO = datetime.timedelta(0)
HOUR = datetime.timedelta(hours=1)


class UTC(datetime.tzinfo):
Expand Down Expand Up @@ -270,11 +241,6 @@ def from_rfc(datestring, use_dateutil=True):
return datetime.datetime.fromtimestamp(timestamp)


def from_iso(datestring, use_dateutil=True):
warnings.warn('from_iso is deprecated. Use from_iso_datetime instead.', UserWarning)
return from_iso_datetime(datestring, use_dateutil)


def from_iso_datetime(datetimestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime object.
Expand Down

0 comments on commit d9bcc48

Please sign in to comment.