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 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Feb 14, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

if not parentNode in openNodes:
if parentNode not in openNodes:
Copy link
Author

Choose a reason for hiding this comment

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

Function populate refactored with the following changes:

Comment on lines -121 to -124
piece = remote_file.read(1024)
if not piece:
if piece := remote_file.read(1024):
dl.write(piece)
else:
break
dl.write(piece)
Copy link
Author

Choose a reason for hiding this comment

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

Function download_thread refactored with the following changes:

Copy link
Owner

Choose a reason for hiding this comment

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

Walrus (:=) requires Python 3.8+

Comment on lines -130 to +144
return sg.popup_get_file('Where to save this file?', 'Download {}'.format(
url), default_path=url.split('/')[-1], save_as=True)
return sg.popup_get_file(
'Where to save this file?',
f'Download {url}',
default_path=url.split('/')[-1],
save_as=True,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function dlPopup refactored with the following changes:

Comment on lines -155 to +172
sg.popup("We're sorry!", req.url() + ' could not be fetched. Try again later.')
sg.popup("We're sorry!", f'{req.url()} could not be fetched. Try again later.')
else:
dlpath = dlPopup(req.url())
if not dlpath is None:
window.FindElement('-DOWNLOADS-').update(value='Downloading {}'.format(dlpath))
if dlpath is not None:
window.FindElement('-DOWNLOADS-').update(value=f'Downloading {dlpath}')
Copy link
Author

Choose a reason for hiding this comment

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

Function go refactored with the following changes:

Comment on lines -165 to +178
if x > 1 or x < 1:
return 's'
return ''
return 's' if x > 1 or x < 1 else ''
Copy link
Author

Choose a reason for hiding this comment

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

Function plural refactored with the following changes:

while not choice in choices:
while choice not in choices:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 21-84 refactored with the following changes:

Comment on lines -155 to +159
query = ''
if not (self.query == ''):
query = '%09' + self.query
query = f'%09{self.query}' if self.query != '' else ''
hst = self.host
if not self.port == 70:
hst += ':{}'.format(self.port)
return '{}://{}/{}{}{}'.format(protocol, hst, self.type, path, query)
if self.port != 70:
hst += f':{self.port}'
return f'{protocol}://{hst}/{self.type}{path}{query}'
Copy link
Author

Choose a reason for hiding this comment

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

Function Request.url refactored with the following changes:

Comment on lines -233 to +231
matches = re.match(r'^(.)(.*)\t(.*)\t(.*)\t(.*)', line)
if matches:
if matches := re.match(r'^(.)(.*)\t(.*)\t(.*)\t(.*)', line):
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_menu refactored with the following changes:

Comment on lines -257 to +259
up = urlparse('gopher://' + url)
up = urlparse(f'gopher://{url}')

req.path = up.path
if up.query:
req.path += '?{}'.format(up.query) # NOT to be confused with actual gopher queries, which use %09
# this just combines them back into one string
req.path += f'?{up.query}'
# this just combines them back into one string
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_url refactored with the following changes:

This removes the following comments ( why? ):

# NOT to be confused with actual gopher queries, which use %09

Comment on lines -353 to +350
path = realpath(gophermap_dir + '/' + path)
path = realpath(f'{gophermap_dir}/{path}')
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_gophermap refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant