class_docstr: Data representing numbers.
  
  :param locale:
      A locale specification such as :code:`en_US` or :code:`de_DE` to use
      for parsing formatted numbers.
  :param group_symbol:
      A grouping symbol used in the numbers. Overrides the value provided by
      the specified :code:`locale`.
  :param decimal_symbol:
      A decimal separate symbol used in the numbers. Overrides the value
      provided by the specified :code:`locale`.
  :param currency_symbols:
      A sequence of currency symbols to strip from numbers.
docstr: Cast a single value to a :class:`decimal.Decimal`.
  
  :returns:
      :class:`decimal.Decimal` or :code:`None`.
code: def cast(self, d):
      """
      Cast a single value to a :class:`decimal.Decimal`.
  
      :returns:
          :class:`decimal.Decimal` or :code:`None`.
      """
      if isinstance(d, Decimal) or d is None:
          return d
  
      t = type(d)
  
      if t is int:
          return Decimal(d)
      if t is float:
          return Decimal(repr(d))
      if d is False:
          return Decimal(0)
      if d is True:
          return Decimal(1)
      if not isinstance(d, str):
          raise CastError('Can not parse value "%s" as Decimal.' % d)
  
      d = d.strip()
  
      if d.lower() in self.null_values:
          return None
  
      d = d.strip("%")
  
      if len(d) > 0 and d[0] == "-":
          d = d[1:]
          sign = NEGATIVE
      else:
          sign = POSITIVE
  
      for symbol in self.currency_symbols:
          d = d.strip(symbol)
  
      d = d.replace(self.group_symbol, "")
      d = d.replace(self.decimal_symbol, ".")
  
      try:
          return Decimal(d) * sign
      # The Decimal class will return an InvalidOperation exception on most Python implementations,
      # but PyPy3 may return a ValueError if the string is not translatable to ASCII
      except (InvalidOperation, ValueError):
          pass
  
      raise CastError('Can not parse value "%s" as Decimal.' % d)
  
file_path: agate/agate/data_types/number.py
imports: import warnings
  from decimal import Decimal, InvalidOperation
  from babel.core import Locale
  from agate.data_types.base import DataType
  from agate.exceptions import CastError
label_desc: Use image node_id 2 for calling the Number obj's underlying member method code with example usage: obj.cast(d) and returns: d, Decimal, Decimal, Decimal, Decimal, None, unknown