python-debianでcontrol fileを読む
python-debianを使ってdebのcontrol fileを扱ってみた。
-
付与されたタグ:
- Python
control fileは概ねRFC822なんだが便利なものもあるということで。
import debian.changelog
import debian.deb822
cl = debian.changelog.Changelog(file('debian/changelog'))
print cl.upstream_version
for i in debian.deb822.Deb822.iter_paragraphs(file('debian/control')):
if i.has_key('homepage'):
vars['homepage'] = i.get('homepage')
if i.keys()[0] == 'Package':
print i['Description']
みたいな感じで。
changelogファイルを読んでupstrem versionを表示。controlを読んでhomepage と description を表示。