Returns a header as a list, ready to write to TSV file
14870
def generate_header(headerfields, oldheader, group_by_field):
    """"""
    fieldtypes = ['peptidefdr', 'peptidepep', 'nopsms', 'proteindata',
                  'precursorquant', 'isoquant']
    return generate_general_header(headerfields, fieldtypes,
                                   peptabledata.HEADER_PEPTIDE, oldheader,
                                   group_by_field)
923059
def headers(self):
    '''
    
    '''

    first_header = self.header()
    single_compamp_data = np.frombuffer(self.data, dtype=np.int8)\
        .reshape((first_header['number_of_half_frames'], first_header['half_frame_bytes']))

    return [self._read_half_frame_header(row) for row in single_compamp_data]
402894
def parse_headers(cls, msg):
        
        return list(email.parser.Parser().parsestr(msg).items())
697926
def _get_headers(self):
        

        header = self.lines[0]
        self.lines = self.lines[1:]

        self.headers = \
            [self.clean(h) for h in header.split(self.seperator)]
        if self.is_strip:
            self.headers = self.headers[1:-1]
        return self.headers
982299
def header(self, sheet, name):
        

        header = sheet.row(0)
        for i, column in enumerate(self.headers[name]):
            header.write(i, self.headers[name][i])
801590
def create_header(self):
		
		try:
			self.check_valid()
			_header_list = []
			for k,v in self.inputs.items():
				if v is None:
					return  {self.__class__.__name__.replace('_','-'):None}
				elif k == 'value':
					_header_list.insert(0,str(v))
				elif isinstance(v,bool):
					if v is True: _header_list.append(k)
				elif type(v) is list:
					lambda v: len(v)>0, [_header_list.append(''.join(['pin-%s=%s' % (pink,pinv) for pink, pinv in pin.items()])) for pin in v]
				else:
					_header_list.append('%s=%s' % (k,str(v)))
			return {self.__class__.__name__.replace('_','-'):'; '.join(_header_list)}
		except Exception, e:
			raise
1201313
def to_header(self):
        """"""
        ranges = []
        for begin, end in self.ranges:
            if end is None:
                ranges.append("%s-" % begin if begin >= 0 else str(begin))
            else:
                ranges.append("%s-%s" % (begin, end - 1))
        return "%s=%s" % (self.units, ",".join(ranges))
502123
def get_header(results):
    ''''''
    ret = ['name', ]
    values = next(iter(results.values()))
    for k, v in values.items():
        if isinstance(v, dict):
            for metric in v.keys():
                ret.append('%s:%s' % (k, metric))
        else:
            ret.append(k)
    return ret
1081347
def pretty_list(rtlst, header, sortBy=0, borders=False):
    """"""
    if borders:
        _space = "|"
    else:
        _space = "  "
    # Windows has a fat terminal border
    _spacelen = len(_space) * (len(header) - 1) + (10 if WINDOWS else 0)
    _croped = False
    # Sort correctly
    rtlst.sort(key=lambda x: x[sortBy])
    # Append tag
    rtlst = header + rtlst
    # Detect column's width
    colwidth = [max([len(y) for y in x]) for x in zip(*rtlst)]
    # Make text fit in box (if required)
    width = get_terminal_width()
    if conf.auto_crop_tables and width:
        width = width - _spacelen
        while sum(colwidth) > width:
            _croped = True
            # Needs to be cropped
            # Get the longest row
            i = colwidth.index(max(colwidth))
            # Get all elements of this row
            row = [len(x[i]) for x in rtlst]
            # Get biggest element of this row: biggest of the array
            j = row.index(max(row))
            # Re-build column tuple with the edited element
            t = list(rtlst[j])
            t[i] = t[i][:-2] + "_"
            rtlst[j] = tuple(t)
            # Update max size
            row[j] = len(t[i])
            colwidth[i] = max(row)
    if _croped:
        log_runtime.info("Table cropped to fit the terminal (conf.auto_crop_tables==True)")  # noqa: E501
    # Generate padding scheme
    fmt = _space.join(["%%-%ds" % x for x in colwidth])
    # Append separation line if needed
    if borders:
        rtlst.insert(1, tuple("-" * x for x in colwidth))
    # Compile
    rt = "\n".join(((fmt % x).strip() for x in rtlst))
    return rt
367543
def process_header(self, headers):
        """"""

        return [c.name for c in self.source.dest_table.columns][1:]
773221
def dict_to_table(header, contents):
    
    def to_text(row):
        name, value = row
        m = max_col1_size + 1 - len(name)
        spacing = ' ' * m

        return ''.join([name, spacing, value])

    thead = tuple(str(col) for col in header)
    rows = []
    for name, value in contents.items():
        # code highlighting
        if value != '':
            if isinstance(value, str):
                value = "'{}'".format(value)
            value = ':py:`{}`'.format(value)
        rows.append((name, value))

    n = np.max([len(header[0])] +
               [len(col1) for col1, _ in rows])
    hborder = tuple('='*n for col in header)
    rows = [hborder, thead, hborder] + rows + [hborder]
    max_col1_size = np.max([len(col1) for col1, _ in rows])
    table = '\n'.join([to_text(row) for row in rows])
    return table
618813
def _render_headers(self):
        
        headers = getattr(self, 'headers', ())
        for index, col in enumerate(headers):
            # We write the headers
            cell = self.worksheet.cell(row=1, column=index + 1)
            cell.value = col['label']

        index += 1

        extra_headers = getattr(self, 'extra_headers', ())
        for add_index, col in enumerate(extra_headers):
            cell = self.worksheet.cell(row=1, column=add_index + index + 1)
            cell.value = col['label']
467333
private function writeHeaders()
    {
        $headers = $this->response->getHeaders();
        foreach ($headers as $name => $list) {
            header("$name: " . implode(', ', $list));
        }
    }
1180547
def list_to_workbook(data, title='report', header=None, widths=None):
    
    wb = Workbook()
    title = re.sub(r'\W+', '', title)[:30]

    if isinstance(data, dict):
        i = 0
        for sheet_name, sheet_data in data.items():
            if i > 0:
                wb.create_sheet()
            ws = wb.worksheets[i]
            build_sheet(
                sheet_data, ws, sheet_name=sheet_name, header=header)
            i += 1
    else:
        ws = wb.worksheets[0]
        build_sheet(data, ws, header=header, widths=widths)
    return wb
379175
def wr_tsv(self, fout_tsv):
        """"""
        with open(fout_tsv, 'w') as prt:
            kws_tsv = {
                'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'},
                'prt_flds':self.flds_cur}
            prt_tsv_sections(prt, self.desc2nts['sections'], **kws_tsv)
            print("  WROTE: {TSV}".format(TSV=fout_tsv))
366842
def _get_header(self):
        """"""

        try:
            header_lines = [int(e) for e in str(self.get_value('headerlines', 0)).split(',')]
        except ValueError as e:
            header_lines = [0]

        # We're processing the raw datafile, with no schema.
        header_rows = islice(self.row_generator, min(header_lines), max(header_lines) + 1)

        from tableintuit import RowIntuiter
        headers = RowIntuiter.coalesce_headers(header_rows)

        return headers
709057
def serialize_for_header(key, value):
    """"""
    if key in QUOTE_FIELDS:
        return json.dumps(value)
    elif isinstance(value, str):
        if " " in value or "\t" in value:
            return json.dumps(value)
        else:
            return value
    elif isinstance(value, list):
        return "[{}]".format(", ".join(value))
    else:
        return str(value)