pyinterfaces 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/PKG-INFO +1 -1
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/pyinterfaces/compilador.py +10 -13
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/pyproject.toml +1 -1
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/README.md +0 -0
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/license.txt +0 -0
- {pyinterfaces-0.2.0 → pyinterfaces-0.3.0}/pyinterfaces/__init__.py +0 -0
|
@@ -25,12 +25,10 @@ def converter_tipos_java_para_python(argumentos_str: str) -> str:
|
|
|
25
25
|
partes = [p.strip() for p in argumentos_limpos.split(',')]
|
|
26
26
|
novos_args = []
|
|
27
27
|
|
|
28
|
-
# CORREÇÃO AQUI: Verificamos se 'self' está contido na lista de partes
|
|
29
28
|
if len(partes) > 0 and partes[0] == 'self':
|
|
30
29
|
novos_args.append('self')
|
|
31
30
|
partes = partes[1:]
|
|
32
31
|
else:
|
|
33
|
-
# Injeta o 'self' automaticamente (padrão Java puro)
|
|
34
32
|
novos_args.append('self')
|
|
35
33
|
|
|
36
34
|
for parte in partes:
|
|
@@ -48,30 +46,29 @@ def converter_tipos_java_para_python(argumentos_str: str) -> str:
|
|
|
48
46
|
|
|
49
47
|
def traduzir_sintaxe_java(texto: str) -> str:
|
|
50
48
|
"""
|
|
51
|
-
Varre o arquivo de texto substituindo a sintaxe 'Interface Nome
|
|
52
|
-
por classes Python puras usando abc.ABC,
|
|
49
|
+
Varre o arquivo de texto substituindo a sintaxe 'Interface Nome:'
|
|
50
|
+
por classes Python puras usando abc.ABC, mantendo a indentação nativa.
|
|
53
51
|
"""
|
|
54
52
|
linhas = texto.split('\n')
|
|
55
53
|
resultado = ["from abc import ABC, abstractmethod\n"]
|
|
56
54
|
dentro_da_interface = False
|
|
57
55
|
|
|
58
56
|
for linha in linhas:
|
|
59
|
-
# 1. Detecta o início da declaração: 'Interface Nome
|
|
60
|
-
inicio_match = re.match(r'\s*Interface\s+(\w+)\s
|
|
57
|
+
# 1. Detecta o início da declaração: 'Interface Nome:' (com ou sem espaços)
|
|
58
|
+
inicio_match = re.match(r'\s*Interface\s+(\w+)\s*:', linha)
|
|
61
59
|
if inicio_match:
|
|
62
60
|
nome_interface = inicio_match.group(1)
|
|
63
61
|
resultado.append(f"class {nome_interface}(ABC):")
|
|
64
62
|
dentro_da_interface = True
|
|
65
63
|
continue
|
|
66
64
|
|
|
65
|
+
# Detecta se a linha voltou para a parede esquerda (fim do bloco da interface)
|
|
66
|
+
if dentro_da_interface and linha.strip() and not linha.startswith(' '):
|
|
67
|
+
dentro_da_interface = False
|
|
68
|
+
|
|
67
69
|
if dentro_da_interface:
|
|
68
|
-
# 2.
|
|
69
|
-
|
|
70
|
-
dentro_da_interface = False
|
|
71
|
-
continue
|
|
72
|
-
|
|
73
|
-
# 3. Captura o método com padrão Java: TipoRetorno nomeMetodo(Argumentos)
|
|
74
|
-
linha_limpa = linha.strip().replace(';', '')
|
|
70
|
+
# 2. Captura os métodos indentados de dentro da interface
|
|
71
|
+
linha_limpa = linha.strip()
|
|
75
72
|
if linha_limpa:
|
|
76
73
|
metodo_match = re.match(r'(?:\w+\s+)?(\w+)\s*\((.*?)\)', linha_limpa)
|
|
77
74
|
if metodo_match:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|