-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cd(bump-version): add get_version script (#197)
- Loading branch information
Showing
5 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Empty file.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
|
||
|
||
def get_version() -> str: | ||
"""Returns the current version. | ||
Returns: | ||
current version | ||
Raises: | ||
ValueError: Invalid version | ||
""" | ||
package_path = Path(__file__).parents[2] / 'aviary' / '__init__.py' | ||
|
||
with package_path.open() as file: | ||
lines = file.readlines() | ||
|
||
for line in lines: | ||
if line.startswith('__version__ = '): | ||
return line.split('=')[1].strip().strip("'") | ||
|
||
message = 'Invalid version!' | ||
raise ValueError(message) | ||
|
||
|
||
if __name__ == '__main__': | ||
print(get_version()) |
This file contains 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