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

import debian.deb822
import pandas as pd

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()