Mercurial > ec-dotfiles
comparison bin/recompress @ 99:97e24e89388f
explicit main call.
author | Edho Prima Arief <edho@myconan.net> |
---|---|
date | Tue, 19 Jul 2011 15:43:02 +0700 |
parents | 9be628347dce |
children |
comparison
equal
deleted
inserted
replaced
98:9be628347dce | 99:97e24e89388f |
---|---|
23 | 23 |
24 def sane_fn(filename): | 24 def sane_fn(filename): |
25 import re | 25 import re |
26 return re.sub(r"[\x00-\x1F\x7F\n\r]", "?", filename) | 26 return re.sub(r"[\x00-\x1F\x7F\n\r]", "?", filename) |
27 | 27 |
28 if __name__ == "__main__": | 28 def main(files): |
29 for filename in sys.argv[1:]: | 29 for filename in files: |
30 print "Recompressing %s:" % sane_fn(filename), | 30 print "Recompressing %s:" % sane_fn(filename), |
31 sys.stdout.flush() | 31 sys.stdout.flush() |
32 try: | 32 try: |
33 byte_orig = os.path.getsize(filename) | 33 byte_orig = os.path.getsize(filename) |
34 repng(filename) | 34 repng(filename) |
40 print "(%s: %s)" % (sys.exc_type, sys.exc_value), | 40 print "(%s: %s)" % (sys.exc_type, sys.exc_value), |
41 re = 1 | 41 re = 1 |
42 finally: | 42 finally: |
43 print "[%s]" % re | 43 print "[%s]" % re |
44 | 44 |
45 if __name__ == "__main__": | |
46 main(sys.argv[1:]) |