Skip to content

Commit

Permalink
Update to python 3 syntax (changed syntax for file: StringIO -> BytesIO)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Nesiu committed May 31, 2019
1 parent e55dc72 commit 9eb94f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions django_google_storage/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
from django.core.files.base import File
from io import StringIO
from io import BytesIO

class GSBotoStorageFile(File):
def __init__(self, name, mode, storage):
Expand All @@ -18,20 +18,20 @@ def size(self):
@property
def file(self):
if self._file is None:
self._file = StringIO()
if 'r' in self._mode:
self._file = BytesIO()
if 'rb' in self._mode:
self._is_dirty = False
self.key.get_contents_to_file(self._file)
self._file.seek(0)
return self._file

def read(self, *args, **kwargs):
if 'r' not in self._mode:
if 'rb' not in self._mode:
raise AttributeError("File was not opened in read mode.")
return super(GSBotoStorageFile, self).read(*args, **kwargs)

def write(self, *args, **kwargs):
if 'w' not in self._mode:
if 'wb' not in self._mode:
raise AttributeError("File was opened for read-only access.")
self._is_dirty = True
return super(GSBotoStorageFile, self).write(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='django-google-storage-updated',
version='0.5.3',
version='0.5.4',
packages=['django_google_storage', ],
author='Maxim Smirnoff',
author_email='[email protected]',
Expand Down

0 comments on commit 9eb94f9

Please sign in to comment.