diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index 59e7425d..6e70032f 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -60,6 +60,7 @@ def _validate_collections_param(collections): raise ValueError("`collections` parameter must be a list or `null`.") collection_names = set() + collection_blacklist = set() for i, collection in enumerate(collections): try: @@ -87,9 +88,14 @@ def _validate_collections_param(collections): if collection_name in collection_names: raise ValueError("Duplicate value.") collection_names.add(collection_name) + + if collection[0] == "!": + collection_blacklist.add(collection_name[1:]) except ValueError as e: raise ValueError(f"`collections` parameter, position {i}: {str(e)}") + return collection_blacklist + class _ConfigReader: def __init__(self, f): @@ -233,7 +239,7 @@ def __init__(self, full_config, name, options): "Set `collections = null` explicitly in your pair config." ) else: - _validate_collections_param(self.collections) + self.blacklist = _validate_collections_param(self.collections) if options: raise ValueError("Unknown options: {}".format(", ".join(options))) diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index c28af141..84e7bda1 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -97,6 +97,7 @@ async def collections_for_pair( rv = await aiostream.stream.list( expand_collections( shortcuts=pair.collections, + blacklist=pair.blacklist, config_a=pair.config_a, config_b=pair.config_b, get_a_discovered=a_discovered.get_self, @@ -194,6 +195,7 @@ async def _discover(self): async def expand_collections( shortcuts, + blacklist, config_a, config_b, get_a_discovered, @@ -221,6 +223,10 @@ async def expand_collections( if collection in handled_collections: continue + elif collection[0] == "!": + continue + elif collection in blacklist: + continue handled_collections.add(collection) a_args = await _collection_from_discovered(