From 7a2f287918beea36378aa0dd9fbdf8ca9ae16355 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Thu, 23 Mar 2023 01:08:30 +0530 Subject: [PATCH] reformat base --- borgmatic/config/normalize.py | 19 +++++++------------ borgmatic/config/validate.py | 9 ++++++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/borgmatic/config/normalize.py b/borgmatic/config/normalize.py index 58e3468..8ce4af2 100644 --- a/borgmatic/config/normalize.py +++ b/borgmatic/config/normalize.py @@ -84,10 +84,9 @@ def normalize(config_filename, config): } ) elif repository.startswith('ssh://'): - config['location']['repositories'].append({ - 'path': repository, - 'label': repository_dict.get('label', None), - }) + config['location']['repositories'].append( + {'path': repository, 'label': repository_dict.get('label', None),} + ) else: rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" logs.append( @@ -99,16 +98,12 @@ def normalize(config_filename, config): ) ) ) - config['location']['repositories'].append({ - 'path': rewritten_repository, - 'label': repository_dict.get('label', None), - }) + config['location']['repositories'].append( + {'path': rewritten_repository, 'label': repository_dict.get('label', None),} + ) else: config['location']['repositories'].append( - { - 'path': repository, - 'label': repository_dict.get('label', None), - } + {'path': repository, 'label': repository_dict.get('label', None),} ) return logs diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 9b64377..b43d42d 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -141,10 +141,13 @@ def repositories_match(first, second): Given two repository dicts with keys 'path' (relative and/or absolute), and 'label', return whether they match. ''' - if isinstance(first,str) and isinstance(second,str): + if isinstance(first, str) and isinstance(second, str): return normalize_repository_path(first) == normalize_repository_path(second) - elif isinstance(first,dict) and isinstance(second,str): - return (second == first.get('label')) or (normalize_repository_path(second) == normalize_repository_path(first.get('path'))) + elif isinstance(first, dict) and isinstance(second, str): + return (second == first.get('label')) or ( + normalize_repository_path(second) == normalize_repository_path(first.get('path')) + ) + def guard_configuration_contains_repository(repository, configurations): '''