Esempio n. 1
0
 def rm_q(self, cond_func):
     indexes = elel.cond_select_indexes_all(self.darr,
                                            cond_func=lambda ele:
                                            (ele['q'] == None))
     idarr = elel.array_map(self.darr, language_locale_q_floatize)
     orig_indexes = elel.cond_select_indexes_all(idarr, cond_func=cond_func)
     idarr = elel.cond_select_values_all(idarr, cond_func=cond_func)
     for index in indexes:
         curr_index = orig_indexes.index(index)
         idarr[curr_index]['q'] = None
     self.darr = idarr
     self.sarr = language_locale_q_darr2sarr(self.darr)
     pobj(self.sarr)
Esempio n. 2
0
def search(arr, s):
    indexes = elel.cond_select_indexes_all(arr,
                                           cond_func=cond_search,
                                           cond_func_args=[s])
    values = elel.select_indexes(arr, indexes)
    pobj(values, with_color=0)
    return (values)
Esempio n. 3
0
def tst2kvlist(**kwargs):
    if ("codec" in kwargs):
        codec = kwargs["codec"]
    else:
        codec = "utf-8"
    if ("code" in kwargs):
        code = kwargs["code"]
    else:
        code = fs.rfile(kwargs["fn"])
    code = code + "\n#"
    g = tokenize(BytesIO(code.encode(codec)).readline)
    info = next(g)
    kl = []
    vl = []
    k = ""
    infos = [info]
    for info in g:
        if (info.type == COMMENT):
            kl.append(k)
            v = _infos2group(infos)
            vl.append(v)
            k = info.string.lstrip("#")
            infos = []
        else:
            infos.append(info)
    indexes = elel.cond_select_indexes_all(kl, cond_func=lambda ele: ele == "")
    kl = elel.pop_indexes(kl, indexes)['list']
    vl = elel.pop_indexes(vl, indexes)['list']
    return ((kl, vl))
Esempio n. 4
0
def get_lsib(tree, nd):
    sibs = get_sibs(tree, nd, including_self=True)
    seq = elel.cond_select_indexes_all(sibs,
                                       cond_func=lambda sib: sib == nd)[0]
    if (seq == 0):
        return (None)
    else:
        return (sibs[seq - 1])
Esempio n. 5
0
def _infos2group(infos):
    def map_func(ele):
        ele.pop(0)
        return (ele)

    indexes = elel.cond_select_indexes_all(infos,
                                           cond_func=lambda info:
                                           (info.type == NEWLINE))
    groups = elel.broken_seqs(infos, indexes)
    groups = elel.remove_all(groups, [])
    groups = elel.mapv(groups, map_func)
    groups = elel.remove_all(groups, [])
    groups = elel.mapv(groups, _group2str)
    try:
        groups = elel.remove_last(groups, "\n")
        groups = elel.remove_first(groups, "\n")
    except:
        pass
    else:
        pass
    return (groups)
Esempio n. 6
0
def get_sibseq(tree, nd):
    sibs = get_sibs(tree, nd, including_self=True)
    seq = elel.cond_select_indexes_all(sibs,
                                       cond_func=lambda sib: sib == nd)[0]
    return (seq)
Esempio n. 7
0
def get_maxlenlyr_depth(m,*args):
    which = eftl.optional_which_arg("all",*args)
    mll = get_maxlyrlen(m)
    depths = elel.cond_select_indexes_all(m,cond_func=lambda ele:len(ele)==mll)
    rslt = depths if(which == "all") else depths[which]
    return(rslt)