launchpadlib API not fully updated for Python3.5
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
launchpadlib |
New
|
Undecided
|
Unassigned |
Bug Description
When running the copy-paste example from reference page: (the package I use is installed with `pip install launchpadlib` which has a version of 1.10.6)
````
from launchpadlib.
launchpad = Launchpad.
print('Hello, %s!' % launchpad.
````
got an exception:
````
File "/home/
oauth = __import_
File "/home/
import urlparse
ImportError: No module named 'urlparse'
````
This caused by the migration of this module to `from urllib.parse import urlparse`. After fixed this, got another exception for the second example:
````
from launchpadlib.
launchpad = Launchpad.
````
````
sig = '%s&' % escape(
File "/home/
return urllib.quote(s, safe='~')
AttributeError: module 'urllib' has no attribute 'quote'
````
This is caused by the same reason. And another:
````
File "/home/
headers.
File "/home/
for k, v in self.parameters
AttributeError: 'dict' object has no attribute 'iteritems'
````
If it is possible, I could do the fix found for Python 3.5 when exploring the APIs.
description: | updated |
affects: | launchpad → launchpadlib |
"""
The MIT License
Copyright (c) 2007 Leah Culver
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import cgi
import urllib
import time
import random
from urllib.parse import urlparse, quote
import hmac
import binascii
VERSION = '1.0' # Hi Blaine!
HTTP_METHOD = 'GET'
SIGNATURE_METHOD = 'PLAINTEXT'
class OAuthError( RuntimeError) :
self.message = message
"""Generic exception class."""
def __init__(self, message='OAuth error occured.'):
def build_authentic ate_header( realm=' '): ate': 'OAuth realm="%s"' % realm}
"""Optional WWW-Authenticate header (401 error)"""
return {'WWW-Authentic
def escape(s):
"""Escape a URL including any /."""
return quote(s, safe='~')
def _utf8_str(s):
"""Convert unicode to utf-8."""
if isinstance(s, unicode):
return s.encode("utf-8")
else:
return str(s)
def generate_ timestamp( ):
"""Get seconds since epoch (UTC)."""
return int(time.time())
def generate_ nonce(length= 8): [str(random. randint( 0, 9)) for i in range(length)])
"""Generate pseudorandom number."""
return ''.join(
def generate_ verifier( length= 8): [str(random. randint( 0, 9)) for i in range(length)])
"""Generate pseudorandom number."""
return ''.join(
class OAuthConsumer( object) :
"""Consumer of OAuth authentication.
OAuthConsumer is a data type that represents the identity of the Consumer
via its shared secret with the Service Provider.
"""
key = None
secret = None
def __init__(self, key, secret):
self.key = key
self.secret = secret
class OAuthToken(object):
"""OAuthToken is a data type that represents an End User via either an access
or request token.
key -- the token
secret -- the token secret
""" confirmed = None
key = None
secret = None
callback = None
callback_
verifier = None
def __init__(self, key, secret):
self.key = key
self.secret = secret
def set_callback(self, callback):
self.callback = callback
self.callback_ confirmed = 'true'
def set_verifier(self, verifier=None):
self. verifier = verifier
if verifier is not None:
else:
self...