12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #
- # This file is part of stov, written by Helmut Pozimski in 2012.
- #
- # 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 <http://www.gnu.org/licenses/>.
- # -*- 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
|