Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: python
python:
- "2.6"
- "2.7"
- "3.4"
- "3.5"
- "3.6"
# command to install dependencies
install:
- pip install -r tests/ci_requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

environment:
matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python34"

# To update these values, visit AppVeyor's site, click the user icon and scroll down to Encrypt Data.
SG_SERVER_URL:
Expand Down
4 changes: 2 additions & 2 deletions shotgun_api3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shotgun import (Shotgun, ShotgunError, ShotgunFileDownloadError, Fault,
from .shotgun import (Shotgun, ShotgunError, ShotgunFileDownloadError, Fault,
AuthenticationFault, MissingTwoFactorAuthenticationFault,
UserCredentialsNotAllowedForSSOAuthenticationFault,
ProtocolError, ResponseError, Error, __version__)
from shotgun import SG_TIMEZONE as sg_timezone
from .shotgun import SG_TIMEZONE as sg_timezone

183 changes: 92 additions & 91 deletions shotgun_api3/lib/httplib2/__init__.py

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions shotgun_api3/lib/httplib2/iri2uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__history__ = """
"""

import urlparse
import urllib.parse


# Convert an IRI to a URI following the rules in RFC 3987
Expand Down Expand Up @@ -50,6 +50,7 @@
(0x100000, 0x10FFFD),
]


def encode(c):
retval = c
i = ord(c)
Expand All @@ -66,16 +67,17 @@ def iri2uri(uri):
"""Convert an IRI to a URI. Note that IRIs must be
passed in a unicode strings. That is, do not utf-8 encode
the IRI before passing it into the function."""
if isinstance(uri ,unicode):
(scheme, authority, path, query, fragment) = urlparse.urlsplit(uri)
if isinstance(uri, str):
(scheme, authority, path, query, fragment) = urllib.parse.urlsplit(uri)
authority = authority.encode('idna')
# For each character in 'ucschar' or 'iprivate'
# 1. encode as utf-8
# 2. then %-encode each octet of that utf-8
uri = urlparse.urlunsplit((scheme, authority, path, query, fragment))
uri = urllib.parse.urlunsplit((scheme, authority.decode(), path, query, fragment))
uri = "".join([encode(c) for c in uri])
return uri


if __name__ == "__main__":
import unittest

Expand All @@ -84,27 +86,25 @@ class Test(unittest.TestCase):
def test_uris(self):
"""Test that URIs are invariant under the transformation."""
invariant = [
u"ftp://ftp.is.co.za/rfc/rfc1808.txt",
u"http://www.ietf.org/rfc/rfc2396.txt",
u"ldap://[2001:db8::7]/c=GB?objectClass?one",
u"mailto:[email protected]",
u"news:comp.infosystems.www.servers.unix",
u"tel:+1-816-555-1212",
u"telnet://192.0.2.16:80/",
u"urn:oasis:names:specification:docbook:dtd:xml:4.1.2" ]
"ftp://ftp.is.co.za/rfc/rfc1808.txt",
"http://www.ietf.org/rfc/rfc2396.txt",
"ldap://[2001:db8::7]/c=GB?objectClass?one",
"mailto:[email protected]",
"news:comp.infosystems.www.servers.unix",
"tel:+1-816-555-1212",
"telnet://192.0.2.16:80/",
"urn:oasis:names:specification:docbook:dtd:xml:4.1.2"]
for uri in invariant:
self.assertEqual(uri, iri2uri(uri))

def test_iri(self):
""" Test that the right type of escaping is done for each part of the URI."""
self.assertEqual("http://xn--o3h.com/%E2%98%84", iri2uri(u"http://\N{COMET}.com/\N{COMET}"))
self.assertEqual("http://bitworking.org/?fred=%E2%98%84", iri2uri(u"http://bitworking.org/?fred=\N{COMET}"))
self.assertEqual("http://bitworking.org/#%E2%98%84", iri2uri(u"http://bitworking.org/#\N{COMET}"))
self.assertEqual("#%E2%98%84", iri2uri(u"#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}")))
self.assertNotEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}".encode('utf-8')))
self.assertEqual("http://xn--o3h.com/%E2%98%84", iri2uri("http://\N{COMET}.com/\N{COMET}"))
self.assertEqual("http://bitworking.org/?fred=%E2%98%84", iri2uri("http://bitworking.org/?fred=\N{COMET}"))
self.assertEqual("http://bitworking.org/#%E2%98%84", iri2uri("http://bitworking.org/#\N{COMET}"))
self.assertEqual("#%E2%98%84", iri2uri("#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri("/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}"))
self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(iri2uri("/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}")))
self.assertNotEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri("/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}".encode('utf-8')))

unittest.main()


2 changes: 1 addition & 1 deletion shotgun_api3/lib/httplib2/socks.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def connect(self, destpair):
To select the proxy server use setproxy().
"""
# Do a minimal input check first
if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (not isinstance(destpair[0], basestring)) or (type(destpair[1]) != int):
if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (not isinstance(destpair[0], str)) or (type(destpair[1]) != int):
raise GeneralProxyError((5, _generalerrors[5]))
if self.__proxy[0] == PROXY_TYPE_SOCKS5:
if self.__proxy[2] != None:
Expand Down
Loading