Merge pull request #4742 from rtfd/davidfischer/storage-syncers

Make storage syncers extend from a base class
humitos/integrations/handle-error-codes
David Fischer 2018-10-16 11:42:54 -07:00 committed by GitHub
commit 5b5edabb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 8 deletions

View File

@ -22,10 +22,19 @@ from readthedocs.core.utils import safe_makedirs
log = logging.getLogger(__name__)
class LocalSyncer(object):
class BaseSyncer(object):
"""A base object for syncers and pullers"""
@classmethod
def copy(cls, path, target, is_file=False, **__):
def copy(cls, path, target, is_file=False, **kwargs):
raise NotImplementedError
class LocalSyncer(BaseSyncer):
@classmethod
def copy(cls, path, target, is_file=False, **kwargs):
"""A copy command that works with files or directories."""
log.info("Local Copy %s to %s", path, target)
if is_file:
@ -41,10 +50,10 @@ class LocalSyncer(object):
shutil.copytree(path, target)
class RemoteSyncer(object):
class RemoteSyncer(BaseSyncer):
@classmethod
def copy(cls, path, target, is_file=False, **__):
def copy(cls, path, target, is_file=False, **kwargs):
"""
A better copy command that works with files or directories.
@ -77,10 +86,10 @@ class RemoteSyncer(object):
log.debug("Copy error to app servers: cmd=%s", sync_cmd)
class DoubleRemotePuller(object):
class DoubleRemotePuller(BaseSyncer):
@classmethod
def copy(cls, path, target, host, is_file=False, **__):
def copy(cls, path, target, host, is_file=False, **kwargs): # pylint: disable=arguments-differ
"""
A better copy command that works from the webs.
@ -114,10 +123,10 @@ class DoubleRemotePuller(object):
log.debug("Copy error to app servers: cmd=%s", sync_cmd)
class RemotePuller(object):
class RemotePuller(BaseSyncer):
@classmethod
def copy(cls, path, target, host, is_file=False, **__):
def copy(cls, path, target, host, is_file=False, **kwargs): # pylint: disable=arguments-differ
"""
A better copy command that works from the webs.