Debian Codegraph @

examples/debfile/ar

raw
1 #!/usr/bin/python3
2
3 # ar.py: ar emulation using ArFile
4 # Copyright (C) 2007 Filippo Giunchedi <[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 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 import os
20 import sys
21
22 from debian import arfile
23
24 if __name__ == '__main__':
25 if len(sys.argv) < 3:
26 print("usage: ar [tp] <arfile>")
27 sys.exit(1)
28
29 if not os.path.exists(sys.argv[2]):
30 print("please provide a file to operate on")
31 sys.exit(1)
32
33 a = arfile.ArFile(sys.argv[2])
34
35 if sys.argv[1] == 't':
36 print("\n".join(a.getnames()))
37 elif sys.argv[1] == 'p':
38 for m in a.getmembers():
39 #print("".join(m.readlines()))
40 sys.stdout.write("".join(m.readlines()))