Skip to content

Commit

Permalink
Use Black to format to PEP8
Browse files Browse the repository at this point in the history
unittests pass
  • Loading branch information
natemacfadden committed Sep 25, 2024
1 parent ebbf211 commit bfd906b
Show file tree
Hide file tree
Showing 15 changed files with 4,065 additions and 2,497 deletions.
47 changes: 28 additions & 19 deletions src/cytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
version = "1.2.4"
versions_with_serious_bugs = []


# Check for more recent versions of CYTools
def check_for_updates():
"""
Expand Down Expand Up @@ -52,45 +53,53 @@ def check_for_updates():

try:
# get updated __init__ from github
p = requests.get("https://raw.githubusercontent.com/"
+ "LiamMcAllisterGroup/cytools/main/cytools/"
+ "__init__.py",
timeout=2)
p = requests.get(
"https://raw.githubusercontent.com/"
+ "LiamMcAllisterGroup/cytools/main/cytools/"
+ "__init__.py",
timeout=2,
)

# find/check the version in this file
for l in p.text.split("\n"):
if (not checked_version) and ("version =" in l):
checked_version = True

# parse version
latest_ver = tuple(int(c) for c in l.split("\"")[1].split("."))
latest_ver = tuple(int(c) for c in l.split('"')[1].split("."))
ver = tuple(int(c) for c in version.split("."))

# check
if latest_ver <= ver:
continue
continue

# local version is old -> print warning
print("\nInfo: A more recent version of CYTools is available: "
f"v{ver[0]}.{ver[1]}.{ver[2]} -> "
f"v{latest_ver[0]}.{latest_ver[1]}.{latest_ver[2]}.\n"
"We recommend upgrading before continuing.\n"
"On Linux and macOS you can update CYTools by running "
"'cytools --update'\n"
"and on Windows you can do this by running the updater "
"tool.\n")
print(
"\nInfo: A more recent version of CYTools is available: "
f"v{ver[0]}.{ver[1]}.{ver[2]} -> "
f"v{latest_ver[0]}.{latest_ver[1]}.{latest_ver[2]}.\n"
"We recommend upgrading before continuing.\n"
"On Linux and macOS you can update CYTools by running "
"'cytools --update'\n"
"and on Windows you can do this by running the updater "
"tool.\n"
)

elif (not checked_bugs) and ("versions_with_serious_bugs =" in l):
checked_bugs = True
bad_versions = literal_eval(l.split("=")[1].strip())
if version in bad_versions:
print("\n****************************\n"
"Warning: This version of CYTools contains a serious"
" bug. Please upgrade to the latest version.\n"
"****************************\n")
print(
"\n****************************\n"
"Warning: This version of CYTools contains a serious"
" bug. Please upgrade to the latest version.\n"
"****************************\n"
)

if checked_version and checked_bugs:
break
except:
pass
pass


check_for_updates()
Loading

0 comments on commit bfd906b

Please sign in to comment.