From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C0DCD1381FA for ; Wed, 14 May 2014 23:49:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 654A9E0A8A; Wed, 14 May 2014 23:49:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 88DF9E0A97 for ; Wed, 14 May 2014 23:49:56 +0000 (UTC) Received: from spoonbill.gentoo.org (unknown [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CD3BC33FF66 for ; Wed, 14 May 2014 23:49:54 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id BEDDE182E0 for ; Wed, 14 May 2014 23:49:52 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1400111298.852864fc72515a50db0296119317d4b0d9ea369d.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/output.py X-VCS-Directories: layman/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 852864fc72515a50db0296119317d4b0d9ea369d X-VCS-Branch: gsoc2014 Date: Wed, 14 May 2014 23:49:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d8be38d5-37c6-434f-b51c-1b87755da6a8 X-Archives-Hash: 0d5e852b7a5790a25cd56746020245c2 commit: 852864fc72515a50db0296119317d4b0d9ea369d Author: Devan Franchini gentoo org> AuthorDate: Wed May 14 21:33:55 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Wed May 14 23:48:18 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=852864fc layman/output.py: Adds file output compatibility In order to allow users to set the output for error and normal output we need to check to see if users have set the output to be of type file. In py2 this is specified by the variable "file", however in py3 this is specified by io.IOBase which encompasses all file types such as Raw, Text, and Buffered files. --- layman/output.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/layman/output.py b/layman/output.py index ea98894..ef348f5 100644 --- a/layman/output.py +++ b/layman/output.py @@ -6,6 +6,7 @@ Distributed under the terms of the GNU General Public License v2 """ +from __future__ import print_function __version__ = "0.1" @@ -15,6 +16,11 @@ import sys from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF from layman.compatibility import encode +# py3.2 +if sys.hexversion >= 0x30200f0: + from io import IOBase as BUILTIN_FILE_TYPE +else: + BUILTIN_FILE_TYPE=file class MessageBase(object): """Base Message class helper functions and variables @@ -30,13 +36,13 @@ class MessageBase(object): error_callback=None ): # Where should the error output go? This can also be a file - if isinstance(err, file): + if isinstance(err, BUILTIN_FILE_TYPE): self.error_out = err else: raise Exception("MessageBase: input parameter 'err' must be of type: file") # Where should the normal output go? This can also be a file - if isinstance(out, file): + if isinstance(out, BUILTIN_FILE_TYPE): self.std_out = out else: raise Exception("MessageBase: input parameter 'out' must be of type: file")