Locate the appropriate freezer given FREEZER or string input from the programmer.

    :param freezer: FREEZER constant or string for the freezer that is requested.  (None = FREEZER.DEFAULT)
    :return:
969653
def resolve_freezer(freezer):
    
    # Set default freezer if there was none
    if not freezer:
        return _Default()

    # Allow character based lookups as well
    if isinstance(freezer, six.string_types):
        cls = _freezer_lookup(freezer)
        return cls()

    # Allow plain class definition lookups (we instantiate the class)
    if freezer.__class__ == type.__class__:
        return freezer()

    # Warn when a custom freezer implementation is used.
    if freezer not in FREEZER.ALL:
        warn(u"Using custom freezer implelmentation: {0}".format(freezer))

    return freezer
866947
def parser(key = "default"):
    """"""
    #Make sure we have a parser for that key. If we don't, then set
    #one up if we know what parameters to use; otherwise return the
    #default parser.
    if key not in _parsers:
        if key == "ssh":
            _parsers["ssh"] = CodeParser(True, False)
        else:
            key = "default"

    return _parsers[key]
930980
def get_parameter_names(self, include_frozen=False):
        
        if include_frozen:
            return self.parameter_names
        return tuple(p
                     for p, f in zip(self.parameter_names, self.unfrozen_mask)
                     if f)
454432
def do_find(self, arg):
        
        if not arg:
            raise CmdError("missing parameter: string")
        process = self.get_process_from_prefix()
        self.find_in_memory(arg, process)
795589
def inputcooker(self):
        
        try:
            while True:
                c = self._inputcooker_getc()
                if not self.iacseq:
                    if c == IAC:
                        self.iacseq += c
                        continue
                    elif c == chr(13) and not(self.sb):
                        c2 = self._inputcooker_getc(block=False)
                        if c2 == theNULL or c2 == '':
                            c = chr(10)
                        elif c2 == chr(10):
                            c = c2
                        else:
                            self._inputcooker_ungetc(c2)
                            c = chr(10)
                    elif c in [x[0] for x in self.ESCSEQ.keys()]:
                        'Looks like the begining of a key sequence'
                        codes = c
                        for keyseq in self.ESCSEQ.keys():
                            if len(keyseq) == 0:
                                continue
                            while codes == keyseq[:len(codes)] and len(codes) <= keyseq:
                                if codes == keyseq:
                                    c = self.ESCSEQ[keyseq]
                                    break
                                codes = codes + self._inputcooker_getc()
                            if codes == keyseq:
                                break
                            self._inputcooker_ungetc(codes[1:])
                            codes = codes[0]
                    self._inputcooker_store(c)
                elif len(self.iacseq) == 1:
                    'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]'
                    if c in (DO, DONT, WILL, WONT):
                        self.iacseq += c
                        continue
                    self.iacseq = ''
                    if c == IAC:
                        self._inputcooker_store(c)
                    else:
                        if c == SB: # SB ... SE start.
                            self.sb = 1
                            self.sbdataq = ''
                        elif c == SE: # SB ... SE end.
                            self.sb = 0
                        # Callback is supposed to look into
                        # the sbdataq
                        self.options_handler(self.sock, c, NOOPT)
                elif len(self.iacseq) == 2:
                    cmd = self.iacseq[1]
                    self.iacseq = ''
                    if cmd in (DO, DONT, WILL, WONT):
                        self.options_handler(self.sock, cmd, c)
        except (EOFError, socket.error):
            pass
595254
def freeze(o):
    
    if isinstance(o, (tuple, list)):
        return tuple(sorted(freeze(e) for e in o))

    if isinstance(o, dict):
        return tuple(sorted((k, freeze(v)) for k, v in iteritems(o)))

    if isinstance(o, (set, frozenset)):
        return tuple(sorted(freeze(e) for e in o))

    return o
1077504
def find_one(self, **kwargs):
        
        kwargs["_limit"] = 1
        iterator = self.find(**kwargs)
        try:
            return next(iterator)
        except StopIteration:
            return None
186023
def _scan(self, type):
        
        tok = self._scanner.token(self._pos, frozenset([type]))
        if tok[2] != type:
            err = SyntaxError("SyntaxError[@ char %s: %s]" % (repr(tok[0]), "Trying to find " + type))
            err.pos = tok[0]
            raise err
        self._pos += 1
        return tok[3]
654478
def get_location(model_obj):
    
    the_model = get_model(model_obj)
    line, col = the_model._tx_parser.pos_to_linecol(
        model_obj._tx_position)
    return {"line": line, "col": col, "filename": the_model._tx_filename}
515199
def get_input(prompt, default=None, choices=None, option_value=None):
    
    if option_value is not None:
        return option_value
    
    choices = choices or []
    while 1:
        r = input(prompt+' ').strip()
        if not r and default is not None:
            return default
        if choices:
            if r not in choices:
                r = None
            else:
                break
        else:
            break
    return r
939094
def get_module_constant(module, symbol, default=-1, paths=None):
    """"""

    try:
        f, path, (suffix, mode, kind) = find_module(module, paths)
    except ImportError:
        # Module doesn't exist
        return None

    try:
        if kind == PY_COMPILED:
            f.read(8)  # skip magic & date
            code = marshal.load(f)
        elif kind == PY_FROZEN:
            code = imp.get_frozen_object(module)
        elif kind == PY_SOURCE:
            code = compile(f.read(), path, 'exec')
        else:
            # Not something we can parse; we'll have to import it.  :(
            if module not in sys.modules:
                imp.load_module(module, f, path, (suffix, mode, kind))
            return getattr(sys.modules[module], symbol, None)

    finally:
        if f:
            f.close()

    return extract_constant(code, symbol, default)
553922
def getSource(self):
        
        bracket = self.next()
        # we should only be here because that was a bracket
        if not bracket == u'{':
            raise Exception(u"parse error getting source")
        c = u''
        identifier = u''
        while True:
            c = self.next()
            if not c:
                raise Exception(u"unexpected end of input getting source")
            elif c == u'}':
                break
            else:
                identifier += c
        if not identifier or not isidentifier(identifier):
            raise StringGenerator.SyntaxError(u"not a valid identifier: %s"%identifier)
        return StringGenerator.Source(identifier)
141894
def get_unfrozen_copy(values):
    
    if isinstance(values, (frozendict, dict)):
        return {key: get_unfrozen_copy(value) for key, value in values.items()}
    elif isinstance(values, (list, tuple)):
        return [get_unfrozen_copy(value) for value in values]

    # Nothing to unfreeze.
    return values
758246
def _input_parser_generator(self):
        
        prefix = ''
        retry = False
        flush = False

        while True:
            flush = False

            if retry:
                retry = False
            else:
                # Get next character.
                c = yield

                if c == _Flush:
                    flush = True
                else:
                    prefix += c

            # If we have some data, check for matches.
            if prefix:
                is_prefix_of_longer_match = _IS_PREFIX_OF_LONGER_MATCH_CACHE[prefix]
                match = self._get_match(prefix)

                # Exact matches found, call handlers..
                if (flush or not is_prefix_of_longer_match) and match:
                    self._call_handler(match, prefix)
                    prefix = ''

                # No exact match found.
                elif (flush or not is_prefix_of_longer_match) and not match:
                    found = False
                    retry = True

                    # Loop over the input, try the longest match first and
                    # shift.
                    for i in range(len(prefix), 0, -1):
                        match= self._get_match(prefix[:i])
                        if match:
                            self._call_handler(match, prefix[:i])
                            prefix = prefix[i:]
                            found = True

                    if not found:
                        self._call_handler(prefix[0], prefix[0])
                        prefix = prefix[1:]
214553
def which(editor: str) -> Optional[str]:
    
    try:
        editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT).strip()
        editor_path = editor_path.decode()
    except subprocess.CalledProcessError:
        editor_path = None
    return editor_path
220704
def freeze(obj):
    
    if isinstance(obj, collections.Mapping):
        return FrozenDict({freeze(k): freeze(v) for k, v in six.iteritems(obj)})
    elif isinstance(obj, list):
        return FrozenList([freeze(e) for e in obj])
    else:
        return obj
687554
def _scan(self, type):
        
        tok = self._scanner.token(self._pos, frozenset([type]))
        self._char_pos = tok[0]
        if tok[2] != type:
            raise SyntaxError("SyntaxError[@ char %s: %s]" % (repr(tok[0]), "Trying to find " + type))
        self._pos += 1
        return tok[3]