python-apt: add option to parse Mastermirror list for mirmon format.
This commit is contained in:
parent
37d28150c3
commit
46d5e40e51
1 changed files with 16 additions and 0 deletions
|
|
@ -31,6 +31,10 @@ parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
help="Filter by country (e.g., AU, BR, CA)",
|
help="Filter by country (e.g., AU, BR, CA)",
|
||||||
default=None)
|
default=None)
|
||||||
|
parser.add_argument(
|
||||||
|
"--mirmon",
|
||||||
|
action="store_true",
|
||||||
|
help="List mirrors suitable for mirmon output")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
with open(args.file, 'r') as file:
|
with open(args.file, 'r') as file:
|
||||||
|
|
@ -67,6 +71,18 @@ for block in blocks:
|
||||||
mirrors[country] = {}
|
mirrors[country] = {}
|
||||||
mirrors[country][site] = {"https": https_urls, "http": http_urls}
|
mirrors[country][site] = {"https": https_urls, "http": http_urls}
|
||||||
|
|
||||||
|
# Print mirmon output if selected
|
||||||
|
if args.mirmon:
|
||||||
|
for country, sites in sorted(mirrors.items()):
|
||||||
|
if args.country and country != args.country:
|
||||||
|
continue
|
||||||
|
for site, urls in sites.items():
|
||||||
|
if urls["http"]:
|
||||||
|
print(f"{country.lower()} {urls['http'][0]}")
|
||||||
|
elif urls["https"]:
|
||||||
|
print(f"{country.lower()} {urls['https'][0]}")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
# Print output
|
# Print output
|
||||||
for country, sites in sorted(mirrors.items()):
|
for country, sites in sorted(mirrors.items()):
|
||||||
if args.country and country != args.country:
|
if args.country and country != args.country:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue