Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

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

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jul 19, 2023

Branch main 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 main branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from edson-github July 19, 2023 22:48
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -21 to +28
if node.left is not None:
self._add(data, node.left)
else:
if node.left is None:
node.left = Node(data)
else:
if node.right is not None:
self._add(data, node.right)
else:
node.right = Node(data)
self._add(data, node.left)
elif node.right is not None:
self._add(data, node.right)
else:
node.right = Node(data)
Copy link
Author

Choose a reason for hiding this comment

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

Function Tree._add refactored with the following changes:

Comment on lines -33 to +32
if self.root is not None:
return self._find(data, self.root)
else:
return None
return self._find(data, self.root) if self.root is not None else None
Copy link
Author

Choose a reason for hiding this comment

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

Function Tree.find refactored with the following changes:

Comment on lines -58 to +54
print(str(node.data) + ' ')
print(f'{str(node.data)} ')
Copy link
Author

Choose a reason for hiding this comment

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

Function Tree._printTree refactored with the following changes:

Comment on lines -28 to +36
output = ""
output = ""
string = string.lower()
string = string.strip()
if string == "":
if not (string := string.strip()):
return(self.blank_string)
else:
for c in string:
for k,v in self.key.items():
if v == c:
output += k

for c in string:
for k,v in self.key.items():
if v == c:
output += k

Copy link
Author

Choose a reason for hiding this comment

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

Function main.decrypt_string refactored with the following changes:

(x,y) = caterpillar.pos()
outside = x < left_wall or x > right_Wall or y > top_wall or y < bottom_wall
return outside
return x < left_wall or x > right_Wall or y > top_wall or y < bottom_wall
Copy link
Author

Choose a reason for hiding this comment

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

Function outside_window refactored with the following changes:

Comment on lines -66 to +80
c.itemconfigure(lives_text , text='Lives : ' + str(lives_remaning))
c.itemconfigure(lives_text, text=f'Lives : {lives_remaning}')
Copy link
Author

Choose a reason for hiding this comment

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

Function lose_a_life refactored with the following changes:

Comment on lines -83 to +97
c.itemconfigure(score_text , text='Score : ' + str(score))
c.itemconfigure(score_text, text=f'Score : {str(score)}')
Copy link
Author

Choose a reason for hiding this comment

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

Function increase_score refactored with the following changes:

Comment on lines -7 to +8

if(re.fullmatch(regex, email)):
return True
else:
return False

return bool((re.fullmatch(regex, email)))
Copy link
Author

Choose a reason for hiding this comment

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

Function isValidEmail refactored with the following changes:

Comment on lines -16 to +13
username = email[0:email.index('@')]
username = email[:email.index('@')]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 16-16 refactored with the following changes:

Comment on lines -3 to +15
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----',
'1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',
':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-',
'-': '-....-', '+': '.-.-.', '"': '.-..-.', '?': '..--..', '/': '-..-.'
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----',
'1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',
':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-',
'-': '-....-', '+': '.-.-.', '"': '.-..-.', '?': '..--..', '/': '-..-.'
}
string=""
for x in message:
string+=char_to_dots[x.upper()]+' '
return string[0:-1]
string = "".join(f'{char_to_dots[x.upper()]} ' for x in message)
return string[:-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 encode_morse refactored with the following changes:

Comment on lines -11 to +14
print(str(err))
print(err)
return out, return_code
except Exception as err:
print("Exception Occurred while executing module : %s", str(err))
print("Exception Occurred while executing module : %s", err)
Copy link
Author

Choose a reason for hiding this comment

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

Function execute_shell_command refactored with the following changes:

Comment on lines -6 to +10
cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
f"{cv2.data.haarcascades}haarcascade_frontalface_default.xml"
)
body_cascade = cv2.CascadeClassifier(
cv2.data.haarcascades + "haarcascade_fullbody.xml")
f"{cv2.data.haarcascades}haarcascade_fullbody.xml"
)
Copy link
Author

Choose a reason for hiding this comment

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

Lines 6-8 refactored with the following changes:

blur = cv2.GaussianBlur(gray, (5, 5), 0)
canny = cv2.Canny(blur, 50, 150)
return canny
return cv2.Canny(blur, 50, 150)
Copy link
Author

Choose a reason for hiding this comment

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

Function canny refactored with the following changes:

Comment on lines -65 to +64
masked_image = cv2.bitwise_and(image, mask)
return masked_image
return cv2.bitwise_and(image, mask)
Copy link
Author

Choose a reason for hiding this comment

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

Function roi refactored with the following changes:

if 'user' in session:
return redirect("/")
return render_template("login.html")
return redirect("/") if 'user' in session else render_template("login.html")
Copy link
Author

Choose a reason for hiding this comment

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

Function login refactored with the following changes:

imagesJPG = []

for index, link in enumerate(imgSRC):
for link in imgSRC:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_pdf refactored with the following changes:

def lcm(a,b):
if a<0 or b<0: return
L = a if a > b else b
L = max(a, b)
Copy link
Author

Choose a reason for hiding this comment

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

Function lcm refactored with the following changes:

def hcf(a,b):
if a<0 or b<0: return
H = a if a<b else b
H = min(a, b)
Copy link
Author

Choose a reason for hiding this comment

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

Function hcf refactored with the following changes:

# Size and font of score label (Top-Left)
score_font = pygame.font.SysFont("arial", 15)
value = score_font.render(" Score: " + str(score), True, white)
value = score_font.render(f" Score: {str(score)}", True, white)
Copy link
Author

Choose a reason for hiding this comment

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

Function score refactored with the following changes:

snake_Head = []
snake_Head.append(x1)
snake_Head.append(y1)
snake_Head = [x1, y1]
Copy link
Author

Choose a reason for hiding this comment

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

Function gameLoop refactored with the following changes:

content = wikipedia.summary(title, sentences = sentences)

return content
return wikipedia.summary(title, sentences = sentences)
Copy link
Author

Choose a reason for hiding this comment

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

Function page refactored with the following changes:

Comment on lines -46 to +44
if specify_num_of_sentences == "y" or specify_num_of_sentences == "Y":
if specify_num_of_sentences in ["y", "Y"]:
Copy link
Author

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:

Comment on lines -76 to +80
o = int(x + columns * y)
o = int(x + columns * y)
N = int(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n)) # luminance index
if rows > y and y > 0 and x > 0 and columns > x and D > z[o]:
z[o] = D
b[o] = chars[N if N > 0 else 0]
b[o] = chars[max(N, 0)]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 76-97 refactored with the following changes:

parameters = (self.name.get(), self.price.get())
self.run_query(query, parameters)
self.message['text'] = 'Product {} added Successfully'.format(self.name.get())
self.message['text'] = f'Product {self.name.get()} added Successfully'
Copy link
Author

Choose a reason for hiding this comment

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

Function Product.add_product refactored with the following changes:

query = 'DELETE FROM product WHERE name = ?'
self.run_query(query, (name, ))
self.message['text'] = 'Record {} deleted Successfully'.format(name)
self.message['text'] = f'Record {name} deleted Successfully'
Copy link
Author

Choose a reason for hiding this comment

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

Function Product.delete_product refactored with the following changes:

Comment on lines -441 to +430
count = 0

for obj in ZONE_MAP:
if obj["SOLVED"]: count += 1

count = sum(1 for obj in ZONE_MAP if obj["SOLVED"])
Copy link
Author

Choose a reason for hiding this comment

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

Function ifSolved refactored with the following changes:

Comment on lines -509 to +494

Copy link
Author

Choose a reason for hiding this comment

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

Function setup_game refactored with the following changes:

Comment on lines 38 to 46
print("Let's Start")
print("Let's Start")
typing_speed()

while True :
if input("Do you want to try again? (y/n): ")=="y":
print("\n")
typing_speed()
else:
break No newline at end of file
while True:
if input("Do you want to try again? (y/n): ") != "y":
break
print("\n")
typing_speed() No newline at end of file
Copy link
Author

Choose a reason for hiding this comment

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

Lines 39-47 refactored with the following changes:

Comment on lines -5 to +6
#initialize
board = [' ' for x in range(10)]
#initialize
board = [' ' for _ in range(10)]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 5-6 refactored with the following changes:

Comment on lines -18 to +22
print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
print(f' {board[1]} | {board[2]} | {board[3]}')
print('-----------')
print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
print(f' {board[4]} | {board[5]} | {board[6]}')
print('-----------')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(f' {board[7]} | {board[8]} | {board[9]}')
Copy link
Author

Choose a reason for hiding this comment

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

Function printBoard 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