-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKata13.py
More file actions
22 lines (20 loc) · 711 Bytes
/
Kata13.py
File metadata and controls
22 lines (20 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re
file = "example.java"
nlineas = 0
paternSpace = r'^\s*$' #Saltos de linea en blanco
paternOne = "^\/\/.*" #Comentario tipo //
paternTwo = "^\/\*.*" #Comentario tipo /*
paternTree = "\W\*\/.*" #Comentario tipo */
innerline = False #Semaforo para no contar las lineas entre /* ... */
for i, line in enumerate(open(file)):
space = re.search(paternSpace, line)
comentOne = re.search(paternOne, line.strip())
comentTwo = re.search(paternTwo, line.strip())
comentTree = re.search(paternTree, line)
if comentTwo:
innerline = True
if comentTree:
innerline = False
if not (space or comentTree or comentOne or innerline):
nlineas += 1
print nlineas