Skip to content

Commit ac9bfc7

Browse files
committed
Remove Python <=3.5 code
Using `ack --type=python -f | xargs pyupgrade --py3-plus` Also: - Remove dependency on `six`
1 parent 7f21ae2 commit ac9bfc7

99 files changed

Lines changed: 418 additions & 472 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ flake8
1919
mypy
2020
types-paramiko
2121
types-pkg-resources
22-
types-six
2322
types-PyYAML
2423
types-pycurl
2524
types-requests

docker/coexecutor/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN apt-get update \
2424
# Install Pulsar Python requirements
2525
&& pip install --no-cache-dir -U pip \
2626
&& pip install --no-cache-dir drmaa wheel kombu pykube pycurl \
27-
webob psutil PasteDeploy six pyyaml paramiko \
27+
webob psutil PasteDeploy pyyaml paramiko \
2828
# Remove build deps and cleanup
2929
&& apt-get -y remove gcc wget lsb-release \
3030
&& apt-get -y autoremove \

docs/conf.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Pulsar documentation build configuration file, created by
43
# sphinx-quickstart on Sun Dec 16 23:16:23 2012.
@@ -42,8 +41,8 @@
4241
master_doc = 'index'
4342

4443
# General information about the project.
45-
project = u'Pulsar'
46-
copyright = u'2014, Galaxy Project'
44+
project = 'Pulsar'
45+
copyright = '2014, Galaxy Project'
4746

4847
# The version info for the project you're documenting, acts as replacement for
4948
# |version| and |release|, also used in various other places throughout the
@@ -185,8 +184,8 @@
185184
# Grouping the document tree into LaTeX files. List of tuples
186185
# (source start file, target name, title, author, documentclass [howto/manual]).
187186
latex_documents = [
188-
('index', 'Pulsar.tex', u'Pulsar Documentation',
189-
u'The Galaxy Project', 'manual'),
187+
('index', 'Pulsar.tex', 'Pulsar Documentation',
188+
'The Galaxy Project', 'manual'),
190189
]
191190

192191
# The name of an image file (relative to this directory) to place at the top of
@@ -215,8 +214,8 @@
215214
# One entry per manual page. List of tuples
216215
# (source start file, name, description, authors, manual section).
217216
man_pages = [
218-
('index', 'pulsar', u'Pulsar Documentation',
219-
[u'Galaxy Project'], 1)
217+
('index', 'pulsar', 'Pulsar Documentation',
218+
['Galaxy Project'], 1)
220219
]
221220

222221
# If true, show URL addresses after external links.
@@ -229,8 +228,8 @@
229228
# (source start file, target name, title, author,
230229
# dir menu entry, description, category)
231230
texinfo_documents = [
232-
('index', 'Pulsar', u'Pulsar Documentation',
233-
u'Galaxy Project', 'Pulsar', 'One line description of project.',
231+
('index', 'Pulsar', 'Pulsar Documentation',
232+
'Galaxy Project', 'Pulsar', 'One line description of project.',
234233
'Miscellaneous'),
235234
]
236235

pulsar/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# -*- coding: utf-8 -*-
2-
31
__version__ = '0.15.0.dev0'
42

53
PROJECT_NAME = "pulsar"
64
PROJECT_OWNER = PROJECT_USERAME = "galaxyproject"
75
PROJECT_AUTHOR = 'Galaxy Project and Community'
86
PROJECT_EMAIL = 'jmchilton@gmail.com'
97

10-
PROJECT_URL = "https://github.com/%s/%s" % (PROJECT_OWNER, PROJECT_NAME)
11-
RAW_CONTENT_URL = "https://raw.github.com/%s/%s/master/" % (
8+
PROJECT_URL = "https://github.com/{}/{}".format(PROJECT_OWNER, PROJECT_NAME)
9+
RAW_CONTENT_URL = "https://raw.github.com/{}/{}/master/".format(
1210
PROJECT_USERAME, PROJECT_NAME
1311
)

pulsar/cache/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from hashlib import sha256
32
from os.path import exists, join
43

@@ -7,7 +6,7 @@
76
from .util import Time
87

98

10-
class CacheFileMapper(object):
9+
class CacheFileMapper:
1110

1211
def __init__(self, directory):
1312
self.directory = directory
@@ -22,7 +21,7 @@ class Cache(PersistenceStore):
2221
"""
2322

2423
def __init__(self, cache_directory="file_cache"):
25-
super(Cache, self).__init__(join(cache_directory, "cache_shelf"))
24+
super().__init__(join(cache_directory, "cache_shelf"))
2625
self.file_mapper = CacheFileMapper(cache_directory)
2726
self.time = Time
2827

@@ -58,7 +57,7 @@ def __destination(self, ip, path):
5857
return self.destination(token)
5958

6059
def __token(self, ip, path):
61-
for_hash = "IP:%s:%s" % (ip, path)
60+
for_hash = "IP:{}:{}".format(ip, path)
6261
return sha256(for_hash.encode('UTF-8')).hexdigest()
6362

6463

pulsar/cache/persistence.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
import shelve
32
import traceback
43

54
from threading import Lock
65

76

8-
class PersistenceStore(object):
7+
class PersistenceStore:
98

109
def __init__(self, filename, require_sync=True):
1110
self.shelf_filename = filename

pulsar/cache/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import os
32
import shutil
43

@@ -22,7 +21,7 @@ def atomicish_move(source, destination, tmp_suffix="_TMP"):
2221
"""
2322
destination_dir = os.path.dirname(destination)
2423
destination_name = os.path.basename(destination)
25-
temp_destination = os.path.join(destination_dir, "%s%s" % (destination_name, tmp_suffix))
24+
temp_destination = os.path.join(destination_dir, "{}{}".format(destination_name, tmp_suffix))
2625
shutil.move(source, temp_destination)
2726
os.rename(temp_destination, destination)
2827

pulsar/client/action_mapper.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
MISSING_SSH_KEY_ERROR = "Attempt to use file transfer action requiring an SSH key without specifying a ssh_key."
8787

8888

89-
class FileActionMapper(object):
89+
class FileActionMapper:
9090
"""
9191
Objects of this class define how paths are mapped to actions.
9292
@@ -263,7 +263,7 @@ def __inject_url(self, action, file_type):
263263
if "?" not in url_base:
264264
url_base = "%s?" % url_base
265265
# TODO: URL encode path.
266-
url = "%s&path=%s&file_type=%s" % (url_base, action.path, file_type)
266+
url = "{}&path={}&file_type={}".format(url_base, action.path, file_type)
267267
action.url = url
268268

269269
def __inject_ssh_properties(self, action):
@@ -281,7 +281,7 @@ def __inject_ssh_properties(self, action):
281281
UNSET_ACTION_KWD = "__UNSET__"
282282

283283

284-
class BaseAction(object):
284+
class BaseAction:
285285
whole_directory_transfer_supported = False
286286
action_spec: Dict[str, Any] = {}
287287
action_type: str
@@ -341,7 +341,7 @@ def __str__(self):
341341
first = False
342342
else:
343343
attribute_str += ","
344-
attribute_str += "%s=%s" % (key, value)
344+
attribute_str += "{}={}".format(key, value)
345345
return "FileAction[%s]" % attribute_str
346346

347347

@@ -376,7 +376,7 @@ class RewriteAction(BaseAction):
376376
staging = STAGING_ACTION_NONE
377377

378378
def __init__(self, source, file_lister=None, source_directory=None, destination_directory=None):
379-
super(RewriteAction, self).__init__(source, file_lister=file_lister)
379+
super().__init__(source, file_lister=file_lister)
380380
self.source_directory = source_directory
381381
self.destination_directory = destination_directory
382382

@@ -453,7 +453,7 @@ class RemoteTransferAction(BaseAction):
453453
staging = STAGING_ACTION_REMOTE
454454

455455
def __init__(self, source, file_lister=None, url=None):
456-
super(RemoteTransferAction, self).__init__(source, file_lister=file_lister)
456+
super().__init__(source, file_lister=file_lister)
457457
self.url = url
458458

459459
def to_dict(self):
@@ -511,7 +511,7 @@ class PubkeyAuthenticatedTransferAction(BaseAction):
511511

512512
def __init__(self, source, file_lister=None, ssh_user=UNSET_ACTION_KWD,
513513
ssh_host=UNSET_ACTION_KWD, ssh_port=UNSET_ACTION_KWD, ssh_key=UNSET_ACTION_KWD):
514-
super(PubkeyAuthenticatedTransferAction, self).__init__(source, file_lister=file_lister)
514+
super().__init__(source, file_lister=file_lister)
515515
self.ssh_user = ssh_user
516516
self.ssh_host = ssh_host
517517
self.ssh_port = ssh_port
@@ -587,7 +587,7 @@ def write_from_path(self, pulsar_path):
587587
self.ssh_port, key_file)
588588

589589

590-
class MessageAction(object):
590+
class MessageAction:
591591
""" Sort of pseudo action describing "files" store in memory and
592592
transferred via message (HTTP, Python-call, MQ, etc...)
593593
"""
@@ -649,7 +649,7 @@ def from_dict(action_dict):
649649
return target_class.from_dict(action_dict)
650650

651651

652-
class BasePathMapper(object):
652+
class BasePathMapper:
653653
match_type: str
654654

655655
def __init__(self, config):
@@ -697,7 +697,7 @@ class PathTypeOnlyMapper(BasePathMapper):
697697
match_type = 'path_type_only'
698698

699699
def __init__(self, config):
700-
super(PathTypeOnlyMapper, self).__init__(config)
700+
super().__init__(config)
701701

702702
def _path_matches(self, path):
703703
return True
@@ -710,14 +710,14 @@ class PrefixPathMapper(BasePathMapper):
710710
match_type = 'prefix'
711711

712712
def __init__(self, config):
713-
super(PrefixPathMapper, self).__init__(config)
713+
super().__init__(config)
714714
self.prefix_path = abspath(config['path'])
715715

716716
def _path_matches(self, path):
717717
return path is not None and path.startswith(self.prefix_path)
718718

719719
def to_pattern(self):
720-
pattern_str = r"(%s%s[^\s,\"\']+)" % (escape(self.prefix_path), escape(sep))
720+
pattern_str = r"({}{}[^\s,\"\']+)".format(escape(self.prefix_path), escape(sep))
721721
return compile(pattern_str)
722722

723723
def to_dict(self):
@@ -728,7 +728,7 @@ class GlobPathMapper(BasePathMapper):
728728
match_type = 'glob'
729729

730730
def __init__(self, config):
731-
super(GlobPathMapper, self).__init__(config)
731+
super().__init__(config)
732732
self.glob_path = config['path']
733733

734734
def _path_matches(self, path):
@@ -745,7 +745,7 @@ class RegexPathMapper(BasePathMapper):
745745
match_type = 'regex'
746746

747747
def __init__(self, config):
748-
super(RegexPathMapper, self).__init__(config)
748+
super().__init__(config)
749749
self.pattern_raw = config['path']
750750
self.pattern = compile(self.pattern_raw)
751751

@@ -775,7 +775,7 @@ def _mappper_from_dict(mapper_dict):
775775
return MAPPER_CLASS_DICT[map_type](mapper_dict)
776776

777777

778-
class FileLister(object):
778+
class FileLister:
779779

780780
def __init__(self, config):
781781
self.depth = int(config.get("depth", "0"))
@@ -793,7 +793,7 @@ def unstructured_map(self, path):
793793
while depth > 0:
794794
path = dirname(path)
795795
depth -= 1
796-
return dict([(join(path, f), f) for f in directory_files(path)])
796+
return {join(path, f): f for f in directory_files(path)}
797797

798798

799799
DEFAULT_FILE_LISTER = FileLister(dict(depth=0))
@@ -809,7 +809,7 @@ def unstructured_map(self, path):
809809
RsyncTransferAction,
810810
ScpTransferAction,
811811
]
812-
actions = dict([(clazz.action_type, clazz) for clazz in ACTION_CLASSES])
812+
actions = {clazz.action_type: clazz for clazz in ACTION_CLASSES}
813813

814814

815815
__all__ = (

pulsar/client/amqp_exchange.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
DEFAULT_REPUBLISH_TIME = 30
3838

3939

40-
class PulsarExchange(object):
40+
class PulsarExchange:
4141
""" Utility for publishing and consuming structured Pulsar queues using kombu.
4242
This is shared between the server and client - an exchange should be setup
4343
for each manager (or in the case of the client, each manager one wished to
@@ -115,7 +115,7 @@ def consume(self, queue_name, callback, check=True, connection_kwargs={}):
115115
connection.drain_events(timeout=self.__timeout)
116116
except socket.timeout:
117117
pass
118-
except (IOError, socket.error) as exc:
118+
except OSError as exc:
119119
self.__handle_io_error(exc, heartbeat_thread)
120120
except BaseException:
121121
log.exception("Problem consuming queue, consumer quitting in problematic fashion!")
@@ -287,7 +287,7 @@ def __queue(self, name):
287287

288288
def __queue_name(self, name):
289289
key_prefix = self.__key_prefix()
290-
queue_name = '%s_%s' % (key_prefix, name)
290+
queue_name = '{}_{}'.format(key_prefix, name)
291291
return queue_name
292292

293293
def __key_prefix(self):

0 commit comments

Comments
 (0)