pvl.args: apply_file: default to no unicode..
--- a/pvl/args.py Mon Dec 16 15:25:15 2013 +0200
+++ b/pvl/args.py Mon Dec 16 22:21:27 2013 +0200
@@ -94,9 +94,9 @@
log.error("refusing to run as root, use --uid 0 to override")
sys.exit(2)
-def apply_file (path=None, mode='r', charset='utf-8') :
+def apply_file (path=None, mode='r', charset=None) :
"""
- Open unicode-enabled file from path, with - using stdio.
+ Open (unicode-enabled) file from path, with - using stdio.
"""
if not path or path == '-' :
@@ -106,12 +106,16 @@
'w': (sys.stdout, codecs.getwriter),
}[mode[0]]
- # wrap
- return func(charset)(stream)
+ if charset :
+ return func(charset)(stream)
+ else :
+ return stream
else :
- # open
- return codecs.open(path, mode, charset)
+ if charset :
+ return codecs.open(path, mode, charset)
+ else :
+ return open(path, mode)
def apply_files (paths, *args, **opts) :
"""