aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/storage
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
committerBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
commitdec47c7102cf0aa3a4debf002928db8e460c0d71 (patch)
tree47631fc15c7af172aa699506adf3d76d3a71976c /mediagoblin/storage
parent5f3a782fef4855e10b7259624a14d8afb0f7be93 (diff)
downloadmediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.lz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.xz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.zip
Apply `pyupgrade --py3-plus` to remove Python 2 compatibility code.
Diffstat (limited to 'mediagoblin/storage')
-rw-r--r--mediagoblin/storage/__init__.py11
-rw-r--r--mediagoblin/storage/cloudfiles.py9
-rw-r--r--mediagoblin/storage/filestorage.py2
-rw-r--r--mediagoblin/storage/mountstorage.py3
4 files changed, 11 insertions, 14 deletions
diff --git a/mediagoblin/storage/__init__.py b/mediagoblin/storage/__init__.py
index 14f13bd3..bd6bad02 100644
--- a/mediagoblin/storage/__init__.py
+++ b/mediagoblin/storage/__init__.py
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import absolute_import
import shutil
import uuid
@@ -50,7 +49,7 @@ class NotImplementedError(Error):
# Storage interface & basic file implementation
###############################################
-class StorageInterface(object):
+class StorageInterface:
"""
Interface for the storage API.
@@ -148,7 +147,7 @@ class StorageInterface(object):
filepath = clean_listy_filepath(filepath)
if self.file_exists(filepath):
- return filepath[:-1] + ["%s-%s" % (uuid.uuid4(), filepath[-1])]
+ return filepath[:-1] + ["{}-{}".format(uuid.uuid4(), filepath[-1])]
else:
return filepath
@@ -224,10 +223,10 @@ def clean_listy_filepath(listy_filepath):
A cleaned list of unicode objects.
"""
cleaned_filepath = [
- six.text_type(secure_filename(filepath))
+ str(secure_filename(filepath))
for filepath in listy_filepath]
- if u'' in cleaned_filepath:
+ if '' in cleaned_filepath:
raise InvalidFilepath(
"A filename component could not be resolved into a usable name.")
@@ -261,7 +260,7 @@ def storage_system_from_config(config_section):
"""
# This construct is needed, because dict(config) does
# not replace the variables in the config items.
- config_params = dict(six.iteritems(config_section))
+ config_params = dict(config_section.items())
if 'storage_class' in config_params:
storage_class = config_params['storage_class']
diff --git a/mediagoblin/storage/cloudfiles.py b/mediagoblin/storage/cloudfiles.py
index 61665ea0..0785f8a9 100644
--- a/mediagoblin/storage/cloudfiles.py
+++ b/mediagoblin/storage/cloudfiles.py
@@ -20,7 +20,6 @@ python-cloudfiles one.
http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports
'''
-from __future__ import absolute_import
from mediagoblin.storage import StorageInterface, clean_listy_filepath
@@ -58,7 +57,7 @@ class CloudFilesStorage(StorageInterface):
servicenet=True if self.param_use_servicenet == 'true' or \
self.param_use_servicenet == True else False)
- _log.debug('Connected to {0} (auth: {1})'.format(
+ _log.debug('Connected to {} (auth: {})'.format(
self.connection.connection.host,
self.connection.auth.host))
@@ -72,7 +71,7 @@ class CloudFilesStorage(StorageInterface):
self.container = self.connection.get_container(
self.param_container)
- _log.debug('Container: {0}'.format(
+ _log.debug('Container: {}'.format(
self.container.name))
self.container_uri = self.container.public_ssl_uri()
@@ -162,7 +161,7 @@ class CloudFilesStorage(StorageInterface):
# and bandwidth usage. So, override this method and use the
# Cloudfile's "send" interface instead.
# TODO: Fixing write() still seems worthwhile though.
- _log.debug('Sending {0} to cloudfiles...'.format(filepath))
+ _log.debug('Sending {} to cloudfiles...'.format(filepath))
with self.get_file(filepath, 'wb') as dest_file:
with open(filename, 'rb') as source_file:
# Copy to storage system in 4096 byte chunks
@@ -188,7 +187,7 @@ class CloudFilesStorageObjectWrapper():
self.storage_object = storage_object
def read(self, *args, **kwargs):
- _log.debug('Reading {0}'.format(
+ _log.debug('Reading {}'.format(
self.storage_object.name))
return self.storage_object.read(*args, **kwargs)
diff --git a/mediagoblin/storage/filestorage.py b/mediagoblin/storage/filestorage.py
index 89f43276..fe0d3c11 100644
--- a/mediagoblin/storage/filestorage.py
+++ b/mediagoblin/storage/filestorage.py
@@ -32,7 +32,7 @@ class FileObjectAwareFile(io.FileIO):
# object, which should be saved RAM-friendly way
shutil.copyfileobj(data, self)
else:
- super(FileObjectAwareFile, self).write(data)
+ super().write(data)
class BasicFileStorage(StorageInterface):
diff --git a/mediagoblin/storage/mountstorage.py b/mediagoblin/storage/mountstorage.py
index a829db31..66ae7c3c 100644
--- a/mediagoblin/storage/mountstorage.py
+++ b/mediagoblin/storage/mountstorage.py
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
import six
@@ -124,7 +123,7 @@ class MountStorage(StorageInterface):
v = table.get(None)
if v:
res.append(" " * len(indent) + repr(indent) + ": " + repr(v))
- for k, v in six.iteritems(table):
+ for k, v in table.items():
if k == None:
continue
res.append(" " * len(indent) + repr(k) + ":")