Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit ddd6708

Browse files
author
Anton Larkin
committed
Fix codestyle
1 parent 7dec31b commit ddd6708

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

django_gocs/__init__.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121

2222
def is_gae_server():
23-
server_software = os.getenv("SERVER_SOFTWARE", "")
24-
return server_software.startswith("Google App Engine")
23+
server_software = os.getenv('SERVER_SOFTWARE', '')
24+
return server_software.startswith('Google App Engine')
2525

2626

2727
class GoogleBlobstoreTemporaryUploadedFile(TemporaryUploadedFile):
@@ -96,7 +96,7 @@ def __init__(self, location=None, base_url=None, force_use_gcs=False):
9696
self.force_use_gcs = force_use_gcs
9797

9898
def _open(self, name, mode='r'):
99-
filename = self.location + "/" + name
99+
filename = '{}/{}'.format(self.location, name)
100100

101101
# rb is not supported
102102
if mode == 'rb':
@@ -114,7 +114,7 @@ def _open(self, name, mode='r'):
114114
return gcs_file
115115

116116
def _save(self, name, content):
117-
filename = self.location + "/" + name
117+
filename = '{}/{}'.format(self.location, name)
118118
filename = os.path.normpath(filename)
119119
type, encoding = mimetypes.guess_type(name)
120120
cache_control = settings.GOOGLE_CLOUD_STORAGE_DEFAULT_CACHE_CONTROL
@@ -142,7 +142,8 @@ def _save(self, name, content):
142142
return name
143143

144144
def delete(self, name):
145-
filename = self.location+"/"+name
145+
filename = '{}/{}'.format(self.location, name)
146+
146147
try:
147148
gcs.delete(filename)
148149
except gcs.NotFoundError:
@@ -163,14 +164,14 @@ def listdir(self, path=None):
163164
head, tail = os.path.split(filePath)
164165
subPath = os.path.join(self.location, path)
165166
head = head.replace(subPath, '', 1)
166-
if head == "":
167+
if head == '':
167168
head = None
168169
if not head and tail:
169170
files.append(tail)
170171
if head:
171-
if not head.startswith("/"):
172-
head = "/" + head
173-
dir = head.split("/")[1]
172+
if not head.startswith('/'):
173+
head = '/{}'.format(head)
174+
dir = head.split('/')[1]
174175
if dir not in directories:
175176
directories.append(dir)
176177
return directories, files
@@ -199,10 +200,11 @@ def url(self, name):
199200

200201
filename = '/gs{}/{}'.format(self.location, name)
201202
key = create_gs_key(filename)
202-
local_base_url = getattr(settings, "GOOGLE_CLOUD_STORAGE_DEV_URL",
203-
"http://localhost:8001/blobstore/blob/")
203+
local_base_url = getattr(settings, 'GOOGLE_CLOUD_STORAGE_DEV_URL',
204+
'http://localhost:8001/blobstore/blob/')
204205
return '{}{}?display=inline'.format(local_base_url, key)
205206

206207
def statFile(self, name):
207-
filename = self.location + "/" + name
208+
filename = '{}/{}'.format(self.location, name)
209+
208210
return gcs.stat(filename)

0 commit comments

Comments
 (0)