# # This file is part of stov, written by Helmut Pozimski 2012-2013. # # stov is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2 of the License. # # stov is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with stov. If not, see . # -*- coding: utf8 -*- from __future__ import unicode_literals, print_function import sys """ A little helper function used to do some additional checks before actually using print to generate the output""" def printf(string, outputlevel, descriptor="stdout", level="default"): if descriptor == "stdout": if level == "default" and outputlevel == "default": if sys.version_info >= (3, 0): print(string) else: print(string.encode("utf8")) elif level == "verbose": if sys.version_info >= (3, 0): print(string) else: print(string.encode("utf8")) elif level == "quiet": pass elif descriptor == "stderr": if level == "default" and outputlevel == "default": if sys.version_info >= (3, 0): print (string, file=sys.stderr) else: print(string.encode("utf8"), file=sys.stderr) elif level == "verbose": if sys.version_info >= (3, 0): print (string, file=sys.stderr) else: print(string.encode("utf8"), file=sys.stderr) elif level == "quiet": pass