Given an integer code, returns an EPSG-like mapping.
        Note: the input code is not validated against an EPSG database.
19909
def from_epsg(cls, code):
        
        if int(code) <= 0:
            raise ValueError("EPSG codes are positive integers")
        return cls({'init': "epsg:{}".format(code), 'no_defs': True})
1173736
def convert(self, value, fromunits, tounits):
        ''''''
        if fromunits == tounits:
            return value
        if (fromunits,tounits) in self.unitmap:
            return value * self.unitmap[(fromunits,tounits)]
        if (tounits,fromunits) in self.unitmap:
            return value / self.unitmap[(tounits,fromunits)]
        raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
1211223
public static JCGLPrimitives primitiveFromGL(
    final int code)
  {
    switch (code) {
      case GL11.GL_LINES:
        return JCGLPrimitives.PRIMITIVE_LINES;
      case GL11.GL_LINE_LOOP:
        return JCGLPrimitives.PRIMITIVE_LINE_LOOP;
      case GL11.GL_POINTS:
        return JCGLPrimitives.PRIMITIVE_POINTS;
      case GL11.GL_TRIANGLES:
        return JCGLPrimitives.PRIMITIVE_TRIANGLES;
      case GL11.GL_TRIANGLE_STRIP:
        return JCGLPrimitives.PRIMITIVE_TRIANGLE_STRIP;
      default:
        throw new UnreachableCodeException();
    }
  }
944855
def _get_code(data, position, obj_end, opts, element_name):
    """"""
    code, position = _get_string(data, position, obj_end, opts, element_name)
    return Code(code), position
140566
function toAlpha3(code) {
  if (typeof code === "string") {
    if (/^[0-9]*$/.test(code)) {
      return numericToAlpha3(code);
    }
    if(code.length === 2) {
      return alpha2ToAlpha3(code.toUpperCase());
    }
    if (code.length === 3) {
      return code.toUpperCase();
    }
  }
  if (typeof code === "number") {
    return numericToAlpha3(code);
  }
  return undefined;
}
67488
def _get_indexing_dispatch_code(key):
    """"""
    if isinstance(key, (NDArray, np.ndarray)):
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, list):
        # TODO(junwu): Add support for nested lists besides integer list
        for i in key:
            if not isinstance(i, integer_types):
                raise TypeError('Indexing NDArray only supports a list of integers as index'
                                ' when key is of list type, received element=%s of type=%s'
                                % (str(i), str(type(i))))
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, (integer_types, py_slice)):
        return _NDARRAY_BASIC_INDEXING
    elif isinstance(key, tuple):
        for idx in key:
            if isinstance(idx, (NDArray, np.ndarray, list, tuple)):
                return _NDARRAY_ADVANCED_INDEXING
            elif not isinstance(idx, (py_slice, integer_types)):
                raise ValueError("NDArray does not support slicing with key %s of type %s."
                                 % (str(idx), str(type(idx))))
        return _NDARRAY_BASIC_INDEXING
    else:
        return _NDARRAY_UNSUPPORTED_INDEXING
1091660
def b58decode(s, errors='strict'):
    ""
    if not s:
        return (b'', 0)

    # Convert the string to an integer
    n = 0
    for c in s:
        n *= 58
        if c not in b58digits:
            raise InvalidBase58Error(u"character %r is not a valid base58 "
                u"character" % c)
        digit = b58digits.index(c)
        n += digit

    # Convert the integer to bytes
    res = BigInteger(n).serialize((n.bit_length()+7)//8 or 1)

    # Add padding back.
    pad = 0
    for c in s[:-1]:
        if c == b58digits[0]: pad += 1
        else: break
    return (b'\x00' * pad + res, len(s))
861636
def ast_to_code(ast, indent=0):
    # type: (Any, int) -> str
    
    code = []

    def append(line):
        # type: (str) -> None
        code.append(("    " * indent) + line)

    if isinstance(ast, Node):
        append("ast.{}(".format(ast.__class__.__name__))
        indent += 1
        for i, k in enumerate(ast._fields, 1):
            v = getattr(ast, k)
            append("{}={},".format(k, ast_to_code(v, indent)))
        if ast.loc:
            append("loc={}".format(ast_to_code(ast.loc, indent)))

        indent -= 1
        append(")")

    elif isinstance(ast, Loc):
        append("loc({}, {})".format(ast.start, ast.end))

    elif isinstance(ast, list):
        if ast:
            append("[")
            indent += 1

            for i, it in enumerate(ast, 1):
                is_last = i == len(ast)
                append(ast_to_code(it, indent) + ("," if not is_last else ""))

            indent -= 1
            append("]")
        else:
            append("[]")

    else:
        append(repr(ast))

    return "\n".join(code).strip()
733654
def to_match(self):
        """"""
        self.validate()

        # The MATCH versions of some operators require an inverted order of arguments.
        # pylint: disable=unused-variable
        regular_operator_format = '(%(left)s %(operator)s %(right)s)'
        inverted_operator_format = '(%(right)s %(operator)s %(left)s)'  # noqa
        intersects_operator_format = '(%(operator)s(%(left)s, %(right)s).asList().size() > 0)'
        # pylint: enable=unused-variable

        # Null literals use 'is/is not' as (in)equality operators, while other values use '=/<>'.
        if any((isinstance(self.left, Literal) and self.left.value is None,
                isinstance(self.right, Literal) and self.right.value is None)):
            translation_table = {
                u'=': (u'IS', regular_operator_format),
                u'!=': (u'IS NOT', regular_operator_format),
            }
        else:
            translation_table = {
                u'=': (u'=', regular_operator_format),
                u'!=': (u'<>', regular_operator_format),
                u'>=': (u'>=', regular_operator_format),
                u'<=': (u'<=', regular_operator_format),
                u'>': (u'>', regular_operator_format),
                u'<': (u'<', regular_operator_format),
                u'+': (u'+', regular_operator_format),
                u'||': (u'OR', regular_operator_format),
                u'&&': (u'AND', regular_operator_format),
                u'contains': (u'CONTAINS', regular_operator_format),
                u'intersects': (u'intersect', intersects_operator_format),
                u'has_substring': (None, None),  # must be lowered into compatible form using LIKE

                # MATCH-specific operators
                u'LIKE': (u'LIKE', regular_operator_format),
                u'INSTANCEOF': (u'INSTANCEOF', regular_operator_format),
            }

        match_operator, format_spec = translation_table.get(self.operator, (None, None))
        if not match_operator:
            raise AssertionError(u'Unrecognized operator used: '
                                 u'{} {}'.format(self.operator, self))

        return format_spec % dict(operator=match_operator,
                                  left=self.left.to_match(),
                                  right=self.right.to_match())
942729
def convert(origin, target, type):
    
    _origin = origin.upper()
    if _origin == 'ROOTCODE':
        _origin = root_type_codes
    elif _origin == 'ROOTNAME':
        _origin = root_type_names
    elif _origin == 'ARRAY':
        _origin = python_codes
    elif _origin == 'NUMPY':
        _origin = numpy_codes
    else:
        raise ValueError("{0} is not a valid type".format(origin))

    _target = target.upper()
    if _target == 'ROOTCODE':
        _target = root_type_codes
    elif _target == 'ROOTNAME':
        _target = root_type_names
    elif _target == 'ARRAY':
        _target = python_codes
    elif _target == 'NUMPY':
        _target = numpy_codes
    else:
        raise ValueError("{0} is not a valid type".format(target))

    if type not in _origin:
        raise ValueError("{0} is not a valid {1} type".format(type, origin))

    return _target[_origin.index(type)]
193080
def to_type(f, type_map=CONSTRUCT_CODE):
  
  name = f.type_id
  if name.startswith('GPSTime'):
    name = 'Gps' + name[3:]
  if type_map.get(name, None):
    return type_map.get(name, None)
  elif name == 'array':
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    return "[%s]" % to_type(f_)
  return name
486376
def decompose_code(code):
    
    code = "%-6s" % code
    ind1 = code[3:4]
    if ind1 == " ": ind1 = "_"
    ind2 = code[4:5]
    if ind2 == " ": ind2 = "_"
    subcode = code[5:6]
    if subcode == " ": subcode = None
    return (code[0:3], ind1, ind2, subcode)
977096
def code(self, code=None, ret_r=False):
        '''
        
        '''
        if code or ret_r:
            self._code = code
            return self
        return self._code
843402
def proj4_to_epsg(projection):
    """"""

    def make_definition(value):
        return {x.strip().lower() for x in value.split('+') if x}

    # Use the EPSG in the definition if available
    match = EPSG_RE.search(projection.srs)
    if match:
        return int(match.group(1))

    # Otherwise, try to look up the EPSG from the pyproj data file
    pyproj_data_dir = os.path.join(os.path.dirname(pyproj.__file__), 'data')
    pyproj_epsg_file = os.path.join(pyproj_data_dir, 'epsg')
    if os.path.exists(pyproj_epsg_file):
        definition = make_definition(projection.srs)
        f = open(pyproj_epsg_file, 'r')
        for line in f.readlines():
            match = PYPROJ_EPSG_FILE_RE.search(line)
            if match:
                file_definition = make_definition(match.group(2))
                if definition == file_definition:
                    return int(match.group(1))
    return None
170615
def _encode_mapping(name, value, check_keys, opts):
    """"""
    data = b"".join([_element_to_bson(key, val, check_keys, opts)
                     for key, val in iteritems(value)])
    return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
703362
def encode(i, *, width=-1):
        
        if i < 0:
            raise ValueError("value is negative")
        assert width != 0
        data = bytearray()
        while i:
            data.append(i & 127)
            i >>= 7
        if width > 0 and len(data) > width:
            raise ValueError("Integer too large")
        if len(data) < abs(width):
            data.extend([0] * (abs(width) - len(data)))
        data.reverse()
        return data
393921
def _cint(col, _map={base26(i): i - 1 for i in range(1, 257)}):
        
        try:
            return _map[col.upper()]
        except KeyError:
            raise ValueError(col)