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 CB2311381FA for ; Wed, 14 May 2014 21:42:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4A239E09F2; Wed, 14 May 2014 21:42:20 +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 CEEBEE09F2 for ; Wed, 14 May 2014 21:42:19 +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 93B3733FEBA for ; Wed, 14 May 2014 21:42:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 39E5D1818D for ; Wed, 14 May 2014 21:42:17 +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: <1400103235.b1d97b175f8dd5224e8c7d8ea6275daeda0e134c.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: b1d97b175f8dd5224e8c7d8ea6275daeda0e134c X-VCS-Branch: gsoc2014 Date: Wed, 14 May 2014 21:42:17 +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: ce48054a-caee-4a79-ae3d-458767574ba5 X-Archives-Hash: 492c72c7f640b72ced6a999e45312134 commit: b1d97b175f8dd5224e8c7d8ea6275daeda0e134c Author: Devan Franchini gentoo org> AuthorDate: Wed May 14 21:33:55 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Wed May 14 21:33:55 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b1d97b17 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")