MCPcopy
hub / github.com/pimutils/vdirsyncer / prepare_pair

Function prepare_pair

vdirsyncer/cli/tasks.py:13–40  ·  view source on GitHub ↗
(wq, pair_name, collections, config, callback, **kwargs)

Source from the content-addressed store, hash-verified

11
12
13def prepare_pair(wq, pair_name, collections, config, callback, **kwargs):
14 pair = config.get_pair(pair_name)
15
16 all_collections = dict(collections_for_pair(
17 status_path=config.general['status_path'], pair=pair
18 ))
19
20 # spawn one worker less because we can reuse the current one
21 new_workers = -1
22 for collection_name in (collections or all_collections):
23 try:
24 config_a, config_b = all_collections[collection_name]
25 except KeyError:
26 raise exceptions.UserError(
27 'Pair {}: Collection {} not found. These are the '
28 'configured collections:\n{}'
29 .format(pair_name,
30 json.dumps(collection_name),
31 list(all_collections)))
32 new_workers += 1
33
34 collection = CollectionConfig(pair, collection_name, config_a,
35 config_b)
36 wq.put(functools.partial(callback, collection=collection,
37 general=config.general, **kwargs))
38
39 for _ in range(new_workers):
40 wq.spawn_worker()
41
42
43def sync_collection(wq, collection, general, force_delete):

Callers

nothing calls this directly

Calls 5

collections_for_pairFunction · 0.85
CollectionConfigClass · 0.85
get_pairMethod · 0.80
putMethod · 0.80
spawn_workerMethod · 0.80

Tested by

no test coverage detected