mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
script to extract repo list from manifest.xml
This commit is contained in:
parent
86917292c2
commit
0bee832c75
31
helpers/manifest-xml-repolist.py
Executable file
31
helpers/manifest-xml-repolist.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
def get_repolist(manifest_file: str, remotes: list):
|
||||
manifest = ET.parse(manifest_file)
|
||||
default_remote = None
|
||||
default = manifest.find('default')
|
||||
if default is not None:
|
||||
default_remote = default.get('remote')
|
||||
for project in manifest.findall('project'):
|
||||
if project.get('remote', default=default_remote) in remotes:
|
||||
yield(project)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("manifest",
|
||||
help='path to manifest.xml')
|
||||
parser.add_argument("remote", nargs='+',
|
||||
help='remotes whose projects should be included')
|
||||
args = parser.parse_args()
|
||||
for repo in get_repolist(args.manifest, args.remote):
|
||||
print(repo.get('name'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
# vim: ts=4 sw=4 sts=4 expandtab
|
Loading…
x
Reference in New Issue
Block a user