Skip to content

Commit 7dcb857

Browse files
committed
Format Python files using Black
1 parent 3c51b6b commit 7dcb857

35 files changed

+139
-142
lines changed

.github/workflows/lint-checker.yml

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ jobs:
2323
VALIDATE_JAVASCRIPT_ES: true
2424
VALIDATE_GOOGLE_JAVA_FORMAT: true
2525
VALIDATE_PYTHON_BLACK: true
26-
PYTHON_BLACK_CONFIG_FILE: "./pyproject.toml"
2726
VALIDATE_PYTHON_ISORT: true

pyproject.toml

-2
This file was deleted.

src/python/arvore_binaria_de_busca.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def __init__(self, chave):
1515
# Metodos de Busca
1616
def busca_recursiva(no, chave):
1717
if no is None:
18-
print(f'{chave} nao foi encontrado na arvore')
18+
print(f"{chave} nao foi encontrado na arvore")
1919
return
2020
if no.chave == chave:
21-
print(f'{chave} foi encontrado na arvore')
21+
print(f"{chave} foi encontrado na arvore")
2222
return no
2323
if chave > no.chave:
2424
busca_recursiva(no.direita, chave)
@@ -50,14 +50,14 @@ def insere(no, chave):
5050

5151

5252
# Metodos de Impressao
53-
IMPRIME_ARVORE = ''
53+
IMPRIME_ARVORE = ""
5454

5555

5656
def pre_ordem(no):
5757
global IMPRIME_ARVORE
5858
if no is None:
5959
return
60-
IMPRIME_ARVORE += str(no.chave) + ', '
60+
IMPRIME_ARVORE += str(no.chave) + ", "
6161
pre_ordem(no.esquerda)
6262
pre_ordem(no.direita)
6363

@@ -67,7 +67,7 @@ def em_ordem(no):
6767
if no is None:
6868
return
6969
em_ordem(no.esquerda)
70-
IMPRIME_ARVORE += str(no.chave) + ', '
70+
IMPRIME_ARVORE += str(no.chave) + ", "
7171
em_ordem(no.direita)
7272

7373

@@ -77,7 +77,7 @@ def pos_ordem(no):
7777
return
7878
pos_ordem(no.esquerda)
7979
pos_ordem(no.direita)
80-
IMPRIME_ARVORE += str(no.chave) + ', '
80+
IMPRIME_ARVORE += str(no.chave) + ", "
8181

8282

8383
# Acha a Altura da Arvore
@@ -142,7 +142,7 @@ def exclui(no, ch):
142142
return True
143143

144144

145-
if __name__ == '__main__':
145+
if __name__ == "__main__":
146146
arvore = Arvore(3) # Cria arvore (raiz)
147147
# Insere varios valores na arvore
148148
arvore = insere(arvore, 2)
@@ -157,11 +157,11 @@ def exclui(no, ch):
157157
busca_recursiva(arvore, 6) # Busca que imprime na propria funcao
158158

159159
if busca_linear(arvore, 6) is not None: # Retorna o NO ou None se nao encontrou
160-
print('Valor encontrado')
160+
print("Valor encontrado")
161161
else:
162-
print('Valor nao encontrado')
162+
print("Valor nao encontrado")
163163

164-
print(f'Altura: {altura(arvore)}')
164+
print(f"Altura: {altura(arvore)}")
165165

166166
# Exclui varios valores
167167
exclui(arvore, 7)
@@ -172,13 +172,13 @@ def exclui(no, ch):
172172
# Chama os metodos de impressao
173173
IMPRIME = ""
174174
pre_ordem(arvore)
175-
print(f'PreOrdem: {IMPRIME}')
175+
print(f"PreOrdem: {IMPRIME}")
176176
IMPRIME = ""
177177
em_ordem(arvore)
178-
print(f'EmOrdem: {IMPRIME}')
178+
print(f"EmOrdem: {IMPRIME}")
179179
IMPRIME = ""
180180
pos_ordem(arvore)
181-
print(f'PosOrdem: {IMPRIME}')
181+
print(f"PosOrdem: {IMPRIME}")
182182

183183
# Mostra a altura da arvore apos remover os itens
184-
print(f'Altura: {altura(arvore)}')
184+
print(f"Altura: {altura(arvore)}")

src/python/binary_tree.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __print_level(self, node, level):
129129
if node is None:
130130
return
131131
if level == 1:
132-
print("%d" % node.data, end=' ')
132+
print("%d" % node.data, end=" ")
133133
elif level > 1:
134134
self.__print_level(node.left, level - 1)
135135
self.__print_level(node.right, level - 1)
@@ -138,13 +138,13 @@ def in_order(self, node):
138138
if node is None:
139139
return
140140
self.in_order(node.left)
141-
print("%d" % node.data, end=' ')
141+
print("%d" % node.data, end=" ")
142142
self.in_order(node.right)
143143

144144
def pre_order(self, node):
145145
if node is None:
146146
return
147-
print("%d" % node.data, end=' ')
147+
print("%d" % node.data, end=" ")
148148
self.pre_order(node.left)
149149
self.pre_order(node.right)
150150

@@ -153,7 +153,7 @@ def post_order(self, node):
153153
return
154154
self.post_order(node.left)
155155
self.post_order(node.right)
156-
print("%d" % node.data, end=' ')
156+
print("%d" % node.data, end=" ")
157157

158158

159159
b_tree = BinaryTree()
@@ -164,11 +164,11 @@ def post_order(self, node):
164164
b_tree.insert(curr_data)
165165

166166
b_tree.in_order(b_tree.root)
167-
print('\n')
167+
print("\n")
168168
b_tree.pre_order(b_tree.root)
169-
print('\n')
169+
print("\n")
170170
b_tree.post_order(b_tree.root)
171-
print('\n')
171+
print("\n")
172172
b_tree.level_order()
173-
print('\n')
173+
print("\n")
174174
print(b_tree.get_height(b_tree.root))

src/python/bubble_sort.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def bubble_sort(data, size):
2020
bubble_sort(data, size - 1)
2121

2222

23-
if __name__ == '__main__':
23+
if __name__ == "__main__":
2424
lista_nao_ordenada = [2, 9, 8, 0, 1, 3, 5, 4, 6, 7]
2525
print(lista_nao_ordenada)
2626
bubble_sort(lista_nao_ordenada, len(lista_nao_ordenada))

src/python/busca_em_labirinto.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111

1212
class Cell(Enum):
13-
EMPTY = ' '
14-
BLOCKED = 'X'
15-
START = 'S'
16-
GOAL = 'G'
17-
PATH = '*'
13+
EMPTY = " "
14+
BLOCKED = "X"
15+
START = "S"
16+
GOAL = "G"
17+
PATH = "*"
1818

1919

20-
MazeLocation = namedtuple('MazeLocation', ['row', 'col'])
20+
MazeLocation = namedtuple("MazeLocation", ["row", "col"])
2121

2222

2323
class Maze:
@@ -46,7 +46,7 @@ def _randomly_fill(self, rows, cols, sparseness):
4646
self._grid[row][col] = Cell.BLOCKED
4747

4848
def __str__(self):
49-
return '\n'.join(['|'.join([c.value for c in r]) for r in self._grid])
49+
return "\n".join(["|".join([c.value for c in r]) for r in self._grid])
5050

5151
def goal_test(self, maze_location):
5252
return maze_location == self.goal
@@ -187,27 +187,27 @@ def node_to_path(node):
187187
return path
188188

189189

190-
if __name__ == '__main__':
190+
if __name__ == "__main__":
191191
maze = Maze()
192192

193193
# Solucao utilizando busca em profundidade
194194
solution = dfs(maze.start, maze.goal_test, maze.successors)
195195
if solution is None:
196-
print('No solution found using depth-first search')
196+
print("No solution found using depth-first search")
197197
else:
198198
path = node_to_path(solution)
199199
maze.mark(path)
200-
print('Solution using DFS:')
200+
print("Solution using DFS:")
201201
print(maze)
202202
maze.clear(path)
203203

204204
# Solucao utilizando busca em largura
205205
solution = bfs(maze.start, maze.goal_test, maze.successors)
206206
if solution is None:
207-
print('No solution found using breath-first search')
207+
print("No solution found using breath-first search")
208208
else:
209209
path = node_to_path(solution)
210210
maze.mark(path)
211-
print('Solution using BFS:')
211+
print("Solution using BFS:")
212212
print(maze)
213213
maze.clear(path)

src/python/busca_sequencial_recursiva.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def busca_sequencial(valor, lista, index):
1515
return busca_sequencial(valor, lista, index + 1)
1616

1717

18-
if __name__ == '__main__':
18+
if __name__ == "__main__":
1919
uma_lista = [1, 9, 39, 4, 12, 38, 94, 37]
2020
for indice, valor_na_lista in enumerate(uma_lista):
21-
print('Testando valor {} no indice {}'.format(valor_na_lista, indice))
21+
print("Testando valor {} no indice {}".format(valor_na_lista, indice))
2222
assert busca_sequencial(valor_na_lista, uma_lista, 0) == indice

src/python/calculate_pi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def calculate_pi(number):
2020
return pi
2121

2222

23-
if __name__ == '__main__':
23+
if __name__ == "__main__":
2424
n_terms = [10, 1000, 100000, 10000000]
2525
for n in n_terms:
26-
print(f'PI ({n}): {calculate_pi(n)}')
26+
print(f"PI ({n}): {calculate_pi(n)}")

src/python/comb_sort.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def comb_sort(arr: list) -> list:
2424
return arr
2525

2626

27-
if __name__ == '__main__':
27+
if __name__ == "__main__":
2828
from random import randint
2929

3030
my_list = [randint(0, 100) for _ in range(10)]
31-
print(f'Lista: {my_list}')
32-
print(f'Ordenada: {comb_sort(my_list)}')
31+
print(f"Lista: {my_list}")
32+
print(f"Ordenada: {comb_sort(my_list)}")

src/python/compressao_huffman.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ def __init__(self, freq, symbol, left=None, right=None):
1414
self.right = right
1515

1616
# direção da árvore (0/1)
17-
self.huff = ''
17+
self.huff = ""
1818

1919

2020
# Função utilitária para imprimir
2121
# códigos huffman para todos os símbolos
2222
# na nova árvore huffman que sera criada
2323

2424

25-
def printNodes(node, val=''):
25+
def printNodes(node, val=""):
2626
# código huffman para o nó atual
2727
newVal = val + str(node.huff)
2828

@@ -41,15 +41,15 @@ def printNodes(node, val=''):
4141

4242

4343
# caracteres para à árvore huffman
44-
chars = ['a', 'b', 'c', 'd', 'e', 'f']
44+
chars = ["a", "b", "c", "d", "e", "f"]
4545

4646
# frequência dos caracteres
4747
freq = [5, 9, 12, 13, 16, 45]
4848

4949
# lista contendo os nós não utilizados
5050
nodes = []
5151

52-
if __name__ == '__main__':
52+
if __name__ == "__main__":
5353
# convertendo caracteres e frequência em
5454
# nós da árvore huffman
5555
for x in range(len(chars)):

src/python/compressao_lz77.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ class BitArray:
77
Classe para manipular bits como um array
88
"""
99

10-
ENDIAN_TYPE = 'big'
10+
ENDIAN_TYPE = "big"
1111
bits = []
1212
output = bytearray()
1313

14-
def __init__(self, input_data=None, endian='big'):
14+
def __init__(self, input_data=None, endian="big"):
1515
self.ENDIAN_TYPE = endian
1616
# Se fornecido um bytearray converte
1717
# o mesmo para lista de bits
@@ -32,7 +32,7 @@ def fromint(self, value):
3232
Converte um inteiro para bits
3333
e adiciona-os à lista
3434
"""
35-
bitstring = '{:08b}'.format(value)
35+
bitstring = "{:08b}".format(value)
3636
for bit in bitstring:
3737
self.append(int(bit, 2))
3838

@@ -53,7 +53,7 @@ def dump(self):
5353
self.output = bytearray()
5454
bits_in_a_byte = 8
5555
for i in range(len(self.bits) // (bits_in_a_byte)):
56-
bitstring = ''
56+
bitstring = ""
5757
readed_bits = self.bits[i * bits_in_a_byte : i * bits_in_a_byte + 8]
5858
for bit in readed_bits:
5959
bitstring += str(bit)
@@ -76,15 +76,15 @@ class LZ77:
7676
CURSOR = 0
7777

7878
# Tipo de leitura binária (ENDIAN)
79-
ENDIAN_TYPE = 'big'
79+
ENDIAN_TYPE = "big"
8080

8181
# Dados de Entrada
8282
data = None
8383

84-
def __init__(self, window_size=400, lookahed_buffer=15, endian='big', verbose=True):
84+
def __init__(self, window_size=400, lookahed_buffer=15, endian="big", verbose=True):
8585
self.MAX_WINDOW_SIZE = window_size
8686
self.MAX_LOOKAHEAD_BUFFER = lookahed_buffer
87-
self.ENDIAN_TYPE = 'big'
87+
self.ENDIAN_TYPE = "big"
8888
self.ENABLE_DEBUG = verbose
8989

9090
def find_longest_match(self):
@@ -325,20 +325,20 @@ def compress(self, input_data):
325325
"Lorem ipsum dolor sit amet..", comes from a line in\
326326
section 1.10.32."'''
327327

328-
if __name__ == '__main__':
328+
if __name__ == "__main__":
329329
lz = LZ77(verbose=False)
330330
print("Entrada:")
331331
entrada = bytearray(input_text.encode())
332332
print(entrada)
333-
print('Tamanho: {}'.format(sys.getsizeof(entrada)))
333+
print("Tamanho: {}".format(sys.getsizeof(entrada)))
334334
print("\n---\n")
335335
compressed = lz.compress(input_text)
336336
print("Dados Comprimidos com LZ77:")
337337
print(compressed)
338-
print('Tamanho: {}'.format(sys.getsizeof(compressed)))
338+
print("Tamanho: {}".format(sys.getsizeof(compressed)))
339339
print("\n---\n")
340340
decompressed = lz.decompress(compressed)
341341
print("Dados descomprimidos com LZ77:")
342342
print(decompressed)
343-
print('Tamanho: {}'.format(sys.getsizeof(decompressed)))
343+
print("Tamanho: {}".format(sys.getsizeof(decompressed)))
344344
print("\n---\n")

src/python/counting_sort.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def counting_sort(arr):
3636
lista = [random.randint(0, 100) for _ in range(n)]
3737

3838
# Imprime a lista original sem ordenação
39-
print(f'Lista Original: {lista}')
39+
print(f"Lista Original: {lista}")
4040

4141
# Ordena a lista utilizando o algoritmo de Counting Sort
4242
lista_ordenada = counting_sort(lista)
4343

4444
# Imprime a lista ordenada
45-
print(f'Lista Ordenada: {lista_ordenada}')
45+
print(f"Lista Ordenada: {lista_ordenada}")

src/python/exponenciacao_recursiva.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def exponenciacao_recursiva(base, expoente):
1717
return base * exponenciacao_recursiva(base, expoente - 1)
1818

1919

20-
if __name__ == '__main__':
20+
if __name__ == "__main__":
2121
print(exponenciacao_recursiva(5, 2))
2222
print(exponenciacao_recursiva(5, 5))

src/python/fatorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def fatorial(num):
1616
return aux
1717

1818

19-
if __name__ == '__main__':
19+
if __name__ == "__main__":
2020
print(fatorial(5))

0 commit comments

Comments
 (0)