Formats information about given DAP from DAPI in a human readable form to list of lines
190816
def format_dap_from_dapi(name, version='', full=False):
    ''''''
    lines = []
    m, d = _get_metadap_dap(name, version)

    if d:
        # Determining label width
        labels = BASIC_LABELS + ['average_rank'] # average_rank comes from m, not d
        if full:
            labels.extend(EXTRA_LABELS)
        label_width = dapi.DapFormatter.calculate_offset(labels)

        # Metadata
        lines += dapi.DapFormatter.format_meta_lines(d, labels=labels, offset=label_width)
        lines.append(dapi.DapFormatter.format_dapi_score(m, offset=label_width))

        if 'assistants' in d:
            # Assistants
            assistants = sorted([a for a in d['assistants'] if a.startswith('assistants')])
            lines.append('')
            for line in dapi.DapFormatter.format_assistants_lines(assistants):
                lines.append(line)

            # Snippets
            if full:
                snippets = sorted([a for a in d['assistants'] if a.startswith('snippets')])
                lines.append('')
                lines += dapi.DapFormatter.format_snippets(snippets)

        # Supported platforms
        if d.get('supported_platforms', ''):
            lines.append('')
            lines += dapi.DapFormatter.format_platforms(d['supported_platforms'])

        lines.append('')
    return lines
1045725
def parse_volumes_output(out):
    
    if not out:
        return []
    line_iter = islice(out.splitlines(), 1, None)  # Skip header
    return list(map(_volume_info, line_iter))
209282
def info(self, buf=None):
        

        if buf is None:  # pragma: no cover
            buf = sys.stdout

        lines = []
        lines.append('xarray.Dataset {')
        lines.append('dimensions:')
        for name, size in self.dims.items():
            lines.append('\t{name} = {size} ;'.format(name=name, size=size))
        lines.append('\nvariables:')
        for name, da in self.variables.items():
            dims = ', '.join(da.dims)
            lines.append('\t{type} {name}({dims}) ;'.format(
                type=da.dtype, name=name, dims=dims))
            for k, v in da.attrs.items():
                lines.append('\t\t{name}:{k} = {v} ;'.format(name=name, k=k,
                                                             v=v))
        lines.append('\n// global attributes:')
        for k, v in self.attrs.items():
            lines.append('\t:{k} = {v} ;'.format(k=k, v=v))
        lines.append('}')

        buf.write('\n'.join(lines))
206401
def _prt_line_detail(self, prt, line, lnum=""):
        """"""
        data = zip(self.flds, line.split('\t'))
        txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)]
        prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt)))
439424
def _pprint(dic):
    """"""
    for key, value in dic.items():
        print("        {0}: {1}".format(key, value))
613463
def readiter(d):
    

    da = ms.getdata([d['datacol'],'axis_info','u','v','w','flag','data_desc_id'], ifraxis=True)
    good = n.where((da['data_desc_id']) == d['spwlist'][0])[0]   # take first spw                                                
    time0 = da['axis_info']['time_axis']['MJDseconds'][good]
    data0 = n.transpose(da[d['datacol']], axes=[3,2,1,0])[good]
    flag0 = n.transpose(da['flag'], axes=[3,2,1,0])[good]
    u0 = da['u'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)    # uvw are in m, so divide by wavelength of first chan to set in lambda
    v0 = da['v'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)
    w0 = da['w'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)

    if len(d['spwlist']) > 1:
        for spw in d['spwlist'][1:]:
            good = n.where((da['data_desc_id']) == spw)[0]
            data1 = n.transpose(da[d['datacol']], axes=[3,2,1,0])[good]
            data0 = n.concatenate( (data0, data1), axis=2 )
            flag0 = n.concatenate( (flag0, n.transpose(da['flag'], axes=[3,2,1,0])[good]), axis=2 )

    del da
    data0 = data0[:,:,d['chans'],:] * n.invert(flag0[:,:,d['chans'],:])   # flag==1 means bad data (for vla)                     
    iterstatus = ms.iternext() 

    return data0.astype('complex64'), u0.astype('float32'), v0.astype('float32'), w0.astype('float32'), time0.astype('float32')
179450
def zlines(f = None, sep = "\0", osep = None, size = 8192):     # {{{1
  """"""
  if f is None: f = sys.stdin
  if osep is None: osep = sep
  buf = ""
  while True:
    chars = f.read(size)
    if not chars: break
    buf += chars; lines = buf.split(sep); buf = lines.pop()
    for line in lines: yield line + osep
  if buf: yield buf
707923
def contents(self):
        """"""
        rslt = []
        for (dpos, dlen, ulen, flag, typcd, nm) in self.toc:
            rslt.append(nm)
        return rslt
117777
def _pprint_features_dict(features_dict, indent=0, add_prefix=True):
  """"""
  first_last_indent_str = " " * indent
  indent_str = " " * (indent + 4)
  first_line = "%s%s({" % (
      first_last_indent_str if add_prefix else "",
      type(features_dict).__name__,
  )
  lines = [first_line]
  for k in sorted(list(features_dict.keys())):
    v = features_dict[k]
    if isinstance(v, tfds.features.FeaturesDict):
      v_str = _pprint_features_dict(v, indent + 4, False)
    else:
      v_str = str(v)
    lines.append("%s'%s': %s," % (indent_str, k, v_str))
  lines.append("%s})" % first_last_indent_str)
  return "\n".join(lines)
732919
def read_documentation(self, fid):
        """"""

        lin = self.read_line(fid)
        while lin[0] != ':':
            self.documentation.append(lin)
            lin = self.read_line(fid)
        return lin
1090159
def _init_data_line(self, fnc, lnum, line):
        """"""
        fld = re.split(self.sep, line)
        # Lines may contain different numbers of items.
        # The line should have all columns requested by the user.
        if self.usr_max_idx < len(fld):
            self.convert_ints_floats(fld)
            fnc(fld)
        else:
            for fld in enumerate(zip(self.hdr2idx.keys(), fld)):
                print(fld)
            for hdr in self.hdrs_usr:
                print(hdr)
            print('# ITEMS ON A LINE:', len(fld))
            print('MAX USR IDX:', self.usr_max_idx)
            raise Exception("ERROR ON LINE {} IN {}".format(lnum+1, self.fin))
447759
def to_mozlog_format(self):
        """"""
        data = {
            "action": self.action,
            "line_number": self.line,
            "test": self.test,
            "subtest": self.subtest,
            "status": self.status,
            "expected": self.expected,
            "message": self.message,
            "signature": self.signature,
            "level": self.level,
            "stack": self.stack,
            "stackwalk_stdout": self.stackwalk_stdout,
            "stackwalk_stderr": self.stackwalk_stderr,
        }

        # Remove empty values
        data = {k: v for k, v in data.items() if v}

        return data
372613
def str_deps(self):
        """"""
        lines = []
        app = lines.append

        app("Dependencies of node %s:" % str(self))
        for i, dep in enumerate(self.deps):
            app("%d) %s, status=%s" % (i, dep.info, str(dep.status)))

        return "\n".join(lines)
1361284
def _get_deps(deps, tree_base, saltenv='base'):
    '''
    
    '''
    deps_list = ''
    if deps is None:
        return deps_list
    if not isinstance(deps, list):
        raise SaltInvocationError(
            '\'deps\' must be a Python list or comma-separated string'
        )
    for deprpm in deps:
        parsed = _urlparse(deprpm)
        depbase = os.path.basename(deprpm)
        dest = os.path.join(tree_base, depbase)
        if parsed.scheme:
            __salt__['cp.get_url'](deprpm, dest, saltenv=saltenv)
        else:
            shutil.copy(deprpm, dest)

        deps_list += ' {0}'.format(dest)

    return deps_list
985808
def process_python_symbol_data(oedata):
    """"""
    symbol_list = []
    for key in oedata:
        val = oedata[key]
        if val and key != 'found_cell_separators':
            if val.is_class_or_function():
                symbol_list.append((key, val.def_name, val.fold_level,
                                    val.get_token()))
    return sorted(symbol_list)
183486
def pp_tuple(self, tup):
        """"""
        last_line = self.f.getvalue().split("\n")[-1]
        l = len(last_line)+1
        indent = ' ' * l
        self.write('(')
        sep = ''
        for item in tup:
            self.write(sep)
            l += len(sep)
            s = repr(item)
            l += len(s)
            self.write(s)
            sep = ','
            if l > LINE_LENGTH:
                l = 0
                sep += '\n' + indent
            else:
                sep += ' '
                pass
            pass
        if len(tup) == 1:
            self.write(", ")
        self.write(')')
680753
def format_users():
    ''''''
    lines = []
    u = users()
    count = u['count']
    if not count:
        raise DapiCommError('Could not find any users on DAPI.')
    for user in u['results']:
        line = user['username']
        if user['full_name']:
            line += ' (' + user['full_name'] + ')'
        lines.append(line)
    return lines