Last active
October 20, 2022 07:06
-
-
Save benigumocom/284760efb999dbf9b375343308beb105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import pyperclip | |
| def parse(source): | |
| parsed = list(map(lambda s: s.strip().split(), source.splitlines())) | |
| parsed = list(map(lambda s: [s[0], s[1].strip('"').strip('\'').split(':')], parsed)) | |
| return parsed | |
| def show_source(source): | |
| print('* source') | |
| print(source) | |
| def show_libraries(parsed): | |
| print('* gradle/libs.versions.toml') | |
| print('[libraries]') | |
| for s in parsed: | |
| print(f'{s[1][1]} = {{ module = "{s[1][0]}:{s[1][1]}", version = "{s[1][2]}" }}') | |
| def show_implementations(parsed): | |
| print('* build.gradle') | |
| for s in parsed: | |
| print(f'{s[0]} libs.{s[1][1].replace("-", ".")}') | |
| def main(): | |
| # https://pypi.org/project/pyclip/ | |
| source = str(pyperclip.paste()) | |
| parsed = parse(source) | |
| show_source(source) | |
| print() | |
| show_libraries(parsed) | |
| print() | |
| show_implementations(parsed) | |
| if __name__ == '__main__': | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ❯ convert-version-catalog.py | |
| * source | |
| implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0" | |
| implementation 'com.google.accompanist:accompanist-swiperefresh:0.26.5-rc' | |
| * gradle/libs.versions.toml | |
| [libraries] | |
| accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version = "0.17.0" } | |
| accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version = "0.26.5-rc" } | |
| * build.gradle | |
| implementation libs.accompanist.systemuicontroller | |
| implementation libs.accompanist.swiperefresh |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
【gradle】Version Catalog への書き換えツールを作る 2022-10-19【python】
👉 https://android.benigumo.com/20221019/version-catalog-2022-10-19/