Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
}


if os.name == 'nt':
Windows = True
else:
Windows = False

Windows = os.name == 'nt'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-120 refactored with the following changes:

try:
with open(f"{proj}_config.json", "r") as config_file:
config = json.load(config_file)
Expand All @@ -41,7 +37,7 @@
json.dump(config, config_file)
print(f'Created {proj}_config.json')
# Attempt to convert an old config into a new one
with open(f"Primer.config", "r") as old_config_file:
with open("Primer.config", "r") as old_config_file:
oldconfig=old_config_file.readlines()
config["statistics"]["Total Calculations"]=int(oldconfig[0])
config["statistics"]["Primes Found"]=int(oldconfig[1])
Expand Down Expand Up @@ -89,12 +85,10 @@
updateAttempt = 0 # Keep track of failed attempts
print('Checking for updates...', end='\r')
while updateAttempt < 3: # Try to retry the update up to 3 times if an error occurs
updateAttempt = updateAttempt+1
updateAttempt += 1
try:
with urllib.request.urlopen("https://smcclennon.github.io/update/api/3") as internalAPI:
repo = []
for line in internalAPI.readlines():
repo.append(line.decode().strip())
repo = [line.decode().strip() for line in internalAPI.readlines()]
apiLatest = repo[0] # Latest release details
proj = repo[1] # Project name
ddl = repo[2] # Direct download link
Expand All @@ -117,7 +111,7 @@
print(f'Latest Version: v{latest}\n')
for release in releases:
print(f'{release[0]}:\n{release[1]}\n')
confirm = input(str('Update now? [Y/n] ')).upper()
confirm = input('Update now? [Y/n] ').upper()
if confirm != 'N':
print(f'Downloading {proj} v{latest}...')
urllib.request.urlretrieve(ddl, os.path.basename(__file__)) # download the latest version to cwd
Expand Down