Skip to content

Sourcery refactored master branch#18

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#18
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

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

Copy link
Copy Markdown

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!

@sourcery-ai sourcery-ai Bot requested a review from dotcomboom February 14, 2023 23:50
Comment thread TreeGopher.py
window.FindElement('-LOADING-').update(visible=True)

if not parentNode in openNodes:
if parentNode not in openNodes:

Copy link
Copy Markdown
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 thread TreeGopher.py
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
Copy Markdown
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
Copy Markdown
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 thread TreeGopher.py
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
Copy Markdown
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 thread TreeGopher.py
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
Copy Markdown
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 thread TreeGopher.py
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
Copy Markdown
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:

Comment thread examples/tests_client.py

choice = ''
while not choice in choices:
while choice not in choices:

Copy link
Copy Markdown
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 thread pituophis/__init__.py
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
Copy Markdown
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 thread pituophis/__init__.py
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
Copy Markdown
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 thread pituophis/__init__.py
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
Copy Markdown
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 thread pituophis/__init__.py
Comment on lines -353 to +350
path = realpath(gophermap_dir + '/' + path)
path = realpath(f'{gophermap_dir}/{path}')

Copy link
Copy Markdown
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