Skip to content

Sourcery refactored master branch#1

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

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

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Apr 11, 2022

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 breezechen April 11, 2022 06:26
Comment on lines -47 to +58
size = '%.2f T' % terabytes
return '%.2f T' % terabytes
elif bytes >= 1073741824:
gigabytes = bytes / 1073741824
size = '%.2f G' % gigabytes
return '%.2f G' % gigabytes
elif bytes >= 1048576:
megabytes = bytes / 1048576
size = '%.2f M' % megabytes
return '%.2f M' % megabytes
elif bytes >= 1024:
kilobytes = bytes / 1024
size = '%.2f K' % kilobytes
return '%.2f K' % kilobytes
else:
size = '%d B' % int(bytes)
return size
return '%d B' % int(bytes)
Copy link
Author

Choose a reason for hiding this comment

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

Function size_str refactored with the following changes:

Comment on lines -77 to -81
data = infile.read(CACHE_SIZE)
while data:
while data := infile.read(CACHE_SIZE):
sock.sendall(data)
data = infile.read(CACHE_SIZE)

Copy link
Author

Choose a reason for hiding this comment

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

Function http_server refactored with the following changes:

Comment on lines -146 to +138
uri = first_line.split()[1]
return uri
return first_line.split()[1]
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_request refactored with the following changes:

Comment on lines -155 to +153
resp_list = []
resp_list.append('HTTP/1.1 %s' % code)
resp_list.append('Content-Type: %s; char=utf-8' % mimetype)
resp_list.append('Content-Length: %s' % str(bytelen))
resp_list.append('\r\n')
resp = '\r\n'.join(resp_list)
return resp
resp_list = [
f'HTTP/1.1 {code}',
f'Content-Type: {mimetype}; char=utf-8',
f'Content-Length: {str(bytelen)}',
'\r\n',
]

return '\r\n'.join(resp_list)
Copy link
Author

Choose a reason for hiding this comment

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

Function build_header 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.

0 participants

Comments