def _convert_hexstr_base(hexstr, base):
if base is _ALPHABET_16:<EOL><INDENT>return hexstr<EOL><DEDENT>baselen = len(base)<EOL>x = int(hexstr, <NUM_LIT:16>)  <EOL>if x == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT:0>'<EOL><DEDENT>sign = <NUM_LIT:1> if x > <NUM_LIT:0> else -<NUM_LIT:1><EOL>x *= sign<EOL>digits = []<EOL>while x:<EOL><INDENT>digits.append(base[x % baselen])<EOL>x //= baselen<EOL><DEDENT>if sign < <NUM_LIT:0>:<EOL><INDENT>digits.append('<STR_LIT:->')<EOL><DEDENT>digits.reverse()<EOL>newbase_str = '<STR_LIT>'.join(digits)<EOL>return newbase_str<EOL>
r"""
    Packs a long hexstr into a shorter length string with a larger base.

    Args:
        hexstr (str): string of hexidecimal symbols to convert
        base (list): symbols of the conversion base

    Example:
        >>> print(_convert_hexstr_base('ffffffff', _ALPHABET_26))
        nxmrlxv
        >>> print(_convert_hexstr_base('0', _ALPHABET_26))
        0
        >>> print(_convert_hexstr_base('-ffffffff', _ALPHABET_26))
        -nxmrlxv
        >>> print(_convert_hexstr_base('aafffff1', _ALPHABET_16))
        aafffff1

    Sympy:
        >>> import sympy as sy
        >>> # Determine the length savings with lossless conversion
        >>> consts = dict(hexbase=16, hexlen=256, baselen=27)
        >>> symbols = sy.symbols('hexbase, hexlen, baselen, newlen')
        >>> haexbase, hexlen, baselen, newlen = symbols
        >>> eqn = sy.Eq(16 ** hexlen,  baselen ** newlen)
        >>> newlen_ans = sy.solve(eqn, newlen)[0].subs(consts).evalf()
        >>> print('newlen_ans = %r' % (newlen_ans,))
        >>> # for a 26 char base we can get 216
        >>> print('Required length for lossless conversion len2 = %r' % (len2,))
        >>> def info(base, len):
        ...     bits = base ** len
        ...     print('base = %r' % (base,))
        ...     print('len = %r' % (len,))
        ...     print('bits = %r' % (bits,))
        >>> info(16, 256)
        >>> info(27, 16)
        >>> info(27, 64)
        >>> info(27, 216)