Parse GnuCash-style symbol "namespace:mnemonic"
482904
def __parse_gc_symbol(self, gc_symbol: str):
        
        result = {
            "namespace": None,
            "mnemonic": None
        }

        parts = gc_symbol.split(':')
        if len(parts) > 1:
            result["namespace"] = parts[0]
            result["mnemonic"] = parts[1]
        else:
            result["mnemonic"] = gc_symbol

        return result
934548
def __parse_namespace(self):
        
        if self.manifest.has_option('config', 'namespace'):
            return self.manifest.get('config', 'namespace')
        elif self.manifest.has_option('config', 'source'):
            return NAMESPACE_REGEX.search(self.manifest.get('config', 'source')).groups()[0]
        else:
            logger.warn('Could not parse namespace implicitely')
            return None
514938
function getNamespacedData(namespace, data){
        var namespacedData = {};
        for (var key in data){
            // key starts with namespace
            if (key.slice(0, namespace.length) == namespace){
                var namespacedKey = key.slice(namespace.length, key.length);
                namespacedKey = namespacedKey.charAt(0).toLowerCase() + namespacedKey.slice(1);
                namespacedData[namespacedKey] = data[key];
            }
        }

        return namespacedData;
    }
344959
function formatSymbolExport(symbol, namespaces, imports) {
  const name = symbol.name;
  const parts = name.split('~');
  const isNamed = parts[0].indexOf('.') !== -1;
  const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
  const last = nsParts.length - 1;
  const importName = isNamed ?
    '_' + nsParts.slice(0, last).join('_') + '$' + nsParts[last] :
    '$' + nsParts.join('$');
  let line = nsParts[0];
  for (let i = 1, ii = nsParts.length; i < ii; ++i) {
    line += `.${nsParts[i]}`;
    namespaces[line] = (line in namespaces ? namespaces[line] : true) && i < ii - 1;
  }
  line += ` = ${importName};`;
  imports[getImport(symbol, nsParts.pop())] = true;
  return line;
}
879150
def namespacereveal_sanity_check( namespace_id, version, lifetime, coeff, base, bucket_exponents, nonalpha_discount, no_vowel_discount ):
   
   # sanity check 
   if not is_b40( namespace_id ) or "+" in namespace_id or namespace_id.count(".") > 0:
      raise Exception("Namespace ID '%s' has non-base-38 characters" % namespace_id)
  
   if len(namespace_id) > LENGTHS['blockchain_id_namespace_id']:
      raise Exception("Invalid namespace ID length for '%s' (expected length between 1 and %s)" % (namespace_id, LENGTHS['blockchain_id_namespace_id']))
    
   if version not in [NAMESPACE_VERSION_PAY_TO_BURN, NAMESPACE_VERSION_PAY_TO_CREATOR, NAMESPACE_VERSION_PAY_WITH_STACKS]:
      raise Exception("Invalid namespace version bits {:x}".format(version))

   if lifetime < 0 or lifetime > (2**32 - 1):
      lifetime = NAMESPACE_LIFE_INFINITE 

   if coeff < 0 or coeff > 255:
      raise Exception("Invalid cost multiplier %s: must be in range [0, 256)" % coeff)
  
   if base < 0 or base > 255:
      raise Exception("Invalid base price %s: must be in range [0, 256)" % base)
 
   if type(bucket_exponents) != list:
        raise Exception("Bucket exponents must be a list")

   if len(bucket_exponents) != 16:
        raise Exception("Exactly 16 buckets required")

   for i in xrange(0, len(bucket_exponents)):
       if bucket_exponents[i] < 0 or bucket_exponents[i] > 15:
          raise Exception("Invalid bucket exponent %s (must be in range [0, 16)" % bucket_exponents[i])
   
   if nonalpha_discount <= 0 or nonalpha_discount > 15:
        raise Exception("Invalid non-alpha discount %s: must be in range [0, 16)" % nonalpha_discount)
    
   if no_vowel_discount <= 0 or no_vowel_discount > 15:
        raise Exception("Invalid no-vowel discount %s: must be in range [0, 16)" % no_vowel_discount)

   return True
759200
def parse_namevalue(nameval, sep: ':', default: nil, symbolize: true)
			name,*val=nameval.split(sep)
			if val.empty?
				value=default
				if default == true
					#special case where if name begins by no- we return false
					name.to_s.match(/^no-(.*)$/) do |m| 
						name=m[1]
						value=false
					end
				end
			else
				value=val.join(sep)
			end
			name=name.to_sym if symbolize
			return name,value
		end
311000
private String parseToken(final char[] terminators) {
		char ch;
		i1 = pos;
		i2 = pos;
		while (hasChar()) {
			ch = chars[pos];
			if (isOneOf(ch, terminators)) {
				break;
			}
			i2++;
			pos++;
		}
		return getToken(false);
	}
306358
def ns(symbol):
        ''''''
        if symbol.type and symbol.type.is_primitive:
            return ''
        return '{0}::'.format('::'.join(symbol.module.name_parts))
131583
function parsecanon(str) {
  var out = {}

  if (_.isArray(str)) {
    return {
      zone: str[0],
      base: str[1],
      name: str[2]
    }
  }

  if (_.isObject(str) && !_.isFunction(str)) return str

  if (!_.isString(str)) return out

  var m = /\$?((\w+|-)\/)?((\w+|-)\/)?(\w+|-)/.exec(str)
  if (m) {
    var zi = m[4] == null ? 4 : 2
    var bi = m[4] == null ? 2 : 4

    out.zone = m[zi] === '-' ? void 0 : m[zi]
    out.base = m[bi] === '-' ? void 0 : m[bi]
    out.name = m[5] === '-' ? void 0 : m[5]
  } else throw error('invalid_canon', { str: str })

  return out
}
253295
private String readNmtoken(boolean isName) throws SAXException, IOException {
        char c;

        nameBufferPos = 0;

        // Read the first character.
        while (true) {
            c = readCh();
            switch (c) {
                case '%':
                case '<':
                case '>':
                case '&':
                case ',':
                case '|':
                case '*':
                case '+':
                case '?':
                case ')':
                case '=':
                case '\'':
                case '"':
                case '[':
                case ' ':
                case '\t':
                case '\n':
                case '\r':
                case ';':
                case '/':
                    unread(c);
                    if (nameBufferPos == 0) {
                        fatal("name expected");
                    }
                    String s = intern(nameBuffer, 0, nameBufferPos);
                    nameBufferPos = 0;
                    return s;
                default:
                    if (isName && (nameBufferPos == 0)
                            && (!(NCName.isNCNameStart(c)))) {
                        fatal("Not a name start character, U+"
                                + Integer.toHexString(c));
                    } else if (!(NCName.isNCNameTrail(c) || c == ':')) {
                        fatal("Not a name character, U+"
                                + Integer.toHexString(c));
                    }
                    if (nameBufferPos >= nameBuffer.length) {
                        nameBuffer = (char[]) extendArray(nameBuffer,
                                nameBuffer.length, nameBufferPos);
                    }
                    nameBuffer[nameBufferPos++] = c;
            }
        }
    }
1132742
def parse_market(self, market, split_char='_'):
        
        crypto, fiat = market.lower().split(split_char)
        return (
            self.fix_symbol(crypto, reverse=True),
            self.fix_symbol(fiat, reverse=True)
        )
105464
def _parse_canonical_symbol(doc):
    """"""
    symbol = doc['$symbol']
    if len(doc) != 1:
        raise TypeError('Bad $symbol, extra field(s): %s' % (doc,))
    return text_type(symbol)
1196128
def load_currency(self, mnemonic: str):
        
        # , base_currency: str <= ignored for now.
        if self.rate and self.rate.currency == mnemonic:
            # Already loaded.
            return

        app = PriceDbApplication()
        # TODO use the base_currency parameter for the query #33
        symbol = SecuritySymbol("CURRENCY", mnemonic)
        self.rate = app.get_latest_price(symbol)
        if not self.rate:
            raise ValueError(f"No rate found for {mnemonic}!")
1143497
def parse_path(nstr: str) -> Address:
    
    if not nstr:
        return []

    n = nstr.split("/")

    # m/a/b/c => a/b/c
    if n[0] == "m":
        n = n[1:]

    # coin_name/a/b/c => 44'/SLIP44_constant'/a/b/c
    if n[0] in slip44:
        coin_id = slip44[n[0]]
        n[0:1] = ["44h", "{}h".format(coin_id)]

    def str_to_harden(x: str) -> int:
        if x.startswith("-"):
            return H_(abs(int(x)))
        elif x.endswith(("h", "'")):
            return H_(int(x[:-1]))
        else:
            return int(x)

    try:
        return [str_to_harden(x) for x in n]
    except Exception:
        raise ValueError("Invalid BIP32 path", nstr)
49993
function namespaceType (ns /* : string */) /* : string */ {
  const parts = ns.split(':')
  if (parts.length < 2) {
    return ''
  }
  return parts.slice(0, -1).join(':')
}
441778
def handle_namespace_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        namespace = tokens['name']
        self.raise_for_redefined_namespace(line, position, namespace)
        self.namespace_to_pattern[namespace] = re.compile(tokens['value'])
        return tokens
121946
def parse_as_header(class_, f):
        
        version, previous_block_hash, merkle_root, height = parse_struct("L##L", f)
        # https://github.com/BTCGPU/BTCGPU/wiki/Technical-Spec
        f.read(28)  # reserved area
        (timestamp, difficulty, nonce, solution) = parse_struct("LL#S", f)
        return class_(version, previous_block_hash, merkle_root, timestamp,
                      difficulty, nonce, height, solution)