Get code of the currency for current locale.

        :param allow_random: Get a random ISO code.
        :return: Currency code.
506802
def currency_iso_code(self, allow_random: bool = False) -> str:
        
        if allow_random:
            return self.random.choice(CURRENCY_ISO_CODES)
        else:
            return self._data['currency-code']
901958
private static FairyModule getFairyModuleForLocale(DataMaster dataMaster, Locale locale, RandomGenerator randomGenerator) {

		LanguageCode code;
		try {
			code = LanguageCode.valueOf(locale.getLanguage().toUpperCase());
		} catch (IllegalArgumentException e) {
			LOG.warn("Uknown locale " + locale);
			code = LanguageCode.EN;
		}

		switch (code) {
			case PL:
				return new PlFairyModule(dataMaster, randomGenerator);
			case EN:
				return new EnFairyModule(dataMaster, randomGenerator);
			case ES:
				return new EsFairyModule(dataMaster, randomGenerator);
			case FR:
				return new EsFairyModule(dataMaster, randomGenerator);
			case SV:
				return new SvFairyModule(dataMaster, randomGenerator);
			case ZH:
				return new ZhFairyModule(dataMaster, randomGenerator);
			case DE:
				return new DeFairyModule(dataMaster, randomGenerator);
			case KA:
				return new KaFairyModule(dataMaster, randomGenerator);
			default:
				LOG.info("No data for your language - using EN");
				return new EnFairyModule(dataMaster, randomGenerator);
		}
	}
1183971
def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
    
    reverse_rate = False
    if to_currency == BASE_CURRENCY:
        # Fetch exchange rate for base currency and use 1 / rate for conversion
        rate_currency = from_currency
        reverse_rate = True
    else:
        rate_currency = to_currency
    rate = get_rate_from_db(rate_currency)

    if reverse_rate:
        conversion_rate = Decimal(1) / rate
    else:
        conversion_rate = rate
    return conversion_rate
1181104
def __get_default_currency(self):
        """"""
        # If we are on Windows, read from registry.
        if sys.platform == "win32":
            # read from registry
            def_curr = self.book["default-currency"] = self.__get_default_currency_windows()
        else:
            # return the currency from locale.
            # todo: Read the preferences on other operating systems.
            def_curr = self.book["default-currency"] = self.__get_locale_currency()

        return def_curr
1147419
def assert_currency! arg
      defines?(arg) ? (country_map[arg] || arg) : raise(Exchange::NoCurrencyError.new("#{arg} is not a currency nor a country code matchable to a currency"))
    end
111737
def currency_context(context):
    
    request = context['request']
    currency_code = memoize_nullary(lambda: get_currency_code(request))

    context['CURRENCIES'] = Currency.active.all() # querysets are already lazy
    context['CURRENCY_CODE'] = currency_code # lazy
    context['CURRENCY'] = memoize_nullary(lambda: get_currency(currency_code)) # lazy

    return ''
733140
def get_base(self, option):
        
        if option:
            if option.isupper():
                if len(option) > 3:
                    return getattr(settings, option), True
                elif len(option) == 3:
                    return option, True
            raise ImproperlyConfigured("Invalid currency code found: %s" % option)
        for attr in ('CURRENCIES_BASE', 'SHOP_DEFAULT_CURRENCY'):
            try:
                return getattr(settings, attr), True
            except AttributeError:
                continue
        return 'USD', False
616182
def get_currencys(self, site='Pro', _async=False):
        
        assert site in ['Pro', 'HADAX']
        params = {}
        path = f'/v1{"/" if site == "Pro" else "/hadax/"}common/currencys'
        return api_key_get(params, path, _async=_async)
745340
protected function getCurrencyIso4217NumericCode($textCurrencyCode)
    {
        $currencies = null;

        $localIso417data = __DIR__ . DS . "Config" . DS . "iso4217.xml";

        $currencyXmlDataUrl = "http://www.currency-iso.org/dam/downloads/lists/list_one.xml";

        $xmlData = @file_get_contents($currencyXmlDataUrl);

        try {
            $currencies = new \SimpleXMLElement($xmlData);

            // Update the local currencies copy.
            @file_put_contents($localIso417data, $xmlData);
        } catch (\Exception $ex) {
            Tlog::getInstance()->warning("Failed to get currency XML data from $currencyXmlDataUrl: ".$ex->getMessage());
            try {
                $currencies = new \SimpleXMLElement(@file_get_contents($localIso417data));
            } catch (\Exception $ex) {
                Tlog::getInstance()->warning("Failed to get currency XML data from local copy $localIso417data: ".$ex->getMessage());
            }
        }

        if (null !== $currencies) {
            foreach ($currencies->CcyTbl->CcyNtry as $country) {
                if ($country->Ccy == $textCurrencyCode) {
                    return (string) $country->CcyNbr;
                }
            }
        }

        // Last chance
        switch ($textCurrencyCode) {
            case 'USD':
                return 840;
            case 'GBP':
                return 826;
                break;
            case 'EUR':
                return 978;
                break;
        }

        throw new \RuntimeException(
            Translator::getInstance()->trans(
                "Failed to get ISO 4217 data for currency %curr, payment is not possible.",
                ['%curr' => $textCurrencyCode]
            )
        );
    }
628142
def _get_random_string(length=44,
                       allowed_chars='abcdefghijklmnopqrstuvwxyz'
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
                       secret_key=settings.secret_key_bytes()):
    
    secret_key = _ensure_bytes(secret_key)
    _reseed_if_needed(using_sysrandom, secret_key)
    return ''.join(random.choice(allowed_chars) for i in range(length))
1221166
def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale:
        
        if "Accept-Language" in self.request.headers:
            languages = self.request.headers["Accept-Language"].split(",")
            locales = []
            for language in languages:
                parts = language.strip().split(";")
                if len(parts) > 1 and parts[1].startswith("q="):
                    try:
                        score = float(parts[1][2:])
                    except (ValueError, TypeError):
                        score = 0.0
                else:
                    score = 1.0
                locales.append((parts[0], score))
            if locales:
                locales.sort(key=lambda pair: pair[1], reverse=True)
                codes = [l[0] for l in locales]
                return locale.get(*codes)
        return locale.get(default)
683468
def random(self):
        
        utc_now = datetime.datetime.utcnow()
        return self.valueFromString(utc_now.strftime(self.defaultFormat()))
1289068
def format_currency_field(__, prec, number, locale):
    """"""
    locale = Locale.parse(locale)
    currency = get_territory_currencies(locale.territory)[0]
    if prec is None:
        pattern, currency_digits = None, True
    else:
        prec = int(prec)
        pattern = locale.currency_formats['standard']
        pattern = modify_number_pattern(pattern, frac_prec=(prec, prec))
        currency_digits = False
    return format_currency(number, currency, pattern, locale=locale,
                           currency_digits=currency_digits)
487761
def get_handler(self, options):
        """"""
        # Import the CurrencyHandler and get an instance
        handler_module = import_module(sources[options[self._source_param]], self._package_name)
        return handler_module.CurrencyHandler(self.log)
922574
def first_currency():
    
    ct = CurrencyType.objects.filter(code='PES').first()
    if ct:
        return ct.pk
464149
def getCodename(locale=None, providers=None):
        
        from django.conf import settings
        # language
        locale = locale or getattr(settings,'FAKER_LOCALE', getattr(settings,'LANGUAGE_CODE', None))
        # providers
        providers = providers or getattr(settings,'FAKER_PROVIDERS', None)

        codename = locale or 'default'

        if providers:
            codename += "-" + "-".join(sorted(providers))

        return codename
1208497
public static Currency getInstance(Locale locale) {
        synchronized (localesToCurrencies) {
            if (locale == null) {
                throw new NullPointerException("locale == null");
            }
            Currency currency = localesToCurrencies.get(locale);
            if (currency != null) {
                return currency;
            }

            String currencyCode = ICU.getCurrencyCode(locale);
            if (currencyCode == null) {
                throw new IllegalArgumentException("Unsupported ISO 3166 country: " + locale);
            } else if (currencyCode.equals("XXX")) {
                return null;
            }
            Currency result = getInstance(currencyCode);
            localesToCurrencies.put(locale, result);
            return result;
        }
    }