Skip to content

Commit

Permalink
Use modern super()
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Jun 19, 2022
1 parent a843f3b commit 406e819
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 39 deletions.
6 changes: 3 additions & 3 deletions ftpsync/ftp_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
# path = self.to_unicode(path)
path = path or "/"
assert is_native(path)
super(FTPTarget, self).__init__(path, extra_opts)
super().__init__(path, extra_opts)
if tls:
try:
self.ftp = ftplib.FTP_TLS()
Expand Down Expand Up @@ -122,7 +122,7 @@ def get_base_name(self):
def open(self):
assert not self.ftp_socket_connected

super(FTPTarget, self).open()
super().open()

options = self.get_options_dict()
no_prompt = self.get_option("no_prompt", True)
Expand Down Expand Up @@ -279,7 +279,7 @@ def close(self):
write_error("ftp.quit() failed: {}".format(e))
self.ftp_socket_connected = False

super(FTPTarget, self).close()
super().close()

def _lock(self, break_existing=False):
"""Write a special file to the target root folder."""
Expand Down
6 changes: 2 additions & 4 deletions ftpsync/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class FileEntry(_Resource):
# EPS_TIME = 0.1

def __init__(self, target, rel_path, name, size, mtime, unique):
super(FileEntry, self).__init__(target, rel_path, name, size, mtime, unique)
super().__init__(target, rel_path, name, size, mtime, unique)

@staticmethod
def _eps_compare(date_1, date_2):
Expand Down Expand Up @@ -397,9 +397,7 @@ def was_modified_since_last_sync(self):
# ===============================================================================
class DirectoryEntry(_Resource):
def __init__(self, target, rel_path, name, size, mtime, unique):
super(DirectoryEntry, self).__init__(
target, rel_path, name, size, mtime, unique
)
super().__init__(target, rel_path, name, size, mtime, unique)
# Directories don't have a size (that we could reasonably use for classification)
self.size = 0

Expand Down
6 changes: 3 additions & 3 deletions ftpsync/sftp_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
# path = self.to_unicode(path)
path = path or "/"
assert is_native(path)
super(SFTPTarget, self).__init__(path, extra_opts)
super().__init__(path, extra_opts)

self.sftp = None
self.host = host
Expand Down Expand Up @@ -110,7 +110,7 @@ def get_base_name(self):
def open(self):
assert not self.ftp_socket_connected

super(SFTPTarget, self).open()
super().open()

options = self.get_options_dict()
no_prompt = self.get_option("no_prompt", True)
Expand Down Expand Up @@ -217,7 +217,7 @@ def close(self):
write_error("sftp.close() failed: {}".format(e))
self.ftp_socket_connected = False

super(SFTPTarget, self).close()
super().close()

def _lock(self, break_existing=False):
"""Write a special file to the target root folder."""
Expand Down
16 changes: 8 additions & 8 deletions ftpsync/synchronizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ class BiDirSynchronizer(BaseSynchronizer):
"""

def __init__(self, local, remote, options):
super(BiDirSynchronizer, self).__init__(local, remote, options)
super().__init__(local, remote, options)

def get_info_strings(self):
return ("synchronize", "with")
Expand Down Expand Up @@ -834,7 +834,7 @@ def _interactive_resolve(self, pair):

def run(self):
# Don't override setting by derived up/downloader
res = super(BiDirSynchronizer, self).run()
res = super().run()
return res

def on_mismatch(self, pair):
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def on_conflict(self, pair):

class UploadSynchronizer(BiDirSynchronizer):
def __init__(self, local, remote, options):
super(UploadSynchronizer, self).__init__(local, remote, options)
super().__init__(local, remote, options)
# local.readonly = True

def get_info_strings(self):
Expand Down Expand Up @@ -1101,7 +1101,7 @@ def _interactive_resolve(self, pair):
def run(self):
self.local.readonly = True
self.remote.readonly = False
res = super(UploadSynchronizer, self).run()
res = super().run()
return res

def on_mismatch(self, pair):
Expand Down Expand Up @@ -1138,7 +1138,7 @@ def on_delete_remote(self, pair):
if not self.options.get("delete"):
self._log_action("skip", "remote del.", " >X", pair.remote)
return
return super(UploadSynchronizer, self).on_delete_remote(pair)
return super().on_delete_remote(pair)

# def on_need_compare(self, pair):
# self._log_action("", "different", "?", pair.local, min_level=2)
Expand All @@ -1157,7 +1157,7 @@ class DownloadSynchronizer(BiDirSynchronizer):
""""""

def __init__(self, local, remote, options):
super(DownloadSynchronizer, self).__init__(local, remote, options)
super().__init__(local, remote, options)

# remote.readonly = True

Expand Down Expand Up @@ -1252,7 +1252,7 @@ def _interactive_resolve(self, pair):
def run(self):
self.local.readonly = False
self.remote.readonly = True
res = super(DownloadSynchronizer, self).run()
res = super().run()
return res

def on_mismatch(self, pair):
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def on_delete_local(self, pair):
if not self.options.get("delete"):
self._log_action("skip", "local del.", "X< ", pair.local)
return
return super(DownloadSynchronizer, self).on_delete_local(pair)
return super().on_delete_local(pair)

def on_delete_remote(self, pair):
# Download does not modify remote target
Expand Down
6 changes: 3 additions & 3 deletions ftpsync/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __init__(self, root_dir, extra_opts=None):
# root_dir = self.to_unicode(root_dir)
root_dir = os.path.expanduser(root_dir)
root_dir = os.path.abspath(root_dir)
super(FsTarget, self).__init__(root_dir, extra_opts)
super().__init__(root_dir, extra_opts)
if not os.path.isdir(root_dir):
raise ValueError("{} is not a directory.".format(root_dir))
self.support_set_time = True
Expand All @@ -430,11 +430,11 @@ def __str__(self):
)

def open(self):
super(FsTarget, self).open()
super().open()
self.cur_dir = self.root_dir

def close(self):
super(FsTarget, self).close()
super().close()

def cwd(self, dir_name):
path = normpath_url(join_url(self.cur_dir, dir_name))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class FixtureTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(FixtureTest, self).setUp()
super().setUp()

def tearDown(self):
super(FixtureTest, self).tearDown()
super().tearDown()

def test_prepare_initial_synced_fixture(self):
# """Test that fixture set up code worked."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class CliTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(CliTest, self).setUp()
super().setUp()
self.local = get_local_test_url()
self.remote = get_remote_test_url()

def tearDown(self):
super(CliTest, self).tearDown()
super().tearDown()

def test_basic(self):
out = run_script("--version")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class TempDevelopTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(TempDevelopTest, self).setUp()
super().setUp()
self.local_url = get_local_test_url()
self.remote_url = get_remote_test_url()

def tearDown(self):
super(TempDevelopTest, self).tearDown()
super().tearDown()

def test_issue_20(self):

Expand Down
4 changes: 2 additions & 2 deletions tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class ScanTest(_SyncTestBase):
"""Test --match and --exclude."""

def setUp(self):
super(ScanTest, self).setUp()
super().setUp()
self.local = get_local_test_url()
self.remote = get_remote_test_url()

def tearDown(self):
super(ScanTest, self).tearDown()
super().tearDown()

re_whitespace = re.compile(r"\s+")

Expand Down
8 changes: 4 additions & 4 deletions tests/test_sync_bidir.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class BidirSyncTest(_SyncTestBase):
"""Test BiDirSynchronizer on file system targets with different resolve modes."""

def setUp(self):
super(BidirSyncTest, self).setUp()
super().setUp()

def tearDown(self):
super(BidirSyncTest, self).tearDown()
super().tearDown()

def test_default(self):
opts = {"verbose": self.verbose} # default options, i.e. 'skip' conflicts
Expand Down Expand Up @@ -332,10 +332,10 @@ class BidirSpecialTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(BidirSpecialTest, self).setUp()
super().setUp()

def tearDown(self):
super(BidirSpecialTest, self).tearDown()
super().tearDown()

def test_folder_conflict(self):
"""Delete a folder on one side, but change content on other side."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sync_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class DownloadResolveTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(DownloadResolveTest, self).setUp()
super().setUp()

def tearDown(self):
super(DownloadResolveTest, self).tearDown()
super().tearDown()

def test_default(self):
opts = {"verbose": self.verbose} # default options, i.e. 'skip' conflicts
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sync_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class UploadResolveTest(_SyncTestBase):

def setUp(self):
# Call self._prepare_initial_synced_fixture():
super(UploadResolveTest, self).setUp()
super().setUp()

def tearDown(self):
super(UploadResolveTest, self).tearDown()
super().tearDown()

def test_default(self):
opts = {"verbose": self.verbose} # default options, i.e. 'skip' conflicts
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class TreeTest(_SyncTestBase):
"""Test `tree`command."""

def setUp(self):
super(TreeTest, self).setUp()
super().setUp()
self.local = get_local_test_url()
self.remote = get_remote_test_url()

def tearDown(self):
super(TreeTest, self).tearDown()
super().tearDown()

re_whitespace = re.compile(r"\s+")

Expand Down

0 comments on commit 406e819

Please sign in to comment.