Return the receiver's subtree as ASCII art.
342161
def _ascii_tree(self, indent: str, no_types: bool, val_count: bool) -> str:
        """"""
        def suffix(sn):
            return f" {{{sn.val_count}}}\n" if val_count else "\n"
        if not self.children:
            return ""
        cs = []
        for c in self.children:
            cs.extend(c._flatten())
        cs.sort(key=lambda x: x.qual_name)
        res = ""
        for c in cs[:-1]:
            res += (indent + c._tree_line(no_types) + suffix(c) +
                    c._ascii_tree(indent + "|  ", no_types, val_count))
        return (res + indent + cs[-1]._tree_line(no_types) + suffix(cs[-1]) +
                cs[-1]._ascii_tree(indent + "   ", no_types, val_count))
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
106285
def get_text(self):
        """"""
        if self.__fulltext:
            return self.__fulltext
        else:
            self.__fulltext = "\n\n".join(text.get_text()
                                          for text in self.__subtrees)
            return self.__fulltext
771215
def _tree_line(self, no_type: bool = False) -> str:
        """"""
        keys = (" [" + " ".join([k[0] for k in self.keys]) + "]"
                if self.keys else "")
        return super()._tree_line() + keys
173263
def as_tree(context):
    """"""

    tree = _build_tree(context, 2, 1)
    if type(tree) == dict:
        tree = [tree] 
    
    return Response(content_type='application/json', body=json.dumps(tree))
1277409
def ascii(graph):
    """"""
    from .._ascii import DAG
    from .._echo import echo_via_pager

    echo_via_pager(str(DAG(graph)))
203339
def get_substr_slices(umi_length, idx_size):
    '''
    
    '''
    cs, r = divmod(umi_length, idx_size)
    sub_sizes = [cs + 1] * r + [cs] * (idx_size - r)
    offset = 0
    slices = []
    for s in sub_sizes:
        slices.append((offset, offset + s))
        offset += s
    return slices
408533
def _unicode_to_ascii(obj):  # pragma: no cover
    """"""
    # pylint: disable=E0602,R1717
    if isinstance(obj, dict):
        return dict(
            [
                (_unicode_to_ascii(key), _unicode_to_ascii(value))
                for key, value in obj.items()
            ]
        )
    if isinstance(obj, list):
        return [_unicode_to_ascii(element) for element in obj]
    if isinstance(obj, unicode):
        return obj.encode("utf-8")
    return obj
723854
private void toStringTree(String indent, StringBuffer sb) {
		sb.append(toString());
		if (children != null) {
			for (Entry<String, DepTreeNode> entry : children.entrySet()) {
				entry.getValue().toStringTree(indent + "\t", sb); //$NON-NLS-1$
			}
		}
	}
346366
def __lstring(self,lstr):
    
    lstr = self.llsrx.sub('',lstr.encode('ascii'))
    lstr = self.rlsrx.sub('',lstr)
    lstr = self.xmltostr.xlat(lstr)
    lstr = self.dlmrx.sub(',',lstr)
    return lstr
880082
def tree_entries_from_data(data):
    """"""
    ord_zero = ord('0')
    space_ord = ord(' ')
    len_data = len(data)
    i = 0
    out = []
    while i < len_data:
        mode = 0

        # read mode
        # Some git versions truncate the leading 0, some don't
        # The type will be extracted from the mode later
        while byte_ord(data[i]) != space_ord:
            # move existing mode integer up one level being 3 bits
            # and add the actual ordinal value of the character
            mode = (mode << 3) + (byte_ord(data[i]) - ord_zero)
            i += 1
        # END while reading mode

        # byte is space now, skip it
        i += 1

        # parse name, it is NULL separated

        ns = i
        while byte_ord(data[i]) != 0:
            i += 1
        # END while not reached NULL

        # default encoding for strings in git is utf8
        # Only use the respective unicode object if the byte stream was encoded
        name = data[ns:i]
        name = safe_decode(name)

        # byte is NULL, get next 20
        i += 1
        sha = data[i:i + 20]
        i = i + 20
        out.append((sha, mode, name))
    # END for each byte in data stream
    return out
1195273
def pprint(self, ind):
        """"""
        pp = pprint.PrettyPrinter(indent=ind)
        pp.pprint(self.tree)
1125645
def print_tree(self) -> str:
        

        if self.ast:
            return self.ast.print_tree(ast_obj=self.ast)
        else:
            return ""
775544
def decode_struct_tree(self, data_type, obj):
        
        subtype = self.determine_struct_tree_subtype(data_type, obj)
        return self.decode_struct(subtype, obj)
944429
def get_chr2idx(self):
        """"""
        return {chr(ascii_int):idx for idx, ascii_int in enumerate(self.all_chrints)}
1243201
def i2b(self, pkt, x):
        """"""
        if type(x) is str:
          x = bytes([ ord(i) for i in x ])
        return x
934723
def _read_ascii(self):
        """"""
        # NOTE: ascii files store binned data using C-like ordering.
        # Dimensions are iterated like x, y, z (so z changes fastest)

        header_str = ''
        with open(self.path) as f:
            for line in f:
                if line.startswith('#'):
                    header_str += line
        self._read_header(header_str)

        data = np.loadtxt(self.path, delimiter=',', unpack=True, ndmin=1)

        # separate data by statistic (neglecting bin columns when necessary)
        n_dim = len(self.dimensions)
        data = {stat: data[n_dim+i] for i, stat in enumerate(self.statistics)}

        # reshape data according to binning
        data_shape = [dim.n_bins for dim in self.dimensions]
        data = {k: v.reshape(data_shape) for k, v in data.items()}

        self.data = data