reformat base

This commit is contained in:
Divyansh Singh 2023-03-23 01:08:30 +05:30
parent 8a63c49498
commit 7a2f287918
2 changed files with 13 additions and 15 deletions

View File

@ -84,10 +84,9 @@ def normalize(config_filename, config):
} }
) )
elif repository.startswith('ssh://'): elif repository.startswith('ssh://'):
config['location']['repositories'].append({ config['location']['repositories'].append(
'path': repository, {'path': repository, 'label': repository_dict.get('label', None),}
'label': repository_dict.get('label', None), )
})
else: else:
rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
logs.append( logs.append(
@ -99,16 +98,12 @@ def normalize(config_filename, config):
) )
) )
) )
config['location']['repositories'].append({ config['location']['repositories'].append(
'path': rewritten_repository, {'path': rewritten_repository, 'label': repository_dict.get('label', None),}
'label': repository_dict.get('label', None), )
})
else: else:
config['location']['repositories'].append( config['location']['repositories'].append(
{ {'path': repository, 'label': repository_dict.get('label', None),}
'path': repository,
'label': repository_dict.get('label', None),
}
) )
return logs return logs

View File

@ -141,10 +141,13 @@ def repositories_match(first, second):
Given two repository dicts with keys 'path' (relative and/or absolute), Given two repository dicts with keys 'path' (relative and/or absolute),
and 'label', return whether they match. 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) return normalize_repository_path(first) == normalize_repository_path(second)
elif isinstance(first,dict) and isinstance(second,str): elif isinstance(first, dict) and isinstance(second, str):
return (second == first.get('label')) or (normalize_repository_path(second) == normalize_repository_path(first.get('path'))) return (second == first.get('label')) or (
normalize_repository_path(second) == normalize_repository_path(first.get('path'))
)
def guard_configuration_contains_repository(repository, configurations): def guard_configuration_contains_repository(repository, configurations):
''' '''