Extract all keys (with values) from `src` dictionary as new dictionary

    values are removed from source dictionary.
546912
def popdict(src, keys):
    
    new = {}
    for key in keys:
        if key in src:
            new[key] = src.pop(key)
    return new
1154084
def dump_dict(self, dump=None):
        """"""

        dump_dict = dict()

        warnings = self.get_warnings()
        if warnings:
            dump_dict['Parsing Warnings'] = warnings

        dump_dict['DOS_HEADER'] = self.DOS_HEADER.dump_dict()
        dump_dict['NT_HEADERS'] = self.NT_HEADERS.dump_dict()
        dump_dict['FILE_HEADER'] = self.FILE_HEADER.dump_dict()

        image_flags = retrieve_flags(IMAGE_CHARACTERISTICS, 'IMAGE_FILE_')

        dump_dict['Flags'] = list()
        for flag in image_flags:
            if getattr(self.FILE_HEADER, flag[0]):
                dump_dict['Flags'].append(flag[0])

        if hasattr(self, 'OPTIONAL_HEADER') and self.OPTIONAL_HEADER is not None:
            dump_dict['OPTIONAL_HEADER'] = self.OPTIONAL_HEADER.dump_dict()

        dll_characteristics_flags = retrieve_flags(DLL_CHARACTERISTICS, 'IMAGE_DLLCHARACTERISTICS_')

        dump_dict['DllCharacteristics'] = list()
        for flag in dll_characteristics_flags:
            if getattr(self.OPTIONAL_HEADER, flag[0]):
                dump_dict['DllCharacteristics'].append(flag[0])

        dump_dict['PE Sections'] = list()

        section_flags = retrieve_flags(SECTION_CHARACTERISTICS, 'IMAGE_SCN_')
        for section in self.sections:
            section_dict = section.dump_dict()
            dump_dict['PE Sections'].append(section_dict)
            section_dict['Flags'] = list()
            for flag in section_flags:
                if getattr(section, flag[0]):
                    section_dict['Flags'].append(flag[0])

            section_dict['Entropy'] = section.get_entropy()
            if md5 is not None:
                section_dict['MD5'] = section.get_hash_md5()
            if sha1 is not None:
                section_dict['SHA1'] = section.get_hash_sha1()
            if sha256 is not None:
                section_dict['SHA256'] = section.get_hash_sha256()
            if sha512 is not None:
                section_dict['SHA512'] = section.get_hash_sha512()



        if (hasattr(self, 'OPTIONAL_HEADER') and
            hasattr(self.OPTIONAL_HEADER, 'DATA_DIRECTORY') ):

            dump_dict['Directories'] = list()

            for idx in range(len(self.OPTIONAL_HEADER.DATA_DIRECTORY)):
                directory = self.OPTIONAL_HEADER.DATA_DIRECTORY[idx]
                dump_dict['Directories'].append(directory.dump_dict())

        if hasattr(self, 'VS_VERSIONINFO'):
            dump_dict['Version Information'] = list()
            for idx in range(len(self.VS_VERSIONINFO)):
                version_info_list = list()
                version_info_list.append(self.VS_VERSIONINFO[idx].dump_dict())

                if hasattr(self, 'VS_FIXEDFILEINFO'):
                    version_info_list.append(self.VS_FIXEDFILEINFO[idx].dump_dict())

                if hasattr(self, 'FileInfo'):
                    fileinfo_list = list()
                    for entry in self.FileInfo[idx]:
                        fileinfo_list.append(entry.dump_dict())

                        if hasattr(entry, 'StringTable'):
                            stringtable_dict = dict()
                            for st_entry in entry.StringTable:
                                [fileinfo_list.append(line) for line in st_entry.dump_dict()]
                                stringtable_dict['LangID'] = st_entry.LangID
                                for str_entry in list(st_entry.entries.items()):
                                    stringtable_dict[str_entry[0]] = str_entry[1]
                            fileinfo_list.append(stringtable_dict)


                        elif hasattr(entry, 'Var'):
                            for var_entry in entry.Var:
                                var_dict = dict()
                                if hasattr(var_entry, 'entry'):
                                    [fileinfo_list.append(line) for line in var_entry.dump_dict()]
                                    var_dict[list(var_entry.entry.keys())[0]] = list(
                                        var_entry.entry.values())[0]
                                    fileinfo_list.append(var_dict)

                dump_dict['Version Information'].append(version_info_list)

        if hasattr(self, 'DIRECTORY_ENTRY_EXPORT'):
            dump_dict['Exported symbols'] = list()
            dump_dict['Exported symbols'].append(self.DIRECTORY_ENTRY_EXPORT.struct.dump_dict())
            for export in self.DIRECTORY_ENTRY_EXPORT.symbols:
                export_dict = dict()
                if export.address is not None:
                    export_dict.update({'Ordinal': export.ordinal, 'RVA': export.address, 'Name': export.name})
                    if export.forwarder:
                        export_dict['forwarder'] = export.forwarder
                dump_dict['Exported symbols'].append(export_dict)

        if hasattr(self, 'DIRECTORY_ENTRY_IMPORT'):
            dump_dict['Imported symbols'] = list()
            for module in self.DIRECTORY_ENTRY_IMPORT:
                import_list = list()
                dump_dict['Imported symbols'].append(import_list)
                import_list.append(module.struct.dump_dict())
                for symbol in module.imports:
                    symbol_dict = dict()
                    if symbol.import_by_ordinal is True:
                        symbol_dict['DLL'] = module.dll
                        symbol_dict['Ordinal'] = symbol.ordinal
                    else:
                        symbol_dict['DLL'] = module.dll
                        symbol_dict['Name'] = symbol.name
                        symbol_dict['Hint'] = symbol.hint

                    if symbol.bound:
                        symbol_dict['Bound'] = symbol.bound
                    import_list.append(symbol_dict)


        if hasattr(self, 'DIRECTORY_ENTRY_BOUND_IMPORT'):
            dump_dict['Bound imports'] = list()
            for bound_imp_desc in self.DIRECTORY_ENTRY_BOUND_IMPORT:
                bound_imp_desc_dict = dict()
                dump_dict['Bound imports'].append(bound_imp_desc_dict)

                bound_imp_desc_dict.update(bound_imp_desc.struct.dump_dict())
                bound_imp_desc_dict['DLL'] = bound_imp_desc.name

                for bound_imp_ref in bound_imp_desc.entries:
                    bound_imp_ref_dict = dict()
                    bound_imp_ref_dict.update(bound_imp_ref.struct.dump_dict())
                    bound_imp_ref_dict['DLL'] = bound_imp_ref.name


        if hasattr(self, 'DIRECTORY_ENTRY_DELAY_IMPORT'):
            dump_dict['Delay Imported symbols'] = list()
            for module in self.DIRECTORY_ENTRY_DELAY_IMPORT:
                module_list = list()
                dump_dict['Delay Imported symbols'].append(module_list)
                module_list.append(module.struct.dump_dict())

                for symbol in module.imports:
                    symbol_dict = dict()
                    if symbol.import_by_ordinal is True:
                        symbol_dict['DLL'] = module.dll
                        symbol_dict['Ordinal'] = symbol.ordinal
                    else:
                        symbol_dict['DLL'] = module.dll
                        symbol_dict['Name'] = symbol.name
                        symbol_dict['Hint'] = symbol.hint

                    if symbol.bound:
                        symbol_dict['Bound'] = symbol.bound
                    module_list.append(symbol_dict)


        if hasattr(self, 'DIRECTORY_ENTRY_RESOURCE'):
            dump_dict['Resource directory'] = list()
            dump_dict['Resource directory'].append(self.DIRECTORY_ENTRY_RESOURCE.struct.dump_dict())

            for resource_type in self.DIRECTORY_ENTRY_RESOURCE.entries:
                resource_type_dict = dict()

                if resource_type.name is not None:
                    resource_type_dict['Name'] = resource_type.name
                else:
                    resource_type_dict['Id'] = (
                        resource_type.struct.Id, RESOURCE_TYPE.get(resource_type.struct.Id, '-'))

                resource_type_dict.update(resource_type.struct.dump_dict())
                dump_dict['Resource directory'].append(resource_type_dict)

                if hasattr(resource_type, 'directory'):
                    directory_list = list()
                    directory_list.append(resource_type.directory.struct.dump_dict())
                    dump_dict['Resource directory'].append(directory_list)

                    for resource_id in resource_type.directory.entries:
                        resource_id_dict = dict()

                        if resource_id.name is not None:
                            resource_id_dict['Name'] = resource_id.name
                        else:
                            resource_id_dict['Id'] = resource_id.struct.Id

                        resource_id_dict.update(resource_id.struct.dump_dict())
                        directory_list.append(resource_id_dict)

                        if hasattr(resource_id, 'directory'):
                            resource_id_list = list()
                            resource_id_list.append(resource_id.directory.struct.dump_dict())
                            directory_list.append(resource_id_list)

                            for resource_lang in resource_id.directory.entries:
                                if hasattr(resource_lang, 'data'):
                                    resource_lang_dict = dict()
                                    resource_lang_dict['LANG'] = resource_lang.data.lang
                                    resource_lang_dict['SUBLANG'] = resource_lang.data.sublang
                                    resource_lang_dict['LANG_NAME'] = LANG.get(resource_lang.data.lang, '*unknown*')
                                    resource_lang_dict['SUBLANG_NAME'] = get_sublang_name_for_lang(resource_lang.data.lang, resource_lang.data.sublang)
                                    resource_lang_dict.update(resource_lang.struct.dump_dict())
                                    resource_lang_dict.update(resource_lang.data.struct.dump_dict())
                                    resource_id_list.append(resource_lang_dict)
                            if hasattr(resource_id.directory, 'strings') and resource_id.directory.strings:
                                for idx, res_string in list(resource_id.directory.strings.items()):
                                    resource_id_list.append(res_string.encode(
                                            'unicode-escape',
                                            'backslashreplace').decode(
                                                'ascii'))


        if ( hasattr(self, 'DIRECTORY_ENTRY_TLS') and
             self.DIRECTORY_ENTRY_TLS and
             self.DIRECTORY_ENTRY_TLS.struct ):
            dump_dict['TLS'] = self.DIRECTORY_ENTRY_TLS.struct.dump_dict()


        if ( hasattr(self, 'DIRECTORY_ENTRY_LOAD_CONFIG') and
             self.DIRECTORY_ENTRY_LOAD_CONFIG and
             self.DIRECTORY_ENTRY_LOAD_CONFIG.struct ):
            dump_dict['LOAD_CONFIG'] = self.DIRECTORY_ENTRY_LOAD_CONFIG.struct.dump_dict()


        if hasattr(self, 'DIRECTORY_ENTRY_DEBUG'):
            dump_dict['Debug information'] = list()
            for dbg in self.DIRECTORY_ENTRY_DEBUG:
                dbg_dict = dict()
                dump_dict['Debug information'].append(dbg_dict)
                dbg_dict.update(dbg.struct.dump_dict())
                dbg_dict['Type'] = DEBUG_TYPE.get(dbg.struct.Type, dbg.struct.Type)


        if self.has_relocs():
            dump_dict['Base relocations'] = list()
            for base_reloc in self.DIRECTORY_ENTRY_BASERELOC:
                base_reloc_list = list()
                dump_dict['Base relocations'].append(base_reloc_list)
                base_reloc_list.append(base_reloc.struct.dump_dict())
                for reloc in base_reloc.entries:
                    reloc_dict = dict()
                    base_reloc_list.append(reloc_dict)
                    reloc_dict['RVA'] = reloc.rva
                    try:
                        reloc_dict['Type'] = RELOCATION_TYPE[reloc.type][16:]
                    except KeyError:
                        reloc_dict['Type'] = reloc.type

        return dump_dict
1085311
def _merge_unbound_var_dicts(src, dst):
  """"""
  for k, v in six.iteritems(src):
    if dst.get(k, v) != v:
      trace1 = ''.join(scopes.skip_common_stack_elements(v.stacktrace, dst[
          k].stacktrace))
      trace2 = ''.join(
          scopes.skip_common_stack_elements(dst[k].stacktrace, v.stacktrace))
      raise ValueError('Key conflict: %s\nDefined At:\n%s\nand\n%s' %
                       (k, trace1, trace2))
    else:
      dst[k] = v
1295860
def sanitize_dict(input_dict):
    
    """
    plain_dict = dict()
    for key in input_dict.keys():
        value = input_dict[key]
        if hasattr(value, 'keys'):
            plain_dict[key] = sanitize_dict(value)
        else:
            plain_dict[key] = value
    return plain_dict
61687
def extract_headers(headers):
    """"""
    sorted_headers = {}
    matches = re.findall(r'(.*):\s(.*)', headers)
    for match in matches:
        header = match[0]
        value = match[1]
        try:
            if value[-1] == ',':
                value = value[:-1]
            sorted_headers[header] = value
        except IndexError:
            pass
    return sorted_headers
919107
def clean_dict_keys(d):
    
    new_d = {}
    for (k, v) in d.iteritems():
        new_d[str(k)] = v
    return new_d
1274622
def key_dict( from_dict ):
	
	new_dict = {}
	old2new = {}
	new2old = {}
	for key in from_dict:
		k = normalizeUnicode(key,'identifier')
		if k != key:
			i = ''
			while new_dict.has_key("%s%s" % (k,i) ):
				if not i:
					i = 1
				else:
					i += 1
			k = "%s%s" % (k,i)
			old2new[key] = k
			new2old[k] = key
		new_dict[k] = from_dict[key]
	return (new_dict.keys(), new_dict, old2new, new2old)
914470
def to_dict(self, omit=()):
        
        result = self.__dict__.copy()
        for key in omit:
            if key in result:
                del result[key]
        return result
358259
def stringify_dict_contents(dct):
    """"""
    return {
        str_if_nested_or_str(k): str_if_nested_or_str(v)
        for k, v in dct.items()
    }
1141117
def dict_values(src):
    
    for v in src.values():
        if isinstance(v, dict):
            for v in dict_values(v):
                yield v
        else:
            yield v
738126
function extract(sources, options) {
		return sources
			.map(function(src) {
				return [src, grunt.file.read(src)];
			})
			.filter(function(list) {
				return syntax.valid(grunt, list[0], list[1]);
			})
			.map(function(list) {
				return extras(list[0], list[1], options);
			});
	}
283728
def _remove_keys_from_dict_with_nonunique_values(self, d, log_fh=None, log_outprefix=None):
        ''''''
        value_counts = collections.Counter(d.values())
        new_d = {}
        writing_log_file = None not in [log_fh, log_outprefix]

        for key in d:
            if value_counts[d[key]] == 1:
                new_d[key] = d[key]
            elif writing_log_file:
                print(log_outprefix, 'Reject because non-unique:', d[key], sep='\t', file=log_fh)

        return new_d
515723
def expand_src_param(values, shp_params):
    
    if values is None:
        return dict([(key, None) for key, _ in shp_params])
    else:
        num_values = len(values)
        return dict(
            [(key, float(values[i]) if i < num_values else None)
                for i, (key, _) in enumerate(shp_params)])
1317766
def unused(self, _dict):
        
        for key, value in _dict.items():
            if value is None:
                del _dict[key]
        return _dict
1212156
def slurp_properties(source, destination, ignore=[], srckeys=None):
    
    if srckeys is None:
        srckeys = source.__all__
    destination.update(dict([(name, getattr(source, name))
                              for name in srckeys
                                if not (name.startswith('__') or name in ignore)
                            ]))
188677
def reconstruct_dict(dot_paths, values):
    
    '''  '''
    
    output_dict = {}
    
    for i in range(len(dot_paths)):
        if i + 1 <= len(values):
            path_segments = segment_path(dot_paths[i])
            current_nest = output_dict
            for j in range(len(path_segments)):
                key_name = path_segments[j]
                try:
                    key_name = int(key_name)
                except:
                    pass
                if j + 1 == len(path_segments):
                    if isinstance(key_name, int):
                        current_nest.append(values[i])
                    else:
                        current_nest[key_name] = values[i]
                else:
                    next_key = path_segments[j+1]
                    try:
                        next_key = int(next_key)
                    except:
                        pass
                    if isinstance(next_key, int):
                        if not key_name in current_nest.keys():
                            current_nest[key_name] = []
                        current_nest = current_nest[key_name]
                    else:
                        if isinstance(key_name, int):
                            current_nest.append({})
                            current_nest = current_nest[len(current_nest) - 1]
                        else:
                            if not key_name in current_nest.keys():
                                current_nest[key_name] = {}
                            current_nest = current_nest[key_name]
    
    return output_dict
87082
def dict_strip(d):
    
    _d = deepcopy(d)
    for k, v in iteritems(d):
        if isinstance(v, str):
            _d[k] = v.strip()
        elif isinstance(v, dict):
            _d[k] = dict_strip(v)

    return _d