~fredg/twadeb

2a4e708ffa89359942029032d59a6514b9e13074 — alienus 10 years ago 345f773
make --full a list of list
1 files changed, 15 insertions(+), 8 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +15 -8
@@ 104,27 104,32 @@ def parseFile(nameOfFile):
                    yield res


def fullInf():
    if full and not today:
        print(socket.gethostname(), ':', \
              strftime("%Y-%m-%d %H:%M:%S"), '--', nbPkgs, 'packages')
        print('-' * 72)


def lastNpkgs(nb):
    lPkg = []
    global rPkg
    rPkg = []
    for infos in parseFile(dpkglog):
        lPkg.append(infos)
    nbPkgs = len(lPkg)
    lPkg = lPkg[0:nb]
    if full and not today:
        print(socket.gethostname(), ':', \
              strftime("%Y-%m-%d %H:%M:%S"), '--', nbPkgs, 'packages')
        print('-' * 72)
    for elt in lPkg:
        date, time, keyword, package, verbef, ver = elt
        if today:
            nb = nbPkgs
            if date == strftime("%Y-%m-%d"):       
                print(package)      
            if date == strftime("%Y-%m-%d"):
                rPkg.append(package)
        elif full:
            keyword = keyword.replace('install', 'I').replace('upgrade', 'U')
            print(keyword, date, time, ' ', package.ljust(25), ver)
            rPkg.append([keyword, date, time, package, ver])
        else:
            print(package)
            rPkg.append(package)


if __name__ == '__main__':


@@ 135,3 140,5 @@ if __name__ == '__main__':
        sys.exit(\
            'full option is useless with the today one, aborting...')
    lastNpkgs(nb)
    for p in rPkg:
        print(p)