Skip to content

Commit

Permalink
lint sql/latest_version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gamesguru committed Apr 18, 2024
1 parent 9244f27 commit 91a4183
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions sql/latest_version.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@

import csv
import os
import sys

SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))

try:
version_csv_path = os.path.join(SCRIPT_DIR, "version.csv")

rows = []
with open(version_csv_path, "r", encoding="utf-8") as _r_file:
reader = csv.reader(_r_file)
rows = list(reader)
def print_version() -> int:
"""Prints latest version. Print nothing on error or missing value/file."""
try:
version_csv_path = os.path.join(SCRIPT_DIR, "version.csv")

# Print latest version
print(rows[-1][1], end="")
# Gather version.CSV into list
rows = []
with open(version_csv_path, "r", encoding="utf-8") as _r_file:
reader = csv.reader(_r_file)
rows = list(reader)

except Exception as exc:
# Failed, so we print empty version
pass
# Print latest version
print(rows[-1][1])
return 0

except Exception: # pylint: disable=broad-exception-caught
# Failed, so we print empty version
return 1


if __name__ == "__main__":
sys.exit(print_version())

0 comments on commit 91a4183

Please sign in to comment.