Make a dictionary to print.
490612
def _options_to_dict(df):
    """"""
    kolums = ["k1", "k2", "value"]
    d = df[kolums].values.tolist()
    dc = {}
    for x in d:
        dc.setdefault(x[0], {})
        dc[x[0]][x[1]] = x[2]
    return dc
692393
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self, 'user') and self.user is not None:
            _dict['user'] = self.user
        return _dict
952635
def printtable(h, header):
    """"""
    hk = header_fields(h)
    if (header):
        printheader()
    writer = csv.DictWriter(sys.stdout, hk, extrasaction='ignore')
    writer.writerow(h)
794464
public void writeDict(PrintWriter fout) throws IOException {
	Iterator it = null;
	int count = 0;

	for (it = dict.keySet().iterator(); it.hasNext(); ) {
	    Integer cpInt = (Integer)it.next();
	    Element elem = (Element)dict.get(cpInt);
	    
	    if (elem.chosen == 1) {
		count++;
	    }
	}
	
	// write the dictionary size
	fout.println(Integer.toString(count));	
	
	for (it = dict.keySet().iterator(); it.hasNext(); ) {    
	
	    Integer cpInt = (Integer)it.next();
	    Element elem = (Element)dict.get(cpInt);
	    
	    if (elem.chosen == 0) {
		continue;
	    }
	    
	    // write the context predicate and its count
	    fout.print(cpInt.toString() + ":" + Integer.toString(elem.count));
	    
	    for (Iterator lbIt = elem.lbCntFidxes.keySet().iterator(); lbIt.hasNext(); ) {
		Integer labelInt = (Integer)lbIt.next();
		CountFIdx cntFIdx = (CountFIdx)elem.lbCntFidxes.get(labelInt);
	
		if (cntFIdx.fidx < 0) {
		    continue;
		}
	
		fout.print(" " + labelInt.toString() + ":" + 
			    Integer.toString(cntFIdx.count) + ":" +
			    Integer.toString(cntFIdx.fidx));		
	    }
	    
	    fout.println();
	}
	
	// write the line ###...
	fout.println(Option.modelSeparator);
    }
694775
def dump_dict_to_file(dictionary, filepath):
    """"""
    create_dirs(
        os.path.dirname(filepath)
    )

    with open(filepath, 'a') as outfile:
        json.dump(dictionary, outfile)
        outfile.write('\n')
353448
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'examples') and self.examples is not None:
            _dict['examples'] = [x._to_dict() for x in self.examples]
        if hasattr(self, 'pagination') and self.pagination is not None:
            _dict['pagination'] = self.pagination._to_dict()
        return _dict
1309426
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'pdf' in _dict:
            args['pdf'] = PdfSettings._from_dict(_dict.get('pdf'))
        if 'word' in _dict:
            args['word'] = WordSettings._from_dict(_dict.get('word'))
        if 'html' in _dict:
            args['html'] = HtmlSettings._from_dict(_dict.get('html'))
        if 'segment' in _dict:
            args['segment'] = SegmentSettings._from_dict(_dict.get('segment'))
        if 'json_normalizations' in _dict:
            args['json_normalizations'] = [
                NormalizationOperation._from_dict(x)
                for x in (_dict.get('json_normalizations'))
            ]
        return cls(**args)
1358939
def print_header(self):
        """"""
        lines_to_print = []
        lines_to_print.append('##fileformat='+self.fileformat)
        if self.filedate:
            lines_to_print.append('##fileformat='+self.fileformat)
            
        for filt in self.filter_dict:
            lines_to_print.append(self.filter_dict[filt])
        for form in self.format_dict:
            lines_to_print.append(self.format_dict[form])
        for info in self.info_dict:
            lines_to_print.append(self.info_dict[info])
        for contig in self.contig_dict:
            lines_to_print.append(self.contig_dict[contig])
        for alt in self.alt_dict:
            lines_to_print.append(self.alt_dict[alt])
        for other in self.other_dict:
            lines_to_print.append(self.other_dict[other])
        lines_to_print.append('#'+ '\t'.join(self.header))
        return lines_to_print
1152321
def print_table(self, sparse=False, file=None, sep='\t'):
        '''
        
        '''

        for kmer, count in sorted(self.to_dict(sparse=sparse).items()):
            print(kmer, count, sep=sep, file=file)
395523
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'location' in _dict:
            args['location'] = Location._from_dict(_dict.get('location'))
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'types' in _dict:
            args['types'] = [
                TypeLabel._from_dict(x) for x in (_dict.get('types'))
            ]
        if 'categories' in _dict:
            args['categories'] = [
                Category._from_dict(x) for x in (_dict.get('categories'))
            ]
        if 'attributes' in _dict:
            args['attributes'] = [
                Attribute._from_dict(x) for x in (_dict.get('attributes'))
            ]
        return cls(**args)
1212437
def _format_args():
        """"""
        if request and request.args.get('prettyprint'):
            return dict(
                indent=2,
                separators=(', ', ': '),
            )
        else:
            return dict(
                indent=None,
                separators=(',', ':'),
            )
1005931
def setup_dictionary(self, task):
        """"""

        dictionary_options = task.get('dictionary', {})
        output = os.path.abspath(dictionary_options.get('output', self.dict_bin))
        lang = dictionary_options.get('lang', 'en_US')
        wordlists = dictionary_options.get('wordlists', [])
        if lang and wordlists:
            self.compile_dictionary(lang, dictionary_options.get('wordlists', []), None, output)
        else:
            output = None
        return output
274871
def sprint(string, *args, **kwargs):
    """"""
    try:
        print(string, *args, **kwargs)
    except UnicodeEncodeError:
        string = string.encode('utf-8', errors='ignore')\
                       .decode('ascii', errors='ignore')
        print(string, *args, **kwargs)
288944
def print(self):
        
        print(tabulate(
            ((i, *row) for i, row in enumerate(self.results, 1)),
            headers=self.headers,
        ))
131207
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'word' in _dict:
            args['word'] = _dict.get('word')
        else:
            raise ValueError(
                'Required property \'word\' not present in Word JSON')
        if 'sounds_like' in _dict:
            args['sounds_like'] = _dict.get('sounds_like')
        else:
            raise ValueError(
                'Required property \'sounds_like\' not present in Word JSON')
        if 'display_as' in _dict:
            args['display_as'] = _dict.get('display_as')
        else:
            raise ValueError(
                'Required property \'display_as\' not present in Word JSON')
        if 'count' in _dict:
            args['count'] = _dict.get('count')
        else:
            raise ValueError(
                'Required property \'count\' not present in Word JSON')
        if 'source' in _dict:
            args['source'] = _dict.get('source')
        else:
            raise ValueError(
                'Required property \'source\' not present in Word JSON')
        if 'error' in _dict:
            args['error'] = [
                WordError._from_dict(x) for x in (_dict.get('error'))
            ]
        return cls(**args)
1226824
def _PrintDictAsTable(self, src_dict):
    
    key_list = list(src_dict.keys())
    key_list.sort()

    print('|', end='')
    for key in key_list:
      print(' {0:s} |'.format(key), end='')
    print('')

    print('|', end='')
    for key in key_list:
      print(' :---: |', end='')
    print('')

    print('|', end='')
    for key in key_list:
      print(' {0!s} |'.format(src_dict[key]), end='')
    print('\n')
421793
def make_dict(cls, table):
        
        ret_dict = {}
        for row in table:
            file_handle = cls.create_from_row(row)
        ret_dict[file_handle.key] = file_handle
        return ret_dict