summaryrefslogtreecommitdiffstats
path: root/format.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-11-14 13:23:12 +0100
committerJan Pokorný <jpokorny@redhat.com>2014-11-14 22:11:19 +0100
commit904116553df1ac3d3ef5ecc88df33d04be29cf50 (patch)
tree64e66d0f3ce5d1dd52c714979076e7089b8392c9 /format.py
parent79360db8e405d520379027cc73c02b08f28b1fc0 (diff)
downloadclufter-904116553df1ac3d3ef5ecc88df33d04be29cf50.tar.gz
clufter-904116553df1ac3d3ef5ecc88df33d04be29cf50.tar.xz
clufter-904116553df1ac3d3ef5ecc88df33d04be29cf50.zip
format: make passing protocol/protodecl optional
It is usually not used internally to allow "1 function, more roles" anyway. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'format.py')
-rw-r--r--format.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/format.py b/format.py
index 736141a..6fe0f2f 100644
--- a/format.py
+++ b/format.py
@@ -337,13 +337,14 @@ class SimpleFormat(Format):
super(SimpleFormat, self).__init__(protocol, *args, **kwargs)
@Format.producing(BYTESTRING)
- def get_bytestring(self, protocol):
+ def get_bytestring(self, *protodecl):
if self.FILE in self._representations: # break the possible loop
with file(self.FILE(), 'rb') as f:
return f.read()
@Format.producing(FILE)
- def get_file(self, protocol, outfile):
+ def get_file(self, *protodecl):
+ outfile = protodecl[-1]
if hasattr(outfile, 'write'):
# assume fileobj out of our control, do not close
outfile.write(self.BYTESTRING())
@@ -729,7 +730,7 @@ class XML(SimpleFormat):
etree_validator = etree_rng_validator
@SimpleFormat.producing(BYTESTRING, chained=True)
- def get_bytestring(self, protocol):
+ def get_bytestring(self, *protodecl):
# chained fallback
return etree.tostring(self.ETREE(protect_safe=True),
pretty_print=True)
@@ -737,5 +738,5 @@ class XML(SimpleFormat):
@SimpleFormat.producing(ETREE, protect=True,
# pre 2.7 compat: http://bugs.python.org/issue5982
validator=etree_validator.__get__(1).im_func)
- def get_etree(self, protocol):
+ def get_etree(self, *protodecl):
return etree.fromstring(self.BYTESTRING()).getroottree()