File python3-porting.diff of Package python3-Trolly

From e323cd7e404a5124c3cc6b873649a77ca9845908 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Fri, 14 Feb 2014 14:03:31 +0100
Subject: [PATCH] Varios Python 3.x compat fixes

imports need to be absolute now, so prepend the
trolly. path everywhere
---
 trolly/authorise.py    |  6 +++---
 trolly/board.py        | 30 +++++++++++++++---------------
 trolly/card.py         | 20 ++++++++++----------
 trolly/checklist.py    | 12 ++++++------
 trolly/client.py       | 35 +++++++++++++++++++----------------
 trolly/list.py         |  8 ++++----
 trolly/member.py       |  4 ++--
 trolly/organisation.py | 26 +++++++++++++-------------
 8 files changed, 72 insertions(+), 69 deletions(-)

diff --git a/trolly/authorise.py b/trolly/authorise.py
index b48461a..fd6561f 100644
--- a/trolly/authorise.py
+++ b/trolly/authorise.py
@@ -4,7 +4,7 @@ Created on 8 Nov 2012
 @author: plish
 '''
 
-from client import Client
+from trolly.client import Client
 
 
 class Authorise( Client ):
@@ -28,7 +28,7 @@ class Authorise( Client ):
                 'scope': 'read,write'
             }
 
-        authorisation_url = self.buildUri( 
+        authorisation_url = self.buildUri(
                 path = '/authorize',
                 query_params = self.addAuthorisation(query_params)
             )
@@ -58,7 +58,7 @@ if __name__ == "__main__":
         pass
 
     if option in ( '-h', '--h', '-help' ):
-        print '\n%s \n\t%s \n\t%s \n\t%s\n\n' % ( 
+        print '\n%s \n\t%s \n\t%s \n\t%s\n\n' % (
                 'Use the -a option to get the authorisation URL.',
                 'First argument API key.',
                 'Second Argument application name',
diff --git a/trolly/board.py b/trolly/board.py
index ea4f2bd..1642e30 100644
--- a/trolly/board.py
+++ b/trolly/board.py
@@ -4,7 +4,7 @@ Created on 8 Nov 2012
 @author: plish
 '''
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class Board( TrelloObject ):
@@ -26,7 +26,7 @@ class Board( TrelloObject ):
         """
         Get all information for this board. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = '/boards/' + self.id,
                 query_params = query_params
             )
@@ -62,7 +62,7 @@ class Board( TrelloObject ):
         """
         Get a Card for a given card id. Returns a Card object.
         """
-        card_json = self.fetchJson( 
+        card_json = self.fetchJson(
                 uri_path = self.base_uri + '/cards/' + card_id
             )
 
@@ -95,7 +95,7 @@ class Board( TrelloObject ):
         """
         Update this board's information. Returns a new board.
         """
-        board_json = self.fetchJson( 
+        board_json = self.fetchJson(
                 uri_path = self.base_uri,
                 http_method = 'PUT',
                 query_params = query_params
@@ -108,22 +108,22 @@ class Board( TrelloObject ):
         """
         Create a list for a board. Returns a new List object.
         """
-        list_json = self.fetchJson( 
+        list_json = self.fetchJson(
                 uri_path = self.base_uri + '/lists',
                 http_method = 'POST',
                 query_params = query_params
             )
 
         return self.createList( list_json )
-    
-    
+
+
     def addMemberById( self, member_id, membership_type = 'normal' ):
         """
-        Add a member to the board using the id. Membership type can be 
-        normal or admin. Returns JSON of all members if successful or raises an 
+        Add a member to the board using the id. Membership type can be
+        normal or admin. Returns JSON of all members if successful or raises an
         Unauthorised exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members/%s' % ( member_id ),
                 http_method = 'PUT',
                 query_params = {
@@ -134,11 +134,11 @@ class Board( TrelloObject ):
 
     def addMember( self, email, fullname, membership_type = 'normal' ):
         """
-        Add a member to the board. Membership type can be normal or admin. 
-        Returns JSON of all members if successful or raises an Unauthorised 
+        Add a member to the board. Membership type can be normal or admin.
+        Returns JSON of all members if successful or raises an Unauthorised
         exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members',
                 http_method = 'PUT',
                 query_params = {
@@ -151,10 +151,10 @@ class Board( TrelloObject ):
 
     def removeMember( self, member_id ):
         """
-        Remove a member from the organisation.Returns JSON of all members if 
+        Remove a member from the organisation.Returns JSON of all members if
         successful or raises an Unauthorised exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members/%s' % ( member_id ),
                 http_method = 'DELETE'
             )
diff --git a/trolly/card.py b/trolly/card.py
index bdd15e2..daa5c6f 100644
--- a/trolly/card.py
+++ b/trolly/card.py
@@ -6,7 +6,7 @@ Created on 8 Nov 2012
 
 import mimetypes
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class Card( TrelloObject ):
@@ -28,7 +28,7 @@ class Card( TrelloObject ):
         """
         Get information for this card. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri,
                 query_params = query_params
             )
@@ -81,7 +81,7 @@ class Card( TrelloObject ):
         """
         Update information for this card. Returns a new Card object.
         """
-        card_json = self.fetchJson( 
+        card_json = self.fetchJson(
                 uri_path = self.base_uri,
                 http_method = 'PUT',
                 query_params = query_params
@@ -94,7 +94,7 @@ class Card( TrelloObject ):
         """
         Adds a comment to this card by the current user.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/actions/comments',
                 http_method = 'POST',
                 query_params = { 'text': comment_text }
@@ -110,13 +110,13 @@ class Card( TrelloObject ):
                 'token': self.client.user_auth_token
             }
 
-        content_type, body = self.encodeMultipartFormdata( 
+        content_type, body = self.encodeMultipartFormdata(
                 fields = fields,
                 filename = filename,
                 file_values = open_file
             )
 
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/attachments',
                 http_method = 'POST',
                 body = body,
@@ -129,7 +129,7 @@ class Card( TrelloObject ):
         """
         Add a checklist to this card. Returns a Checklist object.
         """
-        checklist_json = self.fetchJson( 
+        checklist_json = self.fetchJson(
                 uri_path = self.base_uri + '/checklists',
                 http_method = 'POST',
                 query_params = query_params
@@ -142,7 +142,7 @@ class Card( TrelloObject ):
         """
         Add a label to this card.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/labels',
                 http_method = 'POST',
                 query_params = query_params
@@ -153,7 +153,7 @@ class Card( TrelloObject ):
         """
         Add a member to this card. Returns a list of Member objects.
         """
-        members = self.fetchJson( 
+        members = self.fetchJson(
                 uri_path = self.base_uri + '/members',
                 http_method = 'POST',
                 query_params = { 'value': member_id }
@@ -170,7 +170,7 @@ class Card( TrelloObject ):
         """
         Remove a member from this card.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members/' + member_id,
                 http_method = 'DELETE'
             )
diff --git a/trolly/checklist.py b/trolly/checklist.py
index 9a32b8a..f2e397a 100644
--- a/trolly/checklist.py
+++ b/trolly/checklist.py
@@ -4,7 +4,7 @@ Created on 13 Nov 2012
 @author: plish
 '''
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class Checklist( TrelloObject ):
@@ -24,7 +24,7 @@ class Checklist( TrelloObject ):
         """
         Get all information for this Checklist. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri,
                 query_params = query_params
             )
@@ -35,7 +35,7 @@ class Checklist( TrelloObject ):
         Get all the items for this checklist. Returns a list of dictionaries.
         Each dictionary has the values for an item.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/checkItems',
                 query_params = query_params
             )
@@ -45,7 +45,7 @@ class Checklist( TrelloObject ):
         """
         Update the current checklist. Returns a new Checklist object.
         """
-        checklist_json = self.fetchJson( 
+        checklist_json = self.fetchJson(
                 uri_path = self.base_uri,
                 http_method = 'PUT',
                 query_params = { 'name': name }
@@ -58,7 +58,7 @@ class Checklist( TrelloObject ):
         """
         Add an item to this checklist. Returns a dictionary of values of new item.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/checkItems',
                 http_method = 'POST',
                 query_params = query_params
@@ -69,7 +69,7 @@ class Checklist( TrelloObject ):
         """
         Deletes an item from this checklist.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/checkItems/' + item_id,
                 http_method = 'DELETE'
             )
diff --git a/trolly/client.py b/trolly/client.py
index f8fbe2b..7cb94cf 100644
--- a/trolly/client.py
+++ b/trolly/client.py
@@ -6,14 +6,17 @@ Created on 8 Nov 2012
 
 import json
 from httplib2 import Http
-from urllib import urlencode
-
-from organisation import Organisation
-from board import Board
-from list import List
-from card import Card
-from checklist import Checklist
-from member import Member
+try:
+    from urllib import urlencode
+except ImportError:
+    from urllib.parse import urlencode
+
+from trolly.organisation import Organisation
+from trolly.board import Board
+from trolly.list import List
+from trolly.card import Card
+from trolly.checklist import Checklist
+from trolly.member import Member
 
 from trolly import Unauthorised, ResourceUnavailable
 
@@ -91,7 +94,7 @@ class Client( object ):
             headers['Content-Type'] = 'application/json'
 
         headers['Accept'] = 'application/json'
-        response, content = self.client.request( 
+        response, content = self.client.request(
                 uri = uri,
                 method = http_method,
                 body = body,
@@ -100,14 +103,14 @@ class Client( object ):
 
         self.checkErrors( uri, response )
 
-        return json.loads( content )
+        return json.loads( str(content) )
 
 
     def createOrganisation( self, organisation_json ):
         """
         Create an Organisation object from a JSON object
         """
-        return Organisation( 
+        return Organisation(
                 trello_client = self,
                 organisation_id = organisation_json['id'].encode('utf-8'),
                 name = organisation_json['name'].encode( 'utf-8' )
@@ -118,7 +121,7 @@ class Client( object ):
         """
         Create Board object from a JSON object
         """
-        return Board( 
+        return Board(
                 trello_client = self,
                 board_id = board_json['id'].encode('utf-8'),
                 name = board_json['name'].encode( 'utf-8' )
@@ -129,7 +132,7 @@ class Client( object ):
         """
         Create List object from JSON object
         """
-        return List( 
+        return List(
                 trello_client = self,
                 list_id = list_json['id'].encode('utf-8'),
                 name = list_json['name'].encode( 'utf-8' )
@@ -140,7 +143,7 @@ class Client( object ):
         """
         Create a Card object from JSON object
         """
-        return Card( 
+        return Card(
                 trello_client = self,
                 card_id = card_json['id'].encode('utf-8'),
                 name = card_json['name'].encode( 'utf-8' )
@@ -151,7 +154,7 @@ class Client( object ):
         """
         Create a Checklist object from JSON object
         """
-        return Checklist( 
+        return Checklist(
                 trello_client = self,
                 checklist_id = checklist_json['id'].encode('utf-8'),
                 name = checklist_json['name'].encode( 'utf-8' )
@@ -162,7 +165,7 @@ class Client( object ):
         """
         Create a Member object from JSON object
         """
-        return Member( 
+        return Member(
                 trello_client = self,
                 member_id = member_json['id'].encode('utf-8'),
                 name = member_json['fullName'].encode( 'utf-8' )
diff --git a/trolly/list.py b/trolly/list.py
index b37bf88..5deb645 100644
--- a/trolly/list.py
+++ b/trolly/list.py
@@ -4,7 +4,7 @@ Created on 8 Nov 2012
 @author: plish
 '''
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class List( TrelloObject ):
@@ -25,7 +25,7 @@ class List( TrelloObject ):
         """
         Get information for this list. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri,
                 query_params = query_params
             )
@@ -57,7 +57,7 @@ class List( TrelloObject ):
         """
         Update information for this list. Returns a new List object.
         """
-        list_json = self.fetchJson( 
+        list_json = self.fetchJson(
                 uri_path = self.base_uri,
                 http_method = 'PUT',
                 query_params = query_params
@@ -70,7 +70,7 @@ class List( TrelloObject ):
         """
         Create a card for this list. Returns a Card object.
         """
-        card_json = self.fetchJson( 
+        card_json = self.fetchJson(
                 uri_path = self.base_uri + '/cards',
                 http_method = 'POST',
                 query_params = query_params
diff --git a/trolly/member.py b/trolly/member.py
index 6abedd8..a65103d 100644
--- a/trolly/member.py
+++ b/trolly/member.py
@@ -4,7 +4,7 @@ Created on 9 Nov 2012
 @author: plish
 '''
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class Member( TrelloObject ):
@@ -25,7 +25,7 @@ class Member( TrelloObject ):
         """
         Get Information for a memeber. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri,
                 query_params = query_params
             )
diff --git a/trolly/organisation.py b/trolly/organisation.py
index cb872fc..51f2b21 100644
--- a/trolly/organisation.py
+++ b/trolly/organisation.py
@@ -4,7 +4,7 @@ Created on 14 Nov 2012
 @author: plish
 '''
 
-from trelloobject import TrelloObject
+from trolly.trelloobject import TrelloObject
 
 
 class Organisation( TrelloObject ):
@@ -22,7 +22,7 @@ class Organisation( TrelloObject ):
         """
         Get information fot this organisation. Returns a dictionary of values.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri,
                 query_params = query_params
             )
@@ -59,7 +59,7 @@ class Organisation( TrelloObject ):
         """
         Update this organisations information. Returns a new organisation object.
         """
-        organisation_json = self.fetchJson( 
+        organisation_json = self.fetchJson(
                 uri_path = self.base_uri,
                 http_method = 'PUT',
                 query_params = query_params
@@ -70,22 +70,22 @@ class Organisation( TrelloObject ):
 
     def removeMember( self, member_id ):
         """
-        Remove a member from the organisation.Returns JSON of all members if 
+        Remove a member from the organisation.Returns JSON of all members if
         successful or raises an Unauthorised exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members/%s' % ( member_id ),
                 http_method = 'DELETE'
             )
-    
-    
+
+
     def addMemberById( self, member_id, membership_type = 'normal' ):
         """
-        Add a member to the board using the id. Membership type can be 
-        normal or admin. Returns JSON of all members if successful or raises an 
+        Add a member to the board using the id. Membership type can be
+        normal or admin. Returns JSON of all members if successful or raises an
         Unauthorised exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members/%s' % ( member_id ),
                 http_method = 'PUT',
                 query_params = {
@@ -96,11 +96,11 @@ class Organisation( TrelloObject ):
 
     def addMember( self, email, fullname, membership_type = 'normal' ):
         """
-        Add a member to the board. Membership type can be normal or admin. 
-        Returns JSON of all members if successful or raises an Unauthorised 
+        Add a member to the board. Membership type can be normal or admin.
+        Returns JSON of all members if successful or raises an Unauthorised
         exception if not.
         """
-        return self.fetchJson( 
+        return self.fetchJson(
                 uri_path = self.base_uri + '/members',
                 http_method = 'PUT',
                 query_params = {
-- 
1.8.4.1

openSUSE Build Service is sponsored by