aboutsummaryrefslogtreecommitdiff
path: root/load_packages.py
blob: 423b22701d4e8ef51e8d29b51d538da871627128 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys

import debian.deb822
import pandas as pd

if __name__ == '__main__':
    packages = debian.deb822.Packages.iter_paragraphs(sys.stdin)
    df = pd.DataFrame([dict(p) for p in packages])
    store = pd.HDFStore('pkg.h5')

    # No 'Source' field means that it has the same value as the 'Package'
    # field. Set this explicitly.
    nosrc = df['Source'].isnull()
    df['Source'][nosrc] = df[nosrc]['Package']
    assert sum(pd.isnull(df['Source'])) == 0

    print df

    store = pd.HDFStore('pkg.h5')
    store['packages'] = df
    store.close()