|
| 1 | +import fnmatch |
| 2 | +import logging |
| 3 | +import uuid |
1 | 4 | from collections import ( |
2 | 5 | defaultdict, |
3 | 6 | ) |
|
11 | 14 | from enum import ( |
12 | 15 | auto, |
13 | 16 | ) |
14 | | -import fnmatch |
15 | 17 | from functools import ( |
16 | 18 | partial, |
17 | 19 | ) |
18 | | -import logging |
| 20 | +from itertools import starmap |
19 | 21 | from pprint import ( |
20 | 22 | PrettyPrinter, |
21 | 23 | ) |
22 | 24 | from typing import ( |
23 | | - AbstractSet, |
24 | | -) |
25 | | -import uuid |
| 25 | + AbstractSet, ) |
26 | 26 |
|
27 | 27 | import attrs |
28 | 28 | import requests |
@@ -389,15 +389,22 @@ def is_queue_empty(self, queue_name: str) -> bool: |
389 | 389 | length, _ = self.queues.get_queue_lengths(queues) |
390 | 390 | return length == 0 |
391 | 391 |
|
392 | | - def remote_mirror(self, catalog: CatalogName, sources: Iterable[SourceRef]): |
| 392 | + def remote_mirror(self, |
| 393 | + catalog: CatalogName, |
| 394 | + sources: Iterable[tuple[SourceRef, SourceConfig]]): |
393 | 395 |
|
394 | | - def message(source: SourceRef): |
395 | | - log.info('Mirroring files in source %r from catalog %r', |
396 | | - str(source.spec), catalog) |
397 | | - return self.mirror_source_message(catalog, source) |
| 396 | + def messages(): |
| 397 | + for source, cfg in sources: |
| 398 | + if cfg.mirror: |
| 399 | + log.info('Mirroring files in source %r from catalog %r', |
| 400 | + str(source.spec), catalog) |
| 401 | + yield self.mirror_source_message(catalog, source) |
| 402 | + else: |
| 403 | + log.info('Not mirroring any files in source %r from catalog %r because ' |
| 404 | + 'mirroring is explicitly disabled', |
| 405 | + str(source.spec), catalog) |
398 | 406 |
|
399 | | - messages = map(message, sources) |
400 | | - self.queue_mirror_messages(messages) |
| 407 | + self.queue_mirror_messages(messages()) |
401 | 408 |
|
402 | 409 | def _get_non_empty_fail_queues(self) -> set[str]: |
403 | 410 | return { |
|
0 commit comments