From d05e01a86e4859c0c560e53a4314f1f6b95f05fa Mon Sep 17 00:00:00 2001 From: Shao-Chun Ma Date: Sat, 16 Feb 2019 16:26:45 +0100 Subject: [PATCH] command: refactor Extract method check_up_to_date(). Fixes #1619 --- dvc/command/data_sync.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index a35f0a39f..66927203a 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -24,6 +24,11 @@ class CmdDataBase(CmdBase): ret = 1 return ret + @staticmethod + def check_up_to_date(processed_files_count, message): + if processed_files_count == 0: + logger.info(message) + class CmdDataPull(CmdDataBase): def do_run(self, target=None): @@ -42,8 +47,7 @@ class CmdDataPull(CmdDataBase): except Exception: logger.error("failed to pull data from the cloud") return 1 - if processed_files_count == 0: - logger.info(self.UP_TO_DATE_MSG) + self.check_up_to_date(processed_files_count, self.UP_TO_DATE_MSG) return 0 @@ -63,8 +67,7 @@ class CmdDataPush(CmdDataBase): except Exception: logger.error("failed to push data to the cloud") return 1 - if processed_files_count == 0: - logger.info(self.UP_TO_DATE_MSG) + self.check_up_to_date(processed_files_count, self.UP_TO_DATE_MSG) return 0 @@ -84,8 +87,7 @@ class CmdDataFetch(CmdDataBase): except Exception: logger.error("failed to fetch data from the cloud") return 1 - if processed_files_count == 0: - logger.info(self.UP_TO_DATE_MSG) + self.check_up_to_date(processed_files_count, self.UP_TO_DATE_MSG) return 0