-
-
Notifications
You must be signed in to change notification settings - Fork 128
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 #19
base: master
Are you sure you want to change the base?
Conversation
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.60%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
e9a2dee
to
20b1b17
Compare
urli = urli + "/" | ||
urli = f"{urli}/" | ||
for a in data.text.splitlines(): | ||
# below functionality will find all usernames from svn entries file | ||
if a == "has-props": | ||
author_list.append(old_line) | ||
if a == "file": | ||
if not pattern.search(old_line): | ||
continue | ||
ignore = getext(old_line) in excludes | ||
if ignore: | ||
print('{}{}(not extracted)'.format(urli, old_line)) | ||
else: | ||
print('{}{}'.format(urli, old_line)) | ||
if no_extract and not ignore: | ||
save_url_svn(urli, old_line, proxy_dict) | ||
file_list = file_list + ";" + old_line | ||
if a == "dir": | ||
if old_line != "": | ||
folder_path = os.path.join("output", urli.replace("http://", "").replace("https://", "").replace("/", os.path.sep), old_line) | ||
if not os.path.exists(folder_path): | ||
if no_extract: | ||
os.makedirs(folder_path) | ||
dir_list = dir_list + ";" + old_line | ||
print('{}{}'.format(urli, old_line)) | ||
if not os.path.exists(folder_path) and no_extract: | ||
os.makedirs(folder_path) | ||
dir_list = f"{dir_list};{old_line}" | ||
print(f'{urli}{old_line}') | ||
try: | ||
d = requests.get(urli + old_line + "/.svn/entries", verify=False, proxies=(proxy_dict)) | ||
readsvn(d, urli + old_line, match, proxy_dict) | ||
except Exception: | ||
print("Error Reading {}{}/.svn/entries so killing".format(urli, old_line)) | ||
print(f"Error Reading {urli}{old_line}/.svn/entries so killing") | ||
|
||
elif a == "file": | ||
if not pattern.search(old_line): | ||
continue | ||
ignore = getext(old_line) in excludes | ||
if ignore: | ||
print(f'{urli}{old_line}(not extracted)') | ||
else: | ||
print(f'{urli}{old_line}') | ||
if no_extract and not ignore: | ||
save_url_svn(urli, old_line, proxy_dict) | ||
file_list = f"{file_list};{old_line}" | ||
elif a == "has-props": | ||
author_list.append(old_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function readsvn
refactored with the following changes:
- Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation
) - Simplify conditional into switch-like form [×11] (
switch
) - Replace call to format with f-string [×4] (
use-fstring-for-formatting
) - Merge nested if conditions (
merge-nested-ifs
)
with open(folder + "wc.db", "wb") as f: | ||
with open(f"{folder}wc.db", "wb") as f: | ||
f.write(data.content) | ||
conn = sqlite3.connect(folder + "wc.db") | ||
conn = sqlite3.connect(f"{folder}wc.db") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function readwc
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
print("{} : {}".format(cnt, x)) | ||
print(f"{cnt} : {x}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function show_list
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
print("Error while accessing : {}{}".format(url, svn_path)) | ||
print(f"Error while accessing : {url}{svn_path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function save_url_wc
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
r = requests.get(url + "/.svn/text-base/" + filename + ".svn-base", verify=False, proxies=(proxy_dict)) | ||
r = requests.get( | ||
f"{url}/.svn/text-base/{filename}.svn-base", | ||
verify=False, | ||
proxies=(proxy_dict), | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function save_url_svn
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
print("Only downloading matches to {}".format(match)) | ||
match = "("+match+"|entries$|wc.db$)" # need to allow entries$ and wc.db too | ||
print(f"Only downloading matches to {match}") | ||
match = f"({match}|entries$|wc.db$)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Replace call to format with f-string [×5] (
use-fstring-for-formatting
) - Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation
) - Merge nested if conditions (
merge-nested-ifs
)
This removes the following comments ( why? ):
# need to allow entries$ and wc.db too
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:Help us improve this pull request!