Return the set of IMAP flags that correspond to the letter codes.

        Args:
            codes: The letter codes to map.
493460
def from_maildir(self, codes: str) -> FrozenSet[Flag]:
        
        flags = set()
        for code in codes:
            if code == ',':
                break
            to_sys = self._to_sys.get(code)
            if to_sys is not None:
                flags.add(to_sys)
            else:
                to_kwd = self._to_kwd.get(code)
                if to_kwd is not None:
                    flags.add(to_kwd)
        return frozenset(flags)
1097761
def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]:
    
    codes = get_code_indices(s)
    if not codes:
        # This function is not for non-escape-code stuff, but okay.
        return {i: c for i, c in enumerate(s)}

    indices = {}
    for codeindex in sorted(codes):
        code = codes[codeindex]
        if codeindex == 0:
            indices[codeindex] = code
            continue
        # Grab characters before codeindex.
        start = max(indices or {0: ''}, key=int)
        startcode = indices.get(start, '')
        startlen = start + len(startcode)
        indices.update({i: s[i] for i in range(startlen, codeindex)})
        indices[codeindex] = code

    if not indices:
        return {i: c for i, c in enumerate(s)}
    lastindex = max(indices, key=int)
    lastitem = indices[lastindex]
    start = lastindex + len(lastitem)
    textlen = len(s)
    if start < (textlen - 1):
        # Grab chars after last code.
        indices.update({i: s[i] for i in range(start, textlen)})
    return indices
288450
def to_maildir(self, flags: Iterable[Union[bytes, Flag]]) -> str:
        
        codes = []
        for flag in flags:
            if isinstance(flag, bytes):
                flag = Flag(flag)
            from_sys = self._from_sys.get(flag)
            if from_sys is not None:
                codes.append(from_sys)
            else:
                from_kwd = self._from_kwd.get(flag)
                if from_kwd is not None:
                    codes.append(from_kwd)
        return ''.join(codes)
1283105
Set<OpensFlag> readOpensFlags(int flags) {
        Set<OpensFlag> set = EnumSet.noneOf(OpensFlag.class);
        for (OpensFlag f: OpensFlag.values()) {
            if ((flags & f.value) != 0)
                set.add(f);
        }
        return set;
    }
571574
def _get_keycodes():
    
    try:
        return _key_cache.pop()
    except IndexError:
        pass
    result = []
    terminators = 'ABCDFHPQRS~'
    with TerminalContext():
        code = get_ord()
        result.append(code)
        if code == 27:
            with TimerContext(0.1) as timer:
                code = get_ord()
            if not timer.timed_out:
                result.append(code)
                result.append(get_ord())
                if 64 < result[-1] < 69:
                    pass
                elif result[1] == 91:
                    while True:
                        code = get_ord()
                        result.append(code)
                        if chr(code) in terminators:
                            break
    return tuple(result)
1211333
def hex2ansi(code):
    

    if code.startswith('#'):
        code = code[1:]

    if len(code) == 3:
        # efc -> eeffcc
        return rgb2ansi(*map(lambda o: int(o * 2, 16), code))

    if len(code) != 6:
        raise ValueError('invalid color code')

    rgb = (code[:2], code[2:4], code[4:])
    return rgb2ansi(*map(lambda o: int(o, 16), rgb))
921267
function flag(input) {
  if (!CODE_RE.test(input) || input === 'UK') {
    input = nameToCode(input);
  }

  return codeToFlag(input);
}
33577
public Collection<String> getCurrencyCodes() {
        Collection<String> result = get(KEY_QUERY_CURRENCY_CODES, Collection.class);
        if (result == null) {
            return Collections.emptySet();
        }
        return result;
    }
214574
def get_system_flags() -> FrozenSet[Flag]:
    """"""
    return frozenset({Seen, Recent, Deleted, Flagged, Answered, Draft})
646347
def barcode(opts = {})
      data = format_for_subset_c_if_applicable send(barcodable)
      if (subset = opts[:subset])
        case subset
        when 'A'; Barby::Code128A.new data
        when 'B'; Barby::Code128B.new data
        when 'C'; Barby::Code128C.new data
        end
      else
        most_efficient_barcode_for data
      end
    end
14846
def get_key_codes(keys):
    
    keys = keys.strip().upper().split('+')
    codes = list()
    for key in keys:
        code = ks_settings.KEY_CODES.get(key.strip())
        if code:
            codes.append(code)
    return codes
1360346
def letter_set(self):
        
        end_str = ctypes.create_string_buffer(MAX_CHARS)

        cgaddag.gdg_letter_set(self.gdg, self.node, end_str)

        return [char for char in end_str.value.decode("ascii")]
704658
def _regex_from_encoded_pattern(s):
    """'
    """
    if s.startswith('/') and s.rfind('/') != 0:
        # Parse it: /PATTERN/FLAGS
        idx = s.rfind('/')
        pattern, flags_str = s[1:idx], s[idx+1:]
        flag_from_char = {
            "i": re.IGNORECASE,
            "l": re.LOCALE,
            "s": re.DOTALL,
            "m": re.MULTILINE,
            "u": re.UNICODE,
        }
        flags = 0
        for char in flags_str:
            try:
                flags |= flag_from_char[char]
            except KeyError:
                raise ValueError("unsupported regex flag: '%s' in '%s' "
                                 "(must be one of '%s')"
                                 % (char, s, ''.join(list(flag_from_char.keys()))))
        return re.compile(s[1:idx], flags)
    else: # not an encoded regex
        return re.compile(re.escape(s))
513428
function (keyCode) {
        return list.contains([
          keyMap.LEFT,
          keyMap.UP,
          keyMap.RIGHT,
          keyMap.DOWN
        ], keyCode);
      }
352055
def pack_nibbles(nibbles):
    

    if nibbles[-1] == NIBBLE_TERMINATOR:
        flags = 2
        nibbles = nibbles[:-1]
    else:
        flags = 0

    oddlen = len(nibbles) % 2
    flags |= oddlen   # set lowest bit if odd number of nibbles
    if oddlen:
        nibbles = [flags] + nibbles
    else:
        nibbles = [flags, 0] + nibbles
    o = b''
    for i in range(0, len(nibbles), 2):
        o += ascii_chr(16 * nibbles[i] + nibbles[i + 1])
    return o
856179
private static void findMethodSignatures(String code, Set<String> signatures) {
    if (code == null) {
      return;
    }
    Matcher matcher = OBJC_METHOD_DECL_PATTERN.matcher(code);
    while (matcher.find()) {
      StringBuilder signature = new StringBuilder();
      signature.append(matcher.group(1));
      if (matcher.group(2) != null) {
        signature.append(':');
        String additionalParams = matcher.group(3);
        if (additionalParams != null) {
          Matcher paramsMatcher = ADDITIONAL_PARAM_PATTERN.matcher(additionalParams);
          while (paramsMatcher.find()) {
            signature.append(paramsMatcher.group(1)).append(':');
          }
        }
      }
      signatures.add(signature.toString());
    }
  }
279239
def symbols(self):
        """"""
        def _iter_symbols(symbol_values):
            # The initial charset doesn't matter, as the start codes have the same symbol values in all charsets.
            charset = 'A'

            shift_charset = None
            for symbol_value in symbol_values:
                if shift_charset:
                    symbol = self._val2sym[shift_charset][symbol_value]
                    shift_charset = None
                else:
                    symbol = self._val2sym[charset][symbol_value]

                if symbol in (self.Special.START_A, self.Special.CODE_A):
                    charset = 'A'
                elif symbol in (self.Special.START_B, self.Special.CODE_B):
                    charset = 'B'
                elif symbol in (self.Special.START_C, self.Special.CODE_C):
                    charset = 'C'
                elif symbol in (self.Special.SHIFT_A,):
                    shift_charset = 'A'
                elif symbol in (self.Special.SHIFT_B,):
                    shift_charset = 'B'

                yield symbol

        return list(_iter_symbols(self.symbol_values))