Skip to content

Commit 8e95eda

Browse files
author
Razvan Nesiu
committed
Update to python 3 syntax
1 parent 0a8b769 commit 8e95eda

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

django_google_storage/file.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# coding=utf-8
22
from django.core.files.base import File
3-
4-
try:
5-
from cStringIO import StringIO
6-
except ImportError:
7-
from StringIO import StringIO
8-
3+
from io import StringIO
94

105
class GSBotoStorageFile(File):
116
def __init__(self, name, mode, storage):

django_google_storage/format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# coding=utf-8
2-
import urllib
2+
import urllib.request, urllib.parse, urllib.error
33

44
import boto.utils
55
from boto.exception import BotoClientError
@@ -44,11 +44,11 @@ def build_auth_path(self, bucket, key=''):
4444
path = ''
4545
if bucket != '':
4646
path = '/' + bucket
47-
return path + '/%s' % urllib.quote(key)
47+
return path + '/%s' % urllib.parse.quote(key)
4848

4949
def build_path_base(self, bucket, key=''):
5050
key = boto.utils.get_utf8_value(key)
51-
return '/%s' % urllib.quote(key)
51+
return '/%s' % urllib.parse.quote(key)
5252

5353

5454
class SubdomainCallingFormat(_CallingFormat):

django_google_storage/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _get_or_create_bucket(self, name):
108108
"""Retrieves a bucket if it exists, otherwise creates it."""
109109
try:
110110
return self.connection.get_bucket(name, validate=AUTO_CREATE_BUCKET)
111-
except Exception, e:
111+
except Exception as e:
112112
if AUTO_CREATE_BUCKET:
113113
bucket = self.connection.create_bucket(name)
114114
bucket.set_acl(self.bucket_acl)

django_google_storage/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def safe_join(base, *paths):
1313
1414
Paths outside the base path indicate a possible security sensitive operation.
1515
"""
16-
from urlparse import urljoin
16+
from urllib.parse import urljoin
1717
base_path = force_unicode(base)
18-
paths = map(lambda p: force_unicode(p), paths)
18+
paths = [force_unicode(p) for p in paths]
1919
final_path = urljoin(base_path + ("/" if not base_path.endswith("/") else ""), *paths)
2020
# Ensure final_path starts with base_path and that the next character after
2121
# the final path is '/' (or nothing, in which case final_path must be

0 commit comments

Comments
 (0)