summaryrefslogtreecommitdiffstats
path: root/format.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-03-07 21:40:55 +0100
committerJan Pokorný <jpokorny@redhat.com>2014-03-07 21:40:55 +0100
commit0207eb0e0c5bbe4c132865192667d9de7b89f84e (patch)
tree0112451a421ea02d48eb4e46acf50910540e2f2c /format.py
parent0434412835b433a42b876c0553dfb457c329abc8 (diff)
downloadclufter-0207eb0e0c5bbe4c132865192667d9de7b89f84e.tar.gz
clufter-0207eb0e0c5bbe4c132865192667d9de7b89f84e.tar.xz
clufter-0207eb0e0c5bbe4c132865192667d9de7b89f84e.zip
format: '-' file specification on output means stdout as usual
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'format.py')
-rw-r--r--format.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/format.py b/format.py
index 2136894..80c308e 100644
--- a/format.py
+++ b/format.py
@@ -12,7 +12,7 @@ import logging
from copy import deepcopy
from os import extsep, walk
from os.path import commonprefix, splitext, basename
-from sys import modules
+from sys import modules, stdout
from lxml import etree
@@ -189,8 +189,11 @@ class SimpleFormat(Format, MetaPlugin):
@Format.producing('file')
def get_file(self, protocol, filename):
- with file(filename, 'wb') as f:
- f.write(self('bytestring'))
+ if filename == '-':
+ stdout.write(self('bytestring'))
+ else:
+ with file(filename, 'wb') as f:
+ f.write(self('bytestring'))
return filename