From d63eb8f771f7e947bae7da7b762e9e815ae57246 Mon Sep 17 00:00:00 2001 From: Fuxino Date: Thu, 15 Jun 2023 15:34:00 +0200 Subject: [PATCH] Improve handling of missing inputs --- simple_backup/simple_backup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index e9ef4f0..c12b4eb 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -95,7 +95,7 @@ class Backup: def check_params(self): if self.inputs is None or len(self.inputs) == 0: - logger.info('No files or directory specified for backup.') + logger.info('No existing files or directories specified for backup. Nothing to do') return False @@ -181,11 +181,8 @@ class Backup: with open(self._inputs_path, 'w') as fp: for i in self.inputs: - if not os.path.exists(i): - logger.warning(f'Input {i} not found. Skipping') - else: - fp.write(i) - fp.write('\n') + fp.write(i) + fp.write('\n') with open(self._exclude_path, 'w') as fp: if self.exclude is not None: @@ -267,12 +264,15 @@ def _expand_inputs(inputs): expanded_inputs = [] for i in inputs: + if i == '': + continue + i_ex = glob(os.path.expanduser(i.replace('~', f'~{user}'))) if len(i_ex) == 0: logger.warning(f'No file or directory matching input {i}. Skipping...') else: - expanded_inputs.extend(glob(os.path.expanduser(i.replace('~', f'~{user}')))) + expanded_inputs.extend(i_ex) return expanded_inputs