Convert a crypto and fiat to a "market" string. All exchanges use their
        own format for specifying markets. Subclasses can define their own
        implementation.
496699
def make_market(self, crypto, fiat, seperator="_"):
        
        return ("%s%s%s" % (
            self.fix_symbol(crypto), seperator, self.fix_symbol(fiat))
        ).lower()
487700
public static function createFromString(string $string): CurrencyPairContract
    {
        $matches = [];
        if (!preg_match('#^([A-Z0-9]{3,})\/([A-Z0-9]{3,})$#', $string, $matches)) {
            throw new \InvalidArgumentException('The currency pair must be in the form "EUR/USD".');
        }

        $parts = explode('/', $string);

        return new self($parts[0], $parts[1]);
    }
190619
def to_string(comp_type):
    '''

    '''
    if comp_type == NONE:
        return NONE
    elif comp_type== PERIODIC_EC_SHARED:
        return PERIODC_EC_SHARED
    elif comp_type == PERIODIC_STATE_SHARED:
        return PERIODIC_STATE_SHARED
    elif comp_type == GROUPING:
        return GROUPING
    elif comp_type == FSM_EC_SHARED:
        return FSM_EC_SHARED
    elif comp_type == FSM_STATE_SHARED:
        return FSM_STATE_SHARED
    else:
        raise InvalidCompositeTypeError(type_string)
961143
def from_str(cls: Type[CRCPubkeyType], crc_pubkey: str) -> CRCPubkeyType:
        
        data = CRCPubkey.re_crc_pubkey.match(crc_pubkey)
        if data is None:
            raise Exception("Could not parse CRC public key {0}".format(crc_pubkey))
        pubkey = data.group(1)
        crc = data.group(2)
        return cls(pubkey, crc)
765645
function objToString(obj, commentFix = false) {
  const comment = commentFix ? '/**/' : ''

  return Object.keys(obj).reduce((acc, k) => {
    let value = obj[k]

    if (k.startsWith('__spread__')) {
      return acc + '${' + value + '};' + comment
    }

    if (typeof value === 'string') {
      if (value[0] === '$') {
        value = '${' + value.substr(1) + '}'
      }
      return acc + camelToKebab(k) + ':' + value + ';' + comment
    } else {
      value = objToString(value)
      let key = k[0] === ':' ? '&' + k : k
      key = key[0] === '`' ? key.substr(1, key.length - 2) : key
      return acc + camelToKebab(key) + '{' + value + '};' + comment
    }
  }, '')
}
1295446
public Object stringToKey(String s) {
      char type = s.charAt(0);
      switch (type) {
         case 'S':
            // this is a String, NOT a Short. For Short see case 'X'.
            return s.substring(2);
         case 'I':
            // This is an Integer
            return Integer.valueOf(s.substring(2));
         case 'Y':
            // This is a BYTE
            return Byte.valueOf(s.substring(2));
         case 'L':
            // This is a Long
            return Long.valueOf(s.substring(2));
         case 'X':
            // This is a SHORT
            return Short.valueOf(s.substring(2));
         case 'D':
            // This is a Double
            return Double.valueOf(s.substring(2));
         case 'F':
            // This is a Float
            return Float.valueOf(s.substring(2));
         case 'B':
            // This is a Boolean, NOT a Byte. For Byte see case 'Y'.
            return Boolean.valueOf(s.substring(2));
         case 'C':
            // This is a Character
            return Character.valueOf(s.charAt(2));
         case 'U':
            // This is a java.util.UUID
            return UUID.fromString(s.substring(2));
         case 'A':
            // This is an array of bytes encoded as a Base64 string
            return Base64.getDecoder().decode(s.substring(2));
         case 'T':
            // this is a custom Transformable or a type with a registered Transformer
            int indexOfSecondDelimiter = s.indexOf(':', 2);
            String keyClassName = s.substring(2, indexOfSecondDelimiter);
            String keyAsString = s.substring(indexOfSecondDelimiter + 1);
            Transformer t = getTransformer(keyClassName);
            if (t != null) {
               return t.fromString(keyAsString);
            } else {
               throw log.noTransformerForKey(keyClassName);
            }
      }
      throw new CacheException("Unknown key type metadata: " + type);
   }
603103
def convert_currency(self, base_fiat, base_amount, target_fiat):
        
        url = "http://api.fixer.io/latest?base=%s" % base_fiat
        data = self.get_url(url).json()
        try:
            return data['rates'][target_fiat.upper()] * base_amount
        except KeyError:
            raise Exception("Can not convert %s to %s" % (base_fiat, target_fiat))
1227322
def currency(s=''):
    ''
    if isinstance(s, str):
        s = ''.join(ch for ch in s if ch in floatchars)
    return float(s) if s else TypedWrapper(float, None)
30995
def stringify(self, value, **opts):
        
        if self._is_null(value):
            return None
        try:
            opts_ = self.opts.copy()
            opts_.update(opts)
            return self._stringify(value, **opts_)
        except Exception as e:
            if not isinstance(e, ConverterError):
                e = ConverterError(None, exc=e)
            e.converter = self.__class__
            raise e
86818
def to_simple(self, value, **options):  # nolint
        "  "

        # (string, unicode)
        if isinstance(value, basestring):
            return smart_unicode(value)

        # (int, long, float, real, complex, decimal)
        if isinstance(value, Number):
            return float(str(value)) if isinstance(value, Decimal) else value

        # (datetime, data, time)
        if isinstance(value, (datetime, date, time)):
            return self.to_simple_datetime(value)

        # (dict, ordereddict, mutable mapping)
        if isinstance(value, collections.MutableMapping):
            return dict(
                (k, self.to_simple(v, **options)) for k, v in value.items())

        # (tuple, list, set, iterators)
        if isinstance(value, collections.Iterable):
            return [self.to_simple(o, **options) for o in value]

        # (None, True, False)
        if value is None or value is True or value is False:
            return value

        if hasattr(value, 'to_simple') and not inspect.isclass(value):
            return self.to_simple(value.to_simple(self), **options)

        if isinstance(value, Model):
            return self.to_simple_model(value, **options)

        return str(value)
415446
def to_satoshis(input_quantity, input_type):
    '''  '''
    assert input_type in UNIT_CHOICES, input_type

    # convert to satoshis
    if input_type in ('btc', 'mbtc', 'bit'):
        satoshis = float(input_quantity) * float(UNIT_MAPPINGS[input_type]['satoshis_per'])
    elif input_type == 'satoshi':
        satoshis = input_quantity
    else:
        raise Exception('Invalid Unit Choice: %s' % input_type)

    return int(satoshis)
1092303
public Fiat parseFiat(String currencyCode, String str) throws NumberFormatException {
        return Fiat.valueOf(currencyCode, parseValue(str, Fiat.SMALLEST_UNIT_EXPONENT));
    }
1258600
def _get_all_services(crypto=None, just_exchange=False):
    
    from moneywagon.crypto_data import crypto_data

    if not crypto:
        # no currency specified, get all services
        to_iterate = crypto_data.items()
    else:
        # limit to one currency
        to_iterate = [(crypto, crypto_data[crypto])]

    services = []
    for currency, data in to_iterate:
        if 'services' not in data:
            continue
        if currency == '':
            continue # template

        # price services are defined as dictionaries, all other services
        # are defined as a list.
        price_services = data['services']['current_price']
        del data['services']['current_price']

        all_services = list(price_services.values())
        if not just_exchange:
            all_services += list(data['services'].values())

        # replace
        data['services']['current_price'] = price_services

        services.append([
            item for sublist in all_services for item in sublist
        ])

    return sorted(
        set([item for sublist in services for item in sublist]),
        key=lambda x: x.__name__
    )
378128
def compat_string(value):
        
        if isinstance(value, bytes):
            return value.decode(encoding='utf-8')
        return str(value)
741491
def convert_value(self, value):
        
        if isinstance(value, str):
            assert value.startswith(self.symbol), "Currency does not start with " + self.symbol
            value = value.lstrip(self.symbol)
        return super().convert_value(value)
1271998
def format_price(self, price):
        
        return u"{} {}{}{:02d}".format(
            self.currency_symbol,
            price[0],
            self.decimal_mark,
            price[1],
        )
640366
public static String to(String str, NamingStyle namingStyle) {
        NamingStyle ns = namingStyle;
        if (str == null) {
            return null;
        }
        if (ns == null) {
            ns = NamingStyle.CAMEL;
        }
        String formatStr;
        switch (ns) {
        case CAMEL:
            formatStr = toLowerCamel(str);
            break;
        case SNAKE:
            formatStr = toSnake(str);
            break;
        case PASCAL:
            formatStr = toPascal(str);
            break;
        case KEBAB:
            formatStr = toKebab(str);
            break;
        default:
            formatStr = toLowerCamel(str);
            break;
        }
        return formatStr;
    }