1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/python
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# encode examples/master.cfg | python -c 'import sys, base64; base64.decode(sys.stdin, sys.stdout)'
import base64
import StringIO
import sys
filename = sys.argv[1]
tmp = StringIO.StringIO()
with open(filename) as f:
base64.encode(f, tmp)
tmp.flush()
tmp.seek(0)
sys.stdout.write(''.join(l.strip() for l in tmp.readlines()))
|