1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/usr/bin/env python
# -*- coding: utf-8-with-signature-unix; fill-column: 77 -*-
# -*- indent-tabs-mode: nil -*-
# This file is part of pyutil; see README.rst for licensing terms.
from pyutil import lineutil
import sys
def main():
if len(sys.argv) > 1 and "-s" in sys.argv[1:]:
strip = True
sys.argv.remove("-s")
else:
strip = False
if len(sys.argv) > 1 and "-n" in sys.argv[1:]:
nobak = True
sys.argv.remove("-n")
else:
nobak = False
if len(sys.argv) > 1:
pipe = False
else:
pipe = True
if pipe:
lineutil.lineify_fileobjs(sys.stdin, sys.stdout)
else:
for fn in sys.argv[1:]:
lineutil.lineify_file(fn, strip, nobak)
if __name__ == '__main__':
main()
|