1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-28 10:46:15 +01:00

Run a small demo when the ar module is invoked as a script

It just prints the ar headers.
This commit is contained in:
Marcus Huewe 2019-01-15 15:18:55 +01:00
parent 35a909bee5
commit 470b187374

View File

@ -212,3 +212,16 @@ class Ar:
continue
yield self._get_file(h)
raise StopIteration()
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage: %s <arfile>' % sys.argv[0])
sys.exit(1)
# a potential user might want to pass a bytes instead of a str
# to make sure that the ArError's file attribute is always a
# bytes
ar = Ar(fn=sys.argv[1])
ar.read()
for hdr in ar.hdrs:
print(hdr)