# Path: num2words/compat.py
# def to_s(val):
#     try:
#         return unicode(val)
#     except NameError:
#         return str(val)
# 
# Path: num2words/currency.py
# def parse_currency_parts(value, is_int_with_cents=True):
#     if isinstance(value, int):
#         if is_int_with_cents:
#             # assume cents if value is integer
#             negative = value < 0
#             value = abs(value)
#             integer, cents = divmod(value, 100)
#         else:
#             negative = value < 0
#             integer, cents = abs(value), 0
# 
#     else:
#         value = Decimal(value)
#         value = value.quantize(
#             Decimal('.01'),
#             rounding=ROUND_HALF_UP
#         )
#         negative = value < 0
#         value = abs(value)
#         integer, fraction = divmod(value, 1)
#         integer = int(integer)
#         cents = int(fraction * 100)
# 
#     return integer, cents, negative
# 
# def prefix_currency(prefix, base):
#     return tuple("%s %s" % (prefix, i) for i in base)


import math
from collections import OrderedDict
from decimal import Decimal
from .compat import to_s
from .currency import parse_currency_parts, prefix_currency
    def _cents_verbose(self, number, currency):
        return self.to_cardinal(number)

    def _cents_terse(self, number, currency):
        return "%02d" % number

    def to_currency(self, val, currency='EUR', cents=True, separator=',',
                    adjective=False):
        """
        Args:
            val: Numeric value
            currency (str): Currency code
            cents (bool): Verbose cents
            separator (str): Cent separator
            adjective (bool): Prefix currency name with adjective
        Returns:
            str: Formatted string

        """
        left, right, is_negative = parse_currency_parts(val)

        try:
            cr1, cr2 = self.CURRENCY_FORMS[currency]

        except KeyError:
            raise NotImplementedError(
                'Currency code "%s" not implemented for "%s"' %
                (currency, self.__class__.__name__))

        if adjective and currency in self.CURRENCY_ADJECTIVES:

# Path: num2words/compat.py
# def to_s(val):
#     try:
#         return unicode(val)
#     except NameError:
#         return str(val)
# 
# Path: num2words/currency.py
# def parse_currency_parts(value, is_int_with_cents=True):
#     if isinstance(value, int):
#         if is_int_with_cents:
#             # assume cents if value is integer
#             negative = value < 0
#             value = abs(value)
#             integer, cents = divmod(value, 100)
#         else:
#             negative = value < 0
#             integer, cents = abs(value), 0
# 
#     else:
#         value = Decimal(value)
#         value = value.quantize(
#             Decimal('.01'),
#             rounding=ROUND_HALF_UP
#         )
#         negative = value < 0
#         value = abs(value)
#         integer, fraction = divmod(value, 1)
#         integer = int(integer)
#         cents = int(fraction * 100)
# 
#     return integer, cents, negative
# 
# def prefix_currency(prefix, base):
#     return tuple("%s %s" % (prefix, i) for i in base)


# Path: num2words/base.py
import math
from collections import OrderedDict
from decimal import Decimal
from .compat import to_s
from .currency import parse_currency_parts, prefix_currency

    def _cents_verbose(self, number, currency):
        return self.to_cardinal(number)

    def _cents_terse(self, number, currency):
        return "%02d" % number

    def to_currency(self, val, currency='EUR', cents=True, separator=',',
                    adjective=False):
        """
        Args:
            val: Numeric value
            currency (str): Currency code
            cents (bool): Verbose cents
            separator (str): Cent separator
            adjective (bool): Prefix currency name with adjective
        Returns:
            str: Formatted string

        """
        left, right, is_negative = parse_currency_parts(val)

        try:
            cr1, cr2 = self.CURRENCY_FORMS[currency]

        except KeyError:
            raise NotImplementedError(
                'Currency code "%s" not implemented for "%s"' %
                (currency, self.__class__.__name__))

        if adjective and currency in self.CURRENCY_ADJECTIVES:

            cr1 = prefix_currency(self.CURRENCY_ADJECTIVES[currency], cr1)