-
Notifications
You must be signed in to change notification settings - Fork 2
Update artifactory-oidc to extract existing settings.xml info #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
601aef2
97794ed
030df2b
2e26cfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env python3 | ||
| """Print the child elements of the first <tag> found in an XML file, ignoring | ||
| namespaces, as XML fragments (bare of namespace declarations). Used in place | ||
| of `xmllint --xpath "//*[local-name()='TAG']/*"`, which isn't installed on | ||
| GitHub-hosted runners by default. | ||
|
|
||
| Usage: extract-xml-children.py <file> <tag> | ||
| """ | ||
| import sys | ||
| import xml.etree.ElementTree as ET | ||
|
|
||
|
|
||
| def strip_ns(el: ET.Element) -> ET.Element: | ||
| """ | ||
| Remove the namespace from the default {namespace_namespace}tag_name representation | ||
|
|
||
| Instead of {http://maven....}server, we'd get server | ||
| """ | ||
| el.tag = el.tag.rsplit("}", 1)[-1] | ||
| for child in el: | ||
| strip_ns(child) | ||
| return el | ||
|
|
||
|
|
||
| def main() -> None: | ||
| path, tag = sys.argv[1], sys.argv[2] | ||
| root = ET.parse(path).getroot() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🥳 Removed in commit 2e26cfc 🥳 |
||
| for el in root.iter(): | ||
| if el.tag.rsplit("}", 1)[-1] == tag: | ||
| for child in list(el): | ||
| sys.stdout.write(ET.tostring(strip_ns(child), encoding="unicode")) | ||
| return | ||
| pass # No matching parent element found — print nothing. | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Uh oh!
There was an error while loading. Please reload this page.