| 1 |
#!/usr/bin/python3 |
| 2 |
|
| 3 |
# changelog_head - head like tool for .deb changelog entries |
| 4 |
# Copyright (C) 2007 Stefano Zacchiroli <[email protected]> |
| 5 |
# |
| 6 |
# This program is free software: you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation, either version 3 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
|
| 11 |
"""Like "head" for changelog entries, return last n-th entries of the changelog |
| 12 |
shipped in a .deb file.""" |
| 13 |
|
| 14 |
import sys |
| 15 |
|
| 16 |
from debian import debfile |
| 17 |
|
| 18 |
if __name__ == '__main__': |
| 19 |
if len(sys.argv) > 3 or len(sys.argv) < 2: |
| 20 |
print("Usage: changelog_head DEB [ENTRIES]") |
| 21 |
print(" ENTRIES defaults to 10") |
| 22 |
sys.exit(1) |
| 23 |
|
| 24 |
entries = 10 |
| 25 |
try: |
| 26 |
entries = int(sys.argv[2]) |
| 27 |
except IndexError: |
| 28 |
pass |
| 29 |
|
| 30 |
deb = debfile.DebFile(sys.argv[1]) |
| 31 |
chg = deb.changelog() |
| 32 |
entries = chg._blocks[:entries] |
| 33 |
print(''.join(map(str, entries))) |
| 34 |
|