mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-21 22:18:52 +02: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:
@@ -212,3 +212,16 @@ class Ar:
|
|||||||
continue
|
continue
|
||||||
yield self._get_file(h)
|
yield self._get_file(h)
|
||||||
raise StopIteration()
|
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)
|
||||||
|
Reference in New Issue
Block a user