Skip to content

Commit

Permalink
Changelog entry and minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Aug 21, 2024
1 parent 2a38f73 commit a480bbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).
- Querying Wikidata lexicographical data can be done via the `--query` command ([#159](https://github.com/scribe-org/Scribe-Data/issues/159)).
- The output type of queries can be in JSON, CSV, TSV and SQLite, with conversions output types also being possible ([#145](https://github.com/scribe-org/Scribe-Data/issues/145), [#146](https://github.com/scribe-org/Scribe-Data/issues/146))
- Output paths can be set for query results ([#144](https://github.com/scribe-org/Scribe-Data/issues/144)).
- The version of the CLI can be printed to the command line ([#186](https://github.com/scribe-org/Scribe-Data/issues/186)).
- Total Wikidata lexemes for languages and data types can be derived with the `--total` command ([#147](https://github.com/scribe-org/Scribe-Data/issues/147)).
- Commands can be used via an interactive mode with the `--interactive` command ([#158](https://github.com/scribe-org/Scribe-Data/issues/158)).
- Articles are removed from machine translations so they're more directly useful in Scribe applications ([#96](https://github.com/scribe-org/Scribe-Data/issues/96)).
Expand Down
20 changes: 11 additions & 9 deletions src/scribe_data/cli/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
def get_local_version():
try:
return pkg_resources.get_distribution("scribe-data").version

except pkg_resources.DistributionNotFound:
return "Unknown (Not installed via pip)"

Expand All @@ -36,14 +37,14 @@ def get_latest_version():
response = requests.get(
"https://api.github.com/repos/scribe-org/Scribe-Data/releases/latest"
)
version = response.json()["name"]
return version
return response.json()["name"]

except Exception:
return "Unknown (Unable to fetch version)"


def get_version_message():
local_version = "Scribe-Data v" + get_local_version()
local_version = f"Scribe-Data v{get_local_version()}"
latest_version = get_latest_version()

if (
Expand All @@ -54,9 +55,10 @@ def get_version_message():

if local_version == latest_version:
return f"{local_version}"
else:
update_message = (
f"Scribe-Data v{local_version} (Update available: v{latest_version})\n"
)
update_message += "To update, run: pip scribe-data --upgrade"
return update_message

update_message = (
f"Scribe-Data v{local_version} (Update available: v{latest_version})\n"
)
update_message += "To update: pip scribe-data --upgrade"

return update_message

0 comments on commit a480bbb

Please sign in to comment.