Skip to content

Commit

Permalink
refactor (Resources): remove six
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Aug 5, 2022
1 parent c73aefd commit 19f47fb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/DIRAC/Resources/Storage/GFAL2_SRM2Storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
# pylint: disable=invalid-name

import six

import errno
import json

Expand Down Expand Up @@ -106,7 +106,7 @@ def getTransportURL(self, path, protocols=False):
listProtocols = self.protocolsList
if not listProtocols:
return S_ERROR("GFAL2_SRM2Storage.getTransportURL: No local protocols defined and no defaults found.")
elif isinstance(protocols, six.string_types):
elif isinstance(protocols, str):
listProtocols = [protocols]
elif isinstance(protocols, list):
listProtocols = protocols
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/Resources/Storage/GFAL2_StorageBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# # imports
from past.builtins import long
import six

import os
import datetime
import errno
Expand Down Expand Up @@ -839,7 +839,7 @@ def _prestageSingleFileStatus(self, path, token):
log = self.log.getSubLogger("GFAL2_StorageBase._prestageSingleFileStatus")
log.debug("Checking prestage file status for %s" % path)
# also allow int as token - converting them to strings
if not isinstance(token, six.string_types):
if not isinstance(token, str):
token = str(token)

try:
Expand Down Expand Up @@ -967,7 +967,7 @@ def _releaseSingleFile(self, path, token):
"""
log = self.log.getSubLogger("GFAL2_StorageBase._releaseSingleFile")
log.debug("Attempting to release single file: %s" % path)
if not isinstance(token, six.string_types):
if not isinstance(token, str):
token = str(token)
try:
self.ctx.set_opt_boolean("BDII", "ENABLE", True)
Expand Down
3 changes: 1 addition & 2 deletions src/DIRAC/Resources/Storage/RFIOStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import time

import six

from DIRAC import gLogger, S_OK, S_ERROR
from DIRAC.Resources.Storage.Utilities import checkArgumentFormat
Expand Down Expand Up @@ -981,7 +980,7 @@ def getDirectorySize(self, path):

def __checkArgumentFormat(self, path):
"""FIXME: Can be replaced by a generic checkArgumentFormat Utility"""
if isinstance(path, six.string_types):
if isinstance(path, str):
urls = [path]
elif isinstance(path, list):
urls = path
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/Resources/Storage/StorageElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
# # custom duty

import six

from copy import deepcopy
import datetime
import errno
Expand Down Expand Up @@ -959,7 +959,7 @@ def getURL(self, lfn, protocol=False, replicaDict=None):
protocols = self.turlProtocols
elif isinstance(protocol, list):
protocols = protocol
elif isinstance(protocol, six.string_types):
elif isinstance(protocol, str):
protocols = [protocol]

self.methodName = "getTransportURL"
Expand Down Expand Up @@ -1055,7 +1055,7 @@ def __filterPlugins(self, methodName, protocols=None, inputProtocol=None):
"Filtering plugins for %s (protocol = %s ; inputProtocol = %s)" % (methodName, protocols, inputProtocol)
)

if isinstance(protocols, six.string_types):
if isinstance(protocols, str):
protocols = [protocols]

pluginsToUse = []
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/Resources/Storage/StorageFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
getStorages() This takes a DIRAC SE definition and creates storage stubs for the protocols found in the CS.
By providing an optional list of protocols it is possible to limit the created stubs.
"""
import six

from DIRAC import gLogger, gConfig, S_OK, S_ERROR
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
from DIRAC.ConfigurationSystem.Client.Helpers.Path import cfgPath
Expand Down Expand Up @@ -86,7 +86,7 @@ def getStorages(self, storageName, protocolSections=None, hideExceptions=False):
self.storages = {}
if protocolSections is None:
protocolSections = []
elif isinstance(protocolSections, six.string_types):
elif isinstance(protocolSections, str):
protocolSections = [protocolSections]
if not self.vo:
gLogger.warn("No VO information available")
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/Resources/Storage/Utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Storage plug-ins related utilities
"""
import six

import errno

from DIRAC import S_OK, S_ERROR
Expand All @@ -9,10 +9,10 @@
def checkArgumentFormat(path):
"""returns {'/this/is/an/lfn.1':False, '/this/is/an/lfn.2':False ...}"""

if isinstance(path, six.string_types):
if isinstance(path, str):
return S_OK({path: False})
elif isinstance(path, list):
return S_OK(dict([(url, False) for url in path if isinstance(url, six.string_types)]))
return S_OK(dict([(url, False) for url in path if isinstance(url, str)]))
elif isinstance(path, dict):
returnDict = path.copy()
return S_OK(returnDict)
Expand Down

0 comments on commit 19f47fb

Please sign in to comment.