Skip to content

Commit 3d26d2e

Browse files
corrigindo pep8 e declarações de unicode
1 parent 1fcb8fc commit 3d26d2e

9 files changed

+14
-61
lines changed

atores.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def _calcular_posicao_horizontal(self, delta_t):
8282
self.x = self._x_inicial + self._velocidade_scalar * delta_t * math.cos(self._angulo_de_lancamento)
8383

8484
def _calcular_posicao_vertical(self, delta_t):
85-
self.y = self._y_inicial + \
86-
self._velocidade_scalar * delta_t * math.sin(self._angulo_de_lancamento) - \
87-
(GRAVIDADE / 2) * delta_t ** 2
85+
self.y = (self._y_inicial +
86+
self._velocidade_scalar * delta_t * math.sin(self._angulo_de_lancamento) -
87+
(GRAVIDADE / 2) * delta_t ** 2)
8888

8989
def _calcular_posicao(self, tempo):
9090
delta_t = tempo - self._tempo_de_lancamento
@@ -114,10 +114,3 @@ class PassaroAmarelo(Passaro):
114114
class PassaroVermelho(Passaro):
115115
_velocidade_scalar = 20 # m/s
116116
_caracter_ativo = 'D'
117-
118-
119-
120-
121-
122-
123-

fase.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from itertools import chain
23
from atores import ATIVO
34

@@ -76,5 +77,3 @@ def _verificar_se_existe_ator_ativo(self, atores, tempo):
7677

7778
def _existe_passaro_ativo(self, tempo):
7879
return self._verificar_se_existe_ator_ativo(self._passaros, tempo)
79-
80-

placa_grafica.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
1+
# -*- coding: utf-8 -*-
32
import os
43
import platform
54
import time
@@ -18,7 +17,8 @@
1817

1918
# workaround retirado de http://stackoverflow.com/questions/292095/polling-the-keyboard-in-python
2019

21-
def ouvir_teclado():
20+
21+
def ouvir_teclado_fn():
2222
i, o, e = select.select([sys.stdin], [], [], 0.0001)
2323
for s in i:
2424
if s == sys.stdin:
@@ -28,6 +28,8 @@ def ouvir_teclado():
2828

2929
if eh_windows:
3030
ouvir_teclado = msvcrt.kbhit
31+
else:
32+
ouvir_teclado = ouvir_teclado_fn
3133

3234
LARGURA = 80
3335
ALTURA = 20
@@ -153,4 +155,3 @@ def status(self):
153155

154156
if __name__ == '__main__':
155157
main()
156-

python_birds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# fase_exemplo.lancar(23, 4)
1919

2020
if __name__ == '__main__':
21-
placa_grafica.animar(fase_exemplo)
21+
placa_grafica.animar(fase_exemplo)

templates.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
|TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT|
2222
'''
2323

24-
FRAMES =['''|------------------------------------------------------------------------------|
24+
FRAMES = ['''|------------------------------------------------------------------------------|
2525
| |
2626
| |
2727
| |
@@ -63,8 +63,7 @@
6363
| |
6464
|A |
6565
|TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT|
66-
'''
67-
,
66+
''',
6867

6968
'''|------------------------------------------------------------------------------|
7069
| |
@@ -86,8 +85,7 @@
8685
| |
8786
| A |
8887
|TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT|
89-
'''
90-
,
88+
''',
9189

9290
'''|------------------------------------------------------------------------------|
9391
| |

testes/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, unicode_literals
3-

testes/atores_testes.py

-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def teste_colisao_somente_um_ator_destruido(self):
8686
self.assert_nao_colisao(Ator(1, 2), ator)
8787
self.assert_nao_colisao(Ator(1, 3), ator)
8888

89-
9089
def teste_status(self):
9190
ator = Ator()
9291
assert_ator_status(self, ator, 'A', '+')
@@ -143,7 +142,6 @@ def teste_colisao(self):
143142
passaro_vermelho.lancar(45, 2) # passaro lancado a 45 graus no tempo 2 segundos
144143
# Código de geração de testes
145144

146-
147145
porco = Porco(14, 10)
148146
passaro_vermelho.calcular_posicao(2.89) # tempo exato quanto o passário chega em 14,10
149147
passaro_vermelho.colidir(porco, 2.89)
@@ -666,12 +664,9 @@ def test_lancamento_45_graus(self):
666664
self.assert_passaro_posicao(91, 1, ATIVO, passaro_amarelo, 6.26)
667665
self.assert_passaro_posicao(92, 0, DESTRUIDO, passaro_amarelo, 6.27)
668666

669-
670-
671667
# Código de geração de testes
672668

673669
# for delta_t in range(0, 550):
674670
# t = 2 + (delta_t / 100)
675671
# x, y = passaro_amarelo.calcular_posicao(t)
676672
# print(' self.assert_passaro_posicao(%s, %s, ATIVO, passaro_amarelo, %s)' % (x, y, t))
677-

testes/fase_testes.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12

23
import os
34
from unittest.case import TestCase
@@ -107,10 +108,6 @@ def teste_status(self):
107108
self.assertEqual('Jogo em andamento.', fase.status(3),
108109
'Com Porco ativo e com pássaro para lançar, o jogo não deveria acabar')
109110

110-
def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
111-
fase = Fase()
112-
fase.lancar(90, 0)
113-
114111
def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
115112
passaro_vermelho, passaro_amarelo = PassaroVermelho(1, 1), PassaroAmarelo(1, 1)
116113
fase = Fase()
@@ -129,7 +126,6 @@ def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
129126
self.assertEqual(math.radians(45), passaro_amarelo._angulo_de_lancamento)
130127
self.assertEqual(3, passaro_amarelo._tempo_de_lancamento)
131128

132-
133129
def teste_calcular_pontos(self):
134130
expected = [Ponto(3, 3, 'D'), Ponto(3, 3, '>'), Ponto(3, 3, '>'), Ponto(31, 10, 'O'), Ponto(78, 1, '@'),
135131
Ponto(70, 1, '@')]
@@ -169,9 +165,3 @@ def teste_calcular_pontos(self):
169165

170166
if __name__ == '__main__':
171167
placa_grafica.animar(fase_exemplo)
172-
173-
174-
175-
176-
177-

testes/testes_placa_grafica.py

-22
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,3 @@ def __call__(self, x, y):
4141
self.assertEqual(frames[4], placa_grafica.desenhar(ponto_a, ponto_b))
4242
ponto_b(placa_grafica.LARGURA - 1, placa_grafica.ALTURA - 1)
4343
self.assertEqual(frames[4], placa_grafica.desenhar(ponto_a, ponto_b))
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-

0 commit comments

Comments
 (0)