portugython 0.0.14__tar.gz → 0.2.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.
Files changed (64) hide show
  1. portugython-0.2.0/.gitignore +36 -0
  2. portugython-0.2.0/CHANGELOG.md +70 -0
  3. {portugython-0.0.14 → portugython-0.2.0}/LICENSE +1 -1
  4. portugython-0.2.0/PKG-INFO +292 -0
  5. portugython-0.2.0/README.md +265 -0
  6. portugython-0.2.0/portugython/__init__.py +594 -0
  7. portugython-0.2.0/portugython/abstrato.py +14 -0
  8. portugython-0.2.0/portugython/aleatorio.py +240 -0
  9. portugython-0.2.0/portugython/argumentos.py +44 -0
  10. portugython-0.2.0/portugython/assincronico.py +87 -0
  11. portugython-0.2.0/portugython/bisecao.py +106 -0
  12. portugython-0.2.0/portugython/calendario.py +70 -0
  13. portugython-0.2.0/portugython/caminho.py +132 -0
  14. portugython-0.2.0/portugython/classe_dados.py +40 -0
  15. portugython-0.2.0/portugython/codificacao.py +95 -0
  16. portugython-0.2.0/portugython/colecoes.py +303 -0
  17. portugython-0.2.0/portugython/compressao.py +58 -0
  18. portugython-0.2.0/portugython/configuracao.py +70 -0
  19. portugython-0.2.0/portugython/contexto.py +21 -0
  20. portugython-0.2.0/portugython/copia.py +28 -0
  21. portugython-0.2.0/portugython/csv_pt.py +46 -0
  22. portugython-0.2.0/portugython/depuracao.py +122 -0
  23. portugython-0.2.0/portugython/enumeracao.py +17 -0
  24. portugython-0.2.0/portugython/estatistica.py +81 -0
  25. portugython-0.2.0/portugython/estrutura.py +73 -0
  26. portugython-0.2.0/portugython/expressao.py +251 -0
  27. portugython-0.2.0/portugython/formatacao.py +118 -0
  28. portugython-0.2.0/portugython/funcional.py +158 -0
  29. portugython-0.2.0/portugython/hash_pt.py +96 -0
  30. portugython-0.2.0/portugython/identificador.py +45 -0
  31. portugython-0.2.0/portugython/iteradores.py +269 -0
  32. portugython-0.2.0/portugython/json.py +71 -0
  33. portugython-0.2.0/portugython/matematica.py +510 -0
  34. portugython-0.2.0/portugython/rede.py +129 -0
  35. portugython-0.2.0/portugython/registro.py +64 -0
  36. portugython-0.2.0/portugython/serializacao.py +55 -0
  37. portugython-0.2.0/portugython/sistema.py +406 -0
  38. portugython-0.2.0/portugython/soquete.py +75 -0
  39. portugython-0.2.0/portugython/subprocesso.py +91 -0
  40. portugython-0.2.0/portugython/tempo.py +404 -0
  41. portugython-0.2.0/portugython/threads.py +110 -0
  42. portugython-0.2.0/portugython/tipagem.py +83 -0
  43. portugython-0.2.0/pyproject.toml +43 -0
  44. portugython-0.2.0/tests/test_portugython.py +200 -0
  45. portugython-0.2.0/tests/test_submodulos.py +433 -0
  46. portugython-0.0.14/PKG-INFO +0 -56
  47. portugython-0.0.14/README.md +0 -41
  48. portugython-0.0.14/pyproject.toml +0 -24
  49. portugython-0.0.14/setup.cfg +0 -4
  50. portugython-0.0.14/setup.py +0 -5
  51. portugython-0.0.14/src/aleatorio/__init__.py +0 -1
  52. portugython-0.0.14/src/aleatorio/aleatorio.py +0 -3
  53. portugython-0.0.14/src/matematica/__init__.py +0 -1
  54. portugython-0.0.14/src/matematica/matematica.py +0 -1
  55. portugython-0.0.14/src/mechanics_test.py +0 -0
  56. portugython-0.0.14/src/pegasenha/pegasenha.py +0 -5
  57. portugython-0.0.14/src/portugython/__init__.py +0 -1
  58. portugython-0.0.14/src/portugython/embutidos.py +0 -128
  59. portugython-0.0.14/src/portugython.egg-info/PKG-INFO +0 -56
  60. portugython-0.0.14/src/portugython.egg-info/SOURCES.txt +0 -18
  61. portugython-0.0.14/src/portugython.egg-info/dependency_links.txt +0 -1
  62. portugython-0.0.14/src/portugython.egg-info/top_level.txt +0 -6
  63. /portugython-0.0.14/src/__init__.py → /portugython-0.2.0/portugython/py.typed +0 -0
  64. {portugython-0.0.14/src/pegasenha → portugython-0.2.0/tests}/__init__.py +0 -0
@@ -0,0 +1,36 @@
1
+ # Secrets
2
+ api-token
3
+ .pypirc
4
+ *.pem
5
+ *.key
6
+ .env*
7
+
8
+ # Python
9
+ __pycache__/
10
+ *.py[cod]
11
+ *$py.class
12
+ *.egg-info/
13
+ dist/
14
+ build/
15
+ *.egg
16
+ .eggs/
17
+
18
+ # Virtual environments
19
+ .venv/
20
+ venv/
21
+ env/
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+ .tox/
28
+
29
+ # IDE
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+ .DS_Store
34
+
35
+ # Ruff
36
+ .ruff_cache/
@@ -0,0 +1,70 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-06-26)
4
+
5
+ Full stdlib coverage. 36 submodules total, all importable via `from portugython import <modulo>`:
6
+
7
+ **New in 0.2.0:**
8
+ - `caminho` (pathlib): Caminho com existe, eh_arquivo, listar, ler_texto, escrever_texto, etc.
9
+ - `json`: serializar, deserializar, serializar_arquivo, deserializar_arquivo
10
+ - `estatistica` (statistics): media, mediana, moda, desvio_padrao, covariancia, correlacao, quantis
11
+ - `enumeracao` (enum): Enumeracao, EnumeracaoInteira, EnumeracaoBandeira, automatico, unico
12
+ - `classe_dados` (dataclasses): classe_dados, campo, para_dicionario, para_tupla, substituir
13
+ - `contexto` (contextlib): gerenciador, suprimir, fechar_ao_sair, pilha_saida
14
+ - `tipagem` (typing): re-exporta todos os tipos com nomes em Portugues
15
+ - `csv_pt` (csv): ler_csv, escrever_csv, LeitorCSV, EscritorCSV, LeitorDicionario
16
+ - `registro` (logging): obter_registrador, configurar_registro, depurar, informar, avisar, erro
17
+ - `argumentos` (argparse): AnalisadorArgumentos com adicionar_argumento, analisar
18
+ - `subprocesso` (subprocess): executar, executar_shell, saida, chamar
19
+ - `copia` (copy): copiar, copiar_profundo
20
+ - `hash_pt` (hashlib + hmac): md5, sha256, sha512, blake2b, codigo_autenticacao, comparar_seguro
21
+ - `threads` (threading): Thread, Semaforo, Evento, Trava, contagem_threads, thread_atual
22
+ - `abstrato` (abc): ClasseAbstrata, metodo_abstrato, propriedade_abstrata
23
+ - `bisecao` (bisect + heapq): inserir_ordenado, buscar_ordenado, heapificar, empurrar, n_maiores
24
+ - `identificador` (uuid): uuid1, uuid3, uuid4, uuid5
25
+ - `calendario` (calendar): dias_no_mes, eh_ano_bissexto, dia_semana, calendario_mes
26
+ - `configuracao` (configparser): AnalisadorConfig com ler_arquivo, obter, definir, escrever_arquivo
27
+ - `serializacao` (pickle): serializar, deserializar, serializar_arquivo, deserializar_arquivo
28
+ - `codificacao` (base64 + codecs): para_base64, de_base64, para_base32, para_base16
29
+ - `compressao` (gzip + zlib): comprimir_gzip, descomprimir_gzip, comprimir_zlib
30
+ - `formatacao` (textwrap + pprint + string): quebrar, preencher, dedenter, recuar, imprimir_bonito
31
+ - `depuracao` (traceback + warnings + gc): imprimir_excecao, formatar_excecao, coletar_lixo
32
+ - `soquete` (socket): Soquete, criar_conexao, criar_servidor, nome_host, endereco_ip
33
+ - `assincronico` (asyncio): executar, criar_tarefa, dormir, reunir, Evento, Fila
34
+ - `estrutura` (struct): empacotar, desempacotar, calcular_tamanho
35
+ - `rede` (urllib + http): baixar_url, abrir_url, analisar_url, codificar_url, codificar_parametros
36
+
37
+ Also in 0.2.0:
38
+ - Fix: renamed builtin `identificador` alias to `obter_id` to avoid shadowing the uuid submodule
39
+ - 49 tests covering all modules
40
+
41
+
42
+ ## 0.1.0 (2026-06-26)
43
+
44
+ - Add full stdlib submodule set with Portuguese translations:
45
+ - `aleatorio` (random): escolha, embaralhe, amostra, gauss, normal, etc.
46
+ - `matematica` (math): raiz_quadrada, seno, cosseno, fatorial, mdc, mmc, etc.
47
+ - `sistema` (os + sys): diretorio_atual, listar_diretorio, existe, sair, etc.
48
+ - `tempo` (time + datetime): Data, Hora, DataHora, Duracao, agora, hoje, dormir, etc.
49
+ - `colecoes` (collections): Contador, Deque, DicionarioOrdenado, Pilha, Fila, etc.
50
+ - `iteradores` (itertools): encadeie, combine, permute, acumule, agrupe, etc.
51
+ - `funcional` (functools): reduzido, parcial, cache, compor, negado, etc.
52
+ - `expressao` (re): compilar, buscar, substituir, encontrar_todos, Padrao, etc.
53
+ - Rewrite `__init__.py` with clean Portuguese names (remove `_pt` suffixes)
54
+ - Add `Conjunto` class with Portuguese methods
55
+ - Expand `Texto`, `Lista`, `Dicionario` with more methods
56
+ - Add more exception types: ErroArquivo, ErroPermissao, ErroRecursao, ErroPausa
57
+ - Bump minimum Python to >=3.10
58
+ - 30 tests across all modules
59
+
60
+ ## 0.0.15 (2026-06-26)
61
+
62
+ - Add Portuguese translations of Python builtins and core functions
63
+ - Introduce Lista, Dicionario, Texto classes with Portuguese methods
64
+ - Add helper functions: se(), para_cada(), filtro()
65
+ - Add Portuguese exception classes
66
+ - Expand test suite
67
+
68
+ ## 0.0.14 (2022-11-28)
69
+
70
+ - Latest release on PyPI.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 In Gnave
3
+ Copyright (c) 2022 Victor Kolis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,292 @@
1
+ Metadata-Version: 2.4
2
+ Name: portugython
3
+ Version: 0.2.0
4
+ Summary: A Portuguese translation of the Python functions/modules/packages
5
+ Project-URL: Homepage, https://github.com/spacemany2k38/portugython
6
+ Project-URL: Bug Tracker, https://github.com/spacemany2k38/portugython/issues
7
+ Author: Victor Kolis
8
+ Maintainer: Victor Kolis
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Natural Language :: Portuguese (Brazilian)
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Requires-Python: >=3.10
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest; extra == 'dev'
25
+ Requires-Dist: ruff; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Portugython
29
+
30
+ [![PyPI version](https://img.shields.io/pypi/v/portugython.svg)](https://pypi.org/project/portugython/)
31
+ [![Python versions](https://img.shields.io/pypi/pyversions/portugython.svg)](https://pypi.org/project/portugython/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
+
34
+ Escreva Python em Portugues. Portugython traduz funcoes, tipos e modulos da biblioteca padrao do Python para nomes em portugues.
35
+
36
+ ## Instalacao
37
+
38
+ ```bash
39
+ pip install portugython
40
+ ```
41
+
42
+ ## Uso basico
43
+
44
+ ```python
45
+ from portugython import *
46
+
47
+ escreva("Ola, Mundo!")
48
+ nome = leia("Qual e seu nome? ")
49
+ escreva("Ola,", nome)
50
+
51
+ numeros = Lista([1, 2, 3, 4, 5])
52
+ numeros.adicione(6)
53
+ numeros.classifique(reverso=Verdadeiro)
54
+ escreva(numeros)
55
+
56
+ pares = filtro(lambda x: x % 2 == 0, numeros)
57
+ escreva("Pares:", pares)
58
+
59
+ resultado = se(tamanho(pares) > 0, "tem pares", "sem pares")
60
+ escreva(resultado)
61
+ ```
62
+
63
+ ## Modulos da biblioteca padrao
64
+
65
+ Cada modulo da stdlib tem uma versao em portugues que pode ser importada separadamente.
66
+
67
+ ### aleatorio (random)
68
+
69
+ ```python
70
+ from portugython import aleatorio
71
+
72
+ aleatorio.semente(42)
73
+ n = aleatorio.inteiro_aleatorio(1, 100)
74
+ item = aleatorio.escolha(["pedra", "papel", "tesoura"])
75
+ lista = [1, 2, 3, 4, 5]
76
+ aleatorio.embaralhe(lista)
77
+ amostra = aleatorio.amostra(range(50), k=5)
78
+ ```
79
+
80
+ ### matematica (math)
81
+
82
+ ```python
83
+ from portugython import matematica
84
+
85
+ print(matematica.PI)
86
+ print(matematica.raiz_quadrada(16))
87
+ print(matematica.fatorial(10))
88
+ print(matematica.seno(matematica.PI / 2))
89
+ print(matematica.mdc(48, 18))
90
+ print(matematica.combinacoes(10, 3))
91
+ ```
92
+
93
+ ### sistema (os + sys)
94
+
95
+ ```python
96
+ from portugython import sistema
97
+
98
+ pasta = sistema.diretorio_atual()
99
+ arquivos = sistema.listar_diretorio(".")
100
+ sistema.criar_diretorios("nova/pasta", existe_ok=Verdadeiro)
101
+ sistema.renomear("antigo.txt", "novo.txt")
102
+
103
+ print(sistema.versao)
104
+ print(sistema.plataforma)
105
+ db = sistema.variavel_ambiente("DATABASE_URL", "sqlite:///app.db")
106
+ ```
107
+
108
+ ### tempo (time + datetime)
109
+
110
+ ```python
111
+ from portugython import tempo
112
+
113
+ agora = tempo.agora()
114
+ print(agora.formatar("%d/%m/%Y %H:%M"))
115
+
116
+ hoje = tempo.hoje()
117
+ print(hoje.ano, hoje.mes, hoje.dia)
118
+
119
+ dur = tempo.Duracao.de(dias=7, horas=2)
120
+ print(dur.total_segundos)
121
+
122
+ tempo.dormir(0.1)
123
+ ```
124
+
125
+ ### colecoes (collections)
126
+
127
+ ```python
128
+ from portugython import colecoes
129
+
130
+ # Contagem
131
+ votos = colecoes.Contador(["sim", "nao", "sim", "sim", "nao"])
132
+ print(votos.mais_comuns(1))
133
+
134
+ # Fila dupla
135
+ d = colecoes.Deque([1, 2, 3])
136
+ d.adicione_esquerda(0)
137
+ d.adicione_direita(4)
138
+
139
+ # Pilha
140
+ pilha = colecoes.Pilha()
141
+ pilha.empurre("a")
142
+ pilha.empurre("b")
143
+ print(pilha.retire())
144
+
145
+ # Fila
146
+ fila = colecoes.Fila()
147
+ fila.enfileire("primeiro")
148
+ fila.enfileire("segundo")
149
+ print(fila.desenfileire())
150
+
151
+ # Tupla com campos nomeados
152
+ Ponto = colecoes.tupla_com_nome("Ponto", ["x", "y"])
153
+ p = Ponto(3, 4)
154
+ print(p.x, p.y)
155
+ ```
156
+
157
+ ### iteradores (itertools)
158
+
159
+ ```python
160
+ from portugython import iteradores
161
+
162
+ # Combinatoria
163
+ for combo in iteradores.combine([1, 2, 3, 4], 2):
164
+ print(combo)
165
+
166
+ # Produto cartesiano
167
+ for par in iteradores.produto("AB", "12"):
168
+ print(par)
169
+
170
+ # Acumulacao
171
+ totais = list(iteradores.acumule([1, 2, 3, 4, 5]))
172
+
173
+ # Encadeamento
174
+ unido = list(iteradores.encadeie([1, 2], [3, 4], [5]))
175
+ ```
176
+
177
+ ### funcional (functools)
178
+
179
+ ```python
180
+ from portugython import funcional
181
+
182
+ # Reducao
183
+ total = funcional.reduzido(lambda a, b: a + b, range(1, 11))
184
+
185
+ # Funcao parcial
186
+ multiplicar_por_3 = funcional.parcial(lambda a, b: a * b, 3)
187
+ print(multiplicar_por_3(7))
188
+
189
+ # Memoizacao
190
+ @funcional.cache
191
+ def fibonacci(n):
192
+ if n < 2:
193
+ return n
194
+ return fibonacci(n - 1) + fibonacci(n - 2)
195
+
196
+ # Composicao
197
+ dobrar = lambda x: x * 2
198
+ somar_um = lambda x: x + 1
199
+ dobrar_e_somar = funcional.compor(somar_um, dobrar)
200
+ print(dobrar_e_somar(5))
201
+ ```
202
+
203
+ ### expressao (re)
204
+
205
+ ```python
206
+ from portugython import expressao
207
+
208
+ # Busca simples
209
+ m = expressao.buscar(r"\d+", "pagina 42")
210
+ if m:
211
+ print(m.group())
212
+
213
+ # Todos os resultados
214
+ numeros = expressao.encontrar_todos(r"\d+", "1 mais 2 igual 3")
215
+
216
+ # Substituicao
217
+ limpo = expressao.substituir(r"\s+", " ", "texto com espacos")
218
+
219
+ # Padrao reutilizavel
220
+ email = expressao.Padrao(r"[\w.+-]+@[\w-]+\.[a-z]{2,}")
221
+ if email.encontrar("contato@example.com"):
222
+ print("Email valido")
223
+ ```
224
+
225
+ ## Referencia de builtins
226
+
227
+ ### Entrada / Saida
228
+ | Portugues | Python |
229
+ |-----------|--------|
230
+ | `escreva` | `print` |
231
+ | `leia` | `input` |
232
+ | `abra` | `open` |
233
+
234
+ ### Tipos
235
+ | Portugues | Python |
236
+ |-----------|--------|
237
+ | `inteiro` | `int` |
238
+ | `texto` | `str` |
239
+ | `decimal` | `float` |
240
+ | `logico` | `bool` |
241
+ | `lista` | `list` |
242
+ | `dicionario` | `dict` |
243
+ | `conjunto` | `set` |
244
+ | `tupla` | `tuple` |
245
+ | `intervalo` | `range` |
246
+
247
+ ### Constantes
248
+ | Portugues | Python |
249
+ |-----------|--------|
250
+ | `Verdadeiro` | `True` |
251
+ | `Falso` | `False` |
252
+ | `Nenhum` | `None` |
253
+
254
+ ### Funcoes de sequencia
255
+ | Portugues | Python |
256
+ |-----------|--------|
257
+ | `tamanho` | `len` |
258
+ | `soma` | `sum` |
259
+ | `maximo` | `max` |
260
+ | `minimo` | `min` |
261
+ | `absoluto` | `abs` |
262
+ | `classificado` | `sorted` |
263
+ | `reverso` | `reversed` |
264
+ | `enumerado` | `enumerate` |
265
+ | `comprimido` | `zip` |
266
+ | `mapeado` | `map` |
267
+ | `filtrado` | `filter` |
268
+
269
+ ### Operadores logicos
270
+ | Portugues | Python |
271
+ |-----------|--------|
272
+ | `nao(x)` | `not x` |
273
+ | `e(a, b)` | `a and b` |
274
+ | `ou(a, b)` | `a or b` |
275
+
276
+ ### Funcoes utilitarias
277
+ | Portugues | Python |
278
+ |-----------|--------|
279
+ | `se(c, a, b)` | `a if c else b` |
280
+ | `para_cada(f, it)` | `list(map(f, it))` |
281
+ | `filtro(f, it)` | `list(filter(f, it))` |
282
+ | `reduzido(f, it)` | `functools.reduce(f, it)` |
283
+
284
+ ## Contribuir
285
+
286
+ 1. Crie um fork deste repositorio
287
+ 2. Crie uma branch nova a partir de main
288
+ 3. Envie um pull request
289
+
290
+ ## Licenca
291
+
292
+ MIT
@@ -0,0 +1,265 @@
1
+ # Portugython
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/portugython.svg)](https://pypi.org/project/portugython/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/portugython.svg)](https://pypi.org/project/portugython/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Escreva Python em Portugues. Portugython traduz funcoes, tipos e modulos da biblioteca padrao do Python para nomes em portugues.
8
+
9
+ ## Instalacao
10
+
11
+ ```bash
12
+ pip install portugython
13
+ ```
14
+
15
+ ## Uso basico
16
+
17
+ ```python
18
+ from portugython import *
19
+
20
+ escreva("Ola, Mundo!")
21
+ nome = leia("Qual e seu nome? ")
22
+ escreva("Ola,", nome)
23
+
24
+ numeros = Lista([1, 2, 3, 4, 5])
25
+ numeros.adicione(6)
26
+ numeros.classifique(reverso=Verdadeiro)
27
+ escreva(numeros)
28
+
29
+ pares = filtro(lambda x: x % 2 == 0, numeros)
30
+ escreva("Pares:", pares)
31
+
32
+ resultado = se(tamanho(pares) > 0, "tem pares", "sem pares")
33
+ escreva(resultado)
34
+ ```
35
+
36
+ ## Modulos da biblioteca padrao
37
+
38
+ Cada modulo da stdlib tem uma versao em portugues que pode ser importada separadamente.
39
+
40
+ ### aleatorio (random)
41
+
42
+ ```python
43
+ from portugython import aleatorio
44
+
45
+ aleatorio.semente(42)
46
+ n = aleatorio.inteiro_aleatorio(1, 100)
47
+ item = aleatorio.escolha(["pedra", "papel", "tesoura"])
48
+ lista = [1, 2, 3, 4, 5]
49
+ aleatorio.embaralhe(lista)
50
+ amostra = aleatorio.amostra(range(50), k=5)
51
+ ```
52
+
53
+ ### matematica (math)
54
+
55
+ ```python
56
+ from portugython import matematica
57
+
58
+ print(matematica.PI)
59
+ print(matematica.raiz_quadrada(16))
60
+ print(matematica.fatorial(10))
61
+ print(matematica.seno(matematica.PI / 2))
62
+ print(matematica.mdc(48, 18))
63
+ print(matematica.combinacoes(10, 3))
64
+ ```
65
+
66
+ ### sistema (os + sys)
67
+
68
+ ```python
69
+ from portugython import sistema
70
+
71
+ pasta = sistema.diretorio_atual()
72
+ arquivos = sistema.listar_diretorio(".")
73
+ sistema.criar_diretorios("nova/pasta", existe_ok=Verdadeiro)
74
+ sistema.renomear("antigo.txt", "novo.txt")
75
+
76
+ print(sistema.versao)
77
+ print(sistema.plataforma)
78
+ db = sistema.variavel_ambiente("DATABASE_URL", "sqlite:///app.db")
79
+ ```
80
+
81
+ ### tempo (time + datetime)
82
+
83
+ ```python
84
+ from portugython import tempo
85
+
86
+ agora = tempo.agora()
87
+ print(agora.formatar("%d/%m/%Y %H:%M"))
88
+
89
+ hoje = tempo.hoje()
90
+ print(hoje.ano, hoje.mes, hoje.dia)
91
+
92
+ dur = tempo.Duracao.de(dias=7, horas=2)
93
+ print(dur.total_segundos)
94
+
95
+ tempo.dormir(0.1)
96
+ ```
97
+
98
+ ### colecoes (collections)
99
+
100
+ ```python
101
+ from portugython import colecoes
102
+
103
+ # Contagem
104
+ votos = colecoes.Contador(["sim", "nao", "sim", "sim", "nao"])
105
+ print(votos.mais_comuns(1))
106
+
107
+ # Fila dupla
108
+ d = colecoes.Deque([1, 2, 3])
109
+ d.adicione_esquerda(0)
110
+ d.adicione_direita(4)
111
+
112
+ # Pilha
113
+ pilha = colecoes.Pilha()
114
+ pilha.empurre("a")
115
+ pilha.empurre("b")
116
+ print(pilha.retire())
117
+
118
+ # Fila
119
+ fila = colecoes.Fila()
120
+ fila.enfileire("primeiro")
121
+ fila.enfileire("segundo")
122
+ print(fila.desenfileire())
123
+
124
+ # Tupla com campos nomeados
125
+ Ponto = colecoes.tupla_com_nome("Ponto", ["x", "y"])
126
+ p = Ponto(3, 4)
127
+ print(p.x, p.y)
128
+ ```
129
+
130
+ ### iteradores (itertools)
131
+
132
+ ```python
133
+ from portugython import iteradores
134
+
135
+ # Combinatoria
136
+ for combo in iteradores.combine([1, 2, 3, 4], 2):
137
+ print(combo)
138
+
139
+ # Produto cartesiano
140
+ for par in iteradores.produto("AB", "12"):
141
+ print(par)
142
+
143
+ # Acumulacao
144
+ totais = list(iteradores.acumule([1, 2, 3, 4, 5]))
145
+
146
+ # Encadeamento
147
+ unido = list(iteradores.encadeie([1, 2], [3, 4], [5]))
148
+ ```
149
+
150
+ ### funcional (functools)
151
+
152
+ ```python
153
+ from portugython import funcional
154
+
155
+ # Reducao
156
+ total = funcional.reduzido(lambda a, b: a + b, range(1, 11))
157
+
158
+ # Funcao parcial
159
+ multiplicar_por_3 = funcional.parcial(lambda a, b: a * b, 3)
160
+ print(multiplicar_por_3(7))
161
+
162
+ # Memoizacao
163
+ @funcional.cache
164
+ def fibonacci(n):
165
+ if n < 2:
166
+ return n
167
+ return fibonacci(n - 1) + fibonacci(n - 2)
168
+
169
+ # Composicao
170
+ dobrar = lambda x: x * 2
171
+ somar_um = lambda x: x + 1
172
+ dobrar_e_somar = funcional.compor(somar_um, dobrar)
173
+ print(dobrar_e_somar(5))
174
+ ```
175
+
176
+ ### expressao (re)
177
+
178
+ ```python
179
+ from portugython import expressao
180
+
181
+ # Busca simples
182
+ m = expressao.buscar(r"\d+", "pagina 42")
183
+ if m:
184
+ print(m.group())
185
+
186
+ # Todos os resultados
187
+ numeros = expressao.encontrar_todos(r"\d+", "1 mais 2 igual 3")
188
+
189
+ # Substituicao
190
+ limpo = expressao.substituir(r"\s+", " ", "texto com espacos")
191
+
192
+ # Padrao reutilizavel
193
+ email = expressao.Padrao(r"[\w.+-]+@[\w-]+\.[a-z]{2,}")
194
+ if email.encontrar("contato@example.com"):
195
+ print("Email valido")
196
+ ```
197
+
198
+ ## Referencia de builtins
199
+
200
+ ### Entrada / Saida
201
+ | Portugues | Python |
202
+ |-----------|--------|
203
+ | `escreva` | `print` |
204
+ | `leia` | `input` |
205
+ | `abra` | `open` |
206
+
207
+ ### Tipos
208
+ | Portugues | Python |
209
+ |-----------|--------|
210
+ | `inteiro` | `int` |
211
+ | `texto` | `str` |
212
+ | `decimal` | `float` |
213
+ | `logico` | `bool` |
214
+ | `lista` | `list` |
215
+ | `dicionario` | `dict` |
216
+ | `conjunto` | `set` |
217
+ | `tupla` | `tuple` |
218
+ | `intervalo` | `range` |
219
+
220
+ ### Constantes
221
+ | Portugues | Python |
222
+ |-----------|--------|
223
+ | `Verdadeiro` | `True` |
224
+ | `Falso` | `False` |
225
+ | `Nenhum` | `None` |
226
+
227
+ ### Funcoes de sequencia
228
+ | Portugues | Python |
229
+ |-----------|--------|
230
+ | `tamanho` | `len` |
231
+ | `soma` | `sum` |
232
+ | `maximo` | `max` |
233
+ | `minimo` | `min` |
234
+ | `absoluto` | `abs` |
235
+ | `classificado` | `sorted` |
236
+ | `reverso` | `reversed` |
237
+ | `enumerado` | `enumerate` |
238
+ | `comprimido` | `zip` |
239
+ | `mapeado` | `map` |
240
+ | `filtrado` | `filter` |
241
+
242
+ ### Operadores logicos
243
+ | Portugues | Python |
244
+ |-----------|--------|
245
+ | `nao(x)` | `not x` |
246
+ | `e(a, b)` | `a and b` |
247
+ | `ou(a, b)` | `a or b` |
248
+
249
+ ### Funcoes utilitarias
250
+ | Portugues | Python |
251
+ |-----------|--------|
252
+ | `se(c, a, b)` | `a if c else b` |
253
+ | `para_cada(f, it)` | `list(map(f, it))` |
254
+ | `filtro(f, it)` | `list(filter(f, it))` |
255
+ | `reduzido(f, it)` | `functools.reduce(f, it)` |
256
+
257
+ ## Contribuir
258
+
259
+ 1. Crie um fork deste repositorio
260
+ 2. Crie uma branch nova a partir de main
261
+ 3. Envie um pull request
262
+
263
+ ## Licenca
264
+
265
+ MIT