~fredg/twadeb

9289bc8617cba4853873ce7e8b5ac50cc07759ad — alienus 8 years ago 2a4e708
better print format
1 files changed, 16 insertions(+), 10 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +16 -10
@@ 104,13 104,6 @@ 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


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


@@ 132,6 129,16 @@ def lastNpkgs(nb):
            rPkg.append(package)


def printPkg():
    i = 1
    for p in rPkg:
        if today:
            print(p[0], p[1])
        else:
            print(i, p)
            i += 1


if __name__ == '__main__':
    # Build the dpkglog file (/tmp/dpkg.twadeb)
    dpkgFiles(alldpkg, dpkglog)


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