Ejemplo n.º 1
0
def findfat(pfad):
    res = []
    w = byte(pfad)
    #
    res.append([w, pfad])
    #
    while 1:
        dic = {}
        dateien = os.listdir(pfad)
        flg = False
        for x in dateien:
            x = pfad + x
            if os.path.isdir(x):
                flg = True
                x += '/'
                w = byte(x)
                dic[w] = x
        if flg == True:
            g = max(dic.keys())
            pfad = dic[g]
            res.append([g, pfad])
        elif flg == False:
            break
    try:
        import xz
        xz.show(res)
    except ImportError:
        for x in res:
            x[0] = commify(x[0])
            print(' || '.join(x))
Ejemplo n.º 2
0
def tasks(prj, see=True):
    if isinstance(prj, str):
        pid = getpid(prj)
    elif isinstance(prj, int):
        pid = prj
    api.sync()
    data = api.projects.get_data(pid)
    res = []

    headers = adic({
        'n': 'n',
        'id': 'tid',
        'content': 'title',
        'date_added': 'cdate',
        'due_date': 'ddate',
    })

    for dic in data['items']:
        cdate = dic['date_added']
        ddate = dic['due']['date']
        dic['date_added'] = zt2dt(dic['date_added'])
        dic['due_date'] = xt.s2d(dic['due']['date'])
        dic['n'] = 0
        #
        info = api.items.get(id)
        try:
            dic['notes'] = info['notes'][0]
        except TypeError:
            dic['notes'] = ''
        #
        tmp = {}
        for vor, nach in headers.items():
            tmp[nach] = dic[vor]
        tmp['notes'] = dic['notes']
        res.append(tmp)

    n = 0
    res = sorted(res, key=lambda d: d['ddate'])
    for dic in res:
        n += 1
        dic['n'] = n

    ### AUSGABE ###
    res.append(prj)
    xz.obj2bin(res, bin4tasks)
    res.pop()
    if see == True:
        #
        for dic in res:
            d = dic['cdate']
            dic['cdate'] = dt.date(d.year, d.month, d.day)
        tbl = xz.ldic2tbl(res, list(headers.values()))
        xz.show(tbl)
Ejemplo n.º 3
0
def lists():
    lis = api.state['projects']
    res = {}
    api.sync()
    for dic in lis:
        id = dic['id']
        name = dic['name']
        res[name] = id
    #
    ausgabe = bin4lists.replace('.txt', '.bin')
    xz.dic2txt(res, ausgabe)
    xz.obj2bin(res, bin4lists)
    xz.show(res)
Ejemplo n.º 4
0
def today(prj=''):
    #	pid = getpid(prj)
    #	tasks(pid,False)
    db = xz.bin2obj(bin4tasks)
    db.pop()
    res = []
    tag = xt.heute(False)
    #	tag = tag + dt.timedelta(days=-5)
    #	print( tag )
    for dic in db:
        due = dic['ddate']
        if due <= tag:
            res.append(dic)
#		print( dic ) #d
    headers = 'n/tid/title/cdate/ddate'
    headers = headers.split('/')
    for dic in res:
        d = dic['cdate']
        dic['cdate'] = dt.date(d.year, d.month, d.day)
    tbl = xz.ldic2tbl(res, headers)
    xz.show(tbl)
Ejemplo n.º 5
0
def nv2qt(nv, fjahr=1):
    tbl = nv2mt(nv, fjahr)
    res = []
    for lis in tbl:
        if lis[0] == '/':
            tmp = ['/', 'Q1', 'Q2', 'Q3', 'Q4']
        else:
            j = lis.pop(0)
            tmp = []
            tmp.append(sum(lis[0:3]))
            tmp.append(sum(lis[3:6]))
            tmp.append(sum(lis[6:9]))
            tmp.append(sum(lis[9:12]))
            tmp.insert(0, j)
        res.append(tmp)
    return res


#

##### DIREKT ###############
if __name__ == '__main__':
    nv = xz.txt2dic(labomi + 'a.tsv')
    nv = xz.bless(nv)
    tbl = nv2mt(nv, 12)
    xz.show(tbl)
    tbl = nv2qt(nv, 12)
    xz.show(tbl)
    kbench.enfin()
Ejemplo n.º 6
0
def tafel4fx(tafel, titel, beispiel=[]):

    ### DRITT ###
    if not myhost == 'derrida8':
        jetzt()
        return False

    ### TOR ###
    assert isinstance(titel, str)
    if not beispiel == []:
        assert isinstance(beispiel, list)
    for lis in tafel:
        assert isinstance(lis[0], int)
        assert isinstance(lis[1], str)
#		assert isinstance(lis[2], function)

### VARIABLES ###
    res = []
    res.append(['#', 'HAUPT', 'FX', 'ZEIT', 'TAG'])
    #
    erst = datetime.datetime.now()
    tick = datetime.datetime.now()
    tag = datetime.date.today()

    ### HAUPT ###
    for lis in tafel:
        tick = datetime.datetime.now()
        nummer = lis[0]
        wort = lis[1]
        aufgabe = lis[2]
        #
        if not beispiel == []:
            if not nummer in beispiel:
                continue
        #
        aufgabe()
        tack = datetime.datetime.now()
        zt = tack - tick
        #
        lis = [nummer, titel, wort, zt, tag]
        res.append(lis)
        tick = tack

    ### ENDLICH ###
    zt = tack - erst
    lis = [99, titel, 'ΣΣ', zt, tag]
    res.append(lis)

    ### VORSTELLEUNG ###
    y = 'STATISTIK / ' + titel
    print(rahmen(y, '%', True))
    res.append(res[0])
    xz.show(res)

    ### AUSGABE ###
    res.pop(0)
    res.pop()
    gh = open(kbenchset, 'a', encoding='utf-8')
    y = "### %s @ %s ###\n" % (titel, tag)
    gh.write(y)
    for lis in res:
        y = [str(x) for x in lis]
        y = "\t".join(y)
        gh.write(y)
        gh.write("\n")
    gh.write("#\n")
    gh.close()

    ### PRUFUNG ###
    gh = open(kbenchset, 'r', encoding='utf-8')
    lis = gh.read()
    lis = lis.split("\n")
    lis = [x for x in lis if "###" in x]
    #
    res = {}
    for x in lis:
        if x in res:
            res[x] += 1
        else:
            res[x] = 1
    for x, n in res.items():
        if n == 1: continue
        y = x.replace('### ', '')
        y = y.replace(' ###', '')
        y = y + ' / ' + str(n)
        y = 'DOPPEL HIER : '
Ejemplo n.º 7
0
 def show(my):
     xz.show(my.to_tbl())