55import argparse
66import logging
77import sys
8- from typing import (
9- Iterable ,
10- )
118
129from azul import (
1310 CatalogName ,
2017from azul .azulclient import (
2118 AzulClient ,
2219)
23- from azul .indexer import (
24- SourceRef ,
25- )
2620from azul .logging import (
2721 configure_script_logging ,
2822)
@@ -44,28 +38,31 @@ def mirror_catalog(azul: AzulClient,
4438 source .spec : source
4539 for source in plugin .list_sources (authentication = None )
4640 }
47- source_refs : Iterable [SourceRef ]
48- # When the user doesn't specify a source or provides "*" as a source glob,
49- # we implicitly filter out managed-access sources. This lets us assert that
50- # all sources matching the provided globs are public, without forcing the
51- # user to manually specify every public source.
41+ source_specs = azul .matching_sources ([catalog ], source_globs )[catalog ]
5242 if '*' in source_globs :
53- source_refs = public_sources_by_spec .values ()
43+ # When the user doesn't specify a source or provides "*" as a source glob,
44+ # we implicitly filter out managed-access sources. This lets us assert that
45+ # all sources matching the provided globs are public, without forcing the
46+ # user to manually specify every public source.
47+ source_specs = {
48+ spec : cfg
49+ for spec , cfg in source_specs .items ()
50+ if spec in public_sources_by_spec
51+ }
52+ try :
53+ source_refs = {
54+ public_sources_by_spec [spec ]: cfg
55+ for spec , cfg in source_specs .items ()
56+ }
57+ except KeyError as e :
58+ assert False , R (
59+ 'Cannot mirror managed-access source' , e .args [0 ])
5460 else :
55- source_specs = azul .matching_sources ([catalog ], source_globs )[catalog ]
56- try :
57- source_refs = {
58- public_sources_by_spec [spec ]
59- for spec in source_specs
60- }
61- except KeyError as e :
62- assert False , R (
63- 'Cannot mirror managed-access source' , e .args [0 ])
64- azul .remote_mirror (catalog , source_refs )
65- if wait :
66- azul .wait_for_mirroring ()
67- assert azul .is_queue_empty (fail_queue ), R (
68- 'There are messages in the fail queue' , fail_queue )
61+ azul .remote_mirror (catalog , source_refs .items ())
62+ if wait :
63+ azul .wait_for_mirroring ()
64+ assert azul .is_queue_empty (fail_queue ), R (
65+ 'There are messages in the fail queue' , fail_queue )
6966
7067
7168def main (args ):
0 commit comments