brutils 2.2.0__tar.gz → 2.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.
Files changed (31) hide show
  1. brutils-2.2.0/README.md → brutils-2.3.0/PKG-INFO +272 -4
  2. brutils-2.2.0/PKG-INFO → brutils-2.3.0/README.md +239 -32
  3. brutils-2.3.0/brutils/__init__.py +134 -0
  4. brutils-2.3.0/brutils/currency.py +110 -0
  5. brutils-2.3.0/brutils/data/cities_code.json +5626 -0
  6. brutils-2.3.0/brutils/data/enums/__init__.py +1 -0
  7. brutils-2.3.0/brutils/data/enums/months.py +57 -0
  8. {brutils-2.2.0 → brutils-2.3.0}/brutils/data/enums/uf.py +31 -1
  9. brutils-2.3.0/brutils/date_utils.py +95 -0
  10. brutils-2.3.0/brutils/ibge/__init__.py +0 -0
  11. brutils-2.3.0/brutils/ibge/municipality.py +176 -0
  12. brutils-2.3.0/brutils/ibge/uf.py +61 -0
  13. {brutils-2.2.0 → brutils-2.3.0}/pyproject.toml +6 -4
  14. brutils-2.2.0/brutils/__init__.py +0 -168
  15. brutils-2.2.0/brutils/data/enums/__init__.py +0 -1
  16. {brutils-2.2.0 → brutils-2.3.0}/LICENSE +0 -0
  17. {brutils-2.2.0 → brutils-2.3.0}/brutils/cep.py +0 -0
  18. {brutils-2.2.0 → brutils-2.3.0}/brutils/cnpj.py +0 -0
  19. {brutils-2.2.0 → brutils-2.3.0}/brutils/cpf.py +0 -0
  20. {brutils-2.2.0 → brutils-2.3.0}/brutils/data/enums/better_enum.py +0 -0
  21. {brutils-2.2.0 → brutils-2.3.0}/brutils/data/legal_process_ids.json +0 -0
  22. {brutils-2.2.0 → brutils-2.3.0}/brutils/email.py +0 -0
  23. {brutils-2.2.0 → brutils-2.3.0}/brutils/exceptions/__init__.py +0 -0
  24. {brutils-2.2.0 → brutils-2.3.0}/brutils/exceptions/cep.py +0 -0
  25. {brutils-2.2.0 → brutils-2.3.0}/brutils/legal_process.py +0 -0
  26. {brutils-2.2.0 → brutils-2.3.0}/brutils/license_plate.py +0 -0
  27. {brutils-2.2.0 → brutils-2.3.0}/brutils/phone.py +0 -0
  28. {brutils-2.2.0 → brutils-2.3.0}/brutils/pis.py +0 -0
  29. {brutils-2.2.0 → brutils-2.3.0}/brutils/types/__init__.py +0 -0
  30. {brutils-2.2.0 → brutils-2.3.0}/brutils/types/address.py +0 -0
  31. {brutils-2.2.0 → brutils-2.3.0}/brutils/voter_id.py +0 -0
@@ -1,3 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: brutils
3
+ Version: 2.3.0
4
+ Summary: Utils library for specific Brazilian businesses
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: cpf,cnpj,cep,document,validation,brazil,brazilian
8
+ Author: The Brazilian Utils Organization
9
+ Requires-Python: >=3.10,<4.0
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Natural Language :: Portuguese
14
+ Classifier: Natural Language :: Portuguese (Brazilian)
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3 :: Only
23
+ Classifier: Topic :: Office/Business
24
+ Classifier: Topic :: Software Development :: Internationalization
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Dist: coverage (>=7.2.7,<8.0.0)
27
+ Requires-Dist: holidays (>=0.58,<0.59)
28
+ Requires-Dist: num2words (==0.5.14)
29
+ Project-URL: Repository, https://github.com/brazilian-utils/brutils
30
+ Description-Content-Type: text/markdown
31
+
1
32
  <div align="center">
2
33
  <h1>🇧🇷 Brazilian Utils</h1>
3
34
 
@@ -66,6 +97,8 @@ False
66
97
  - [generate\_phone](#generate_phone)
67
98
  - [Email](#email)
68
99
  - [is\_valid\_email](#is_valid_email)
100
+ - [Data](#date)
101
+ - [convert\_date\_to_text](#convert_date_to_text)
69
102
  - [Placa de Carro](#placa-de-carro)
70
103
  - [is\_valid\_license\_plate](#is_valid_license_plate)
71
104
  - [format\_license\_plate](#format_license_plate)
@@ -83,10 +116,20 @@ False
83
116
  - [format\_legal\_process](#format_legal_process)
84
117
  - [remove\_symbols\_legal\_process](#remove_symbols_legal_process)
85
118
  - [generate\_legal\_process](#generate_legal_process)
86
- - [Título Eleitoral](#titulo-eleitoral)
87
- - [is_valid_voter_id](#is_valid_voter_id)
88
- - [format_voter_id](#format_voter_id)
89
- - [generate_voter_id](#generate_voter_id)
119
+ - [Titulo Eleitoral](#titulo-eleitoral)
120
+ - [is\_valid\_voter\_id](#is_valid_voter_id)
121
+ - [format\_voter\_id](#format_voter_id)
122
+ - [generate\_voter\_id](#generate_voter_id)
123
+ - [IBGE](#ibge)
124
+ - [convert_code_to_uf](#convert_code_to_uf)
125
+ - [convert_uf_to_name](#convert_uf_to_name)
126
+ - [get_code_by_municipality_name](#get_code_by_municipality_name)
127
+ - [get\_municipality\_by\_code](#get_municipality_by_code)
128
+ - [Feriados](#feriados)
129
+ - [is_holiday](#is_holiday)
130
+ - [Monetário](#monetário)
131
+ - [format\_currency](#format_currency)
132
+ - [convert\_real\_to\_text](#convert_real_to_text)
90
133
 
91
134
  ## CPF
92
135
 
@@ -626,6 +669,33 @@ False
626
669
  False
627
670
  ```
628
671
 
672
+ ## Data
673
+
674
+ ## convert_date_to_text
675
+
676
+ Converte uma data em sua representação textual.
677
+
678
+ Argumentos:
679
+ - date (str): Uma string no formato dd/mm/aaaa
680
+
681
+ Retorna:
682
+ - A represetação textual da data ou None caso a data esteja mal formatada ou a data seja inválida.
683
+
684
+ Exemplo:
685
+
686
+ ````python
687
+ >>> from brutils import convert_date_to_text
688
+ >>> convert_date_to_text("25/12/2000")
689
+ "Vinte e cinco de dezembro de dois mil"
690
+ >>> convert_date_to_text("31/02/2000")
691
+ None
692
+ >>> convert_date_to_text("29/02/2024")
693
+ "Vinte e nove de fevereiro de dois mil e vinte e quatro"
694
+ >>> convert_date_to_text("1/08/2024")
695
+ "Primeiro de agosto de dois mil e vinte e quatro"
696
+ ````
697
+
698
+
629
699
  ## Placa de Carro
630
700
 
631
701
  ### is_valid_license_plate
@@ -1084,6 +1154,195 @@ Exemplo:
1084
1154
  '950125640248'
1085
1155
  ```
1086
1156
 
1157
+ ## IBGE
1158
+
1159
+ ### convert_code_to_uf
1160
+ Converte um determinado código do IBGE (string de 2 dígitos) para sua UF (abreviatura estadual) correspondente.
1161
+
1162
+ Args:
1163
+ * code (str): O código IBGE de 2 dígitos a ser convertido.
1164
+
1165
+ Retorna:
1166
+ * str or None: O código UF correspondente ao código IBGE, ou None se o
1167
+ código IBGE for inválido.
1168
+
1169
+ Exemplo:
1170
+
1171
+ ```python
1172
+ >>> from brutils.ibge.uf import convert_code_to_uf
1173
+ >>> convert_code_to_uf("12")
1174
+ 'AC'
1175
+ >>> convert_code_to_uf("33")
1176
+ 'RJ'
1177
+ >>> convert_code_to_uf("99")
1178
+ >>>
1179
+ ```
1180
+
1181
+ ### get_code_by_municipality_name
1182
+
1183
+ Retorna o código IBGE para um dado nome de município e código de UF.
1184
+
1185
+ Essa função recebe uma string representando o nome de um município e o código da UF, e retorna o código IBGE correspondente (string). A função lida com os nomes ignorando diferenças de maiúsculas, acentos, tratando o caractere "ç" como "c", e ignorando diferenças de maiúsculas para o código da UF.
1186
+
1187
+ Argumentos:
1188
+ * municipality_name (str): O nome do município.
1189
+ * uf (str): O código UF do estado.
1190
+
1191
+ Retorna:
1192
+ * str: O código IBGE do município. Retorna None se o nome não for válido ou não existir.
1193
+
1194
+ Exemplo:
1195
+
1196
+ ```python
1197
+ >>> from brutils import get_code_by_municipality_name
1198
+ >>> get_code_by_municipality_name("São Paulo", "SP")
1199
+ "3550308"
1200
+ >>> get_code_by_municipality_name("goiania", "go")
1201
+ "5208707"
1202
+ >>> get_code_by_municipality_name("Conceição do Coité", "BA")
1203
+ "2908408"
1204
+ >>> get_code_by_municipality_name("conceicao do Coite", "Ba")
1205
+ "2908408"
1206
+ >>> get_code_by_municipality_name("Municipio Inexistente", "")
1207
+ None
1208
+ >>> get_code_by_municipality_name("Municipio Inexistente", "RS")
1209
+ None
1210
+ ```
1211
+
1212
+ ### get_municipality_by_code
1213
+
1214
+ Retorna o nome do município e a UF para um código do IBGE.
1215
+
1216
+ Args:
1217
+ * code (str): O código do IBGE para o município.
1218
+
1219
+ Returns:
1220
+ * tuple: Retorna uma Tupla formatado como ("Município", "UF").
1221
+ * None: Retorna None se o código for inválido.
1222
+
1223
+ Example:
1224
+
1225
+ ```python
1226
+ >>> from brutils import get_municipality_by_code
1227
+ >>> get_municipality_by_code(3550308)
1228
+ ("São Paulo", "SP")
1229
+ ```
1230
+
1231
+ ### convert_uf_to_name
1232
+ Converte um código de UF brasileiro (por exemplo, 'SP') no nome completo do estado ('São Paulo').
1233
+
1234
+ A busca é case-insensitive (não diferencia maiúsculas de minúsculas) e ignora espaços em branco ao redor.
1235
+
1236
+ Argumentos:
1237
+ * uf (str): Código de UF com duas letras.
1238
+
1239
+ Retorna:
1240
+ * str | None: O nome completo do estado, ou ``None`` se o código for inválido.
1241
+
1242
+ Exemplo:
1243
+
1244
+ ```python
1245
+ >>> from brutils.ibge.uf import convert_uf_to_name
1246
+ >>> convert_uf_to_name('SP')
1247
+ 'São Paulo'
1248
+ >>> convert_uf_to_name('rj')
1249
+ 'Rio de Janeiro'
1250
+ ```
1251
+
1252
+ ## Feriados
1253
+
1254
+ ### is_holiday
1255
+
1256
+ Verifica se uma determinada data é um feriado nacional ou estadual no Brasil.
1257
+
1258
+ Esta função recebe um objeto `datetime` como a data e uma UF opcional (Unidade Federativa) para especificar feriados estaduais. Retorna `True` se a data for um feriado, `False` se não for, ou `None` se a data ou UF forem inválidas. Nota: a função não abrange feriados municipais.
1259
+
1260
+ Argumentos:
1261
+
1262
+ - `date (datetime)`: A data a ser verificada.
1263
+ - `uf (str, opcional)`: A abreviação do estado (UF) para verificar feriados estaduais. Se não fornecido, apenas feriados nacionais são considerados.
1264
+
1265
+ Retorna:
1266
+
1267
+ - `bool | None`: `True` se a data for um feriado, `False` se não for, ou `None` se a data ou UF forem inválidas.
1268
+
1269
+ Exemplo:
1270
+
1271
+ ```python
1272
+ >>> from datetime import datetime
1273
+ >>> from brutils import is_holiday
1274
+
1275
+ >>> is_holiday(datetime(2024, 1, 1))
1276
+ True
1277
+ >>> is_holiday(datetime(2024, 1, 2))
1278
+ False
1279
+ >>> is_holiday(datetime(2024, 3, 2), uf="SP")
1280
+ False
1281
+ >>> is_holiday(datetime(2024, 12, 25), uf="RJ")
1282
+ True
1283
+ ```
1284
+
1285
+ ## Monetário
1286
+
1287
+ ### format_currency
1288
+
1289
+ Formata um número seguindo o padrão monetário brasileiro. O número será formatado
1290
+ adicionando o símbolo R$ como prefixo, vírgula como separador decimal, e ponto como
1291
+ agrupador de milhar.
1292
+
1293
+ Argumentos:
1294
+ * float ou Decimal: Um número com ou sem casas decimais.
1295
+
1296
+ Retorna:
1297
+ * str ou None: O número formatado seguindo o padrão brasileiro.
1298
+
1299
+ Exemplo:
1300
+
1301
+ ```python
1302
+ >>> from brutils.currency import format_currency
1303
+ >>> format_currency(1259.03)
1304
+ 'R$ 1.259,03'
1305
+ >>> format_currency(0)
1306
+ 'R$ 0,00'
1307
+ >>> format_currency("not a number")
1308
+ None
1309
+ ```
1310
+
1311
+ ### convert_real_to_text
1312
+
1313
+ Converte um valor monetário em reais para sua representação por extenso. Esta função recebe um número decimal representando um valor monetário em reais e o converte para uma string com o valor escrito por extenso em português do Brasil. Ela trata tanto a parte inteira (reais) quanto a parte fracionária (centavos), respeitando a gramática correta para os casos de singular e plural, bem como casos especiais como zero e valores negativos.
1314
+
1315
+ Argumentos:
1316
+ - amount (decimal): O valor monetário a ser convertido por extenso.
1317
+ - A parte inteira representa os reais.
1318
+ - A parte decimal representa os centavos.
1319
+ - 2 casas decimais.
1320
+
1321
+ Retorna:
1322
+ - str: Uma string com o valor monetário escrito por extenso em português do Brasil.
1323
+ - Retorna "Zero reais" para o valor 0,00.
1324
+ - Retorna None se o valor for inválido ou absolutamente maior que 1 quatrilhão.
1325
+ - Trata valores negativos, adicionando "Menos" no início da string.
1326
+
1327
+ Limitações:
1328
+ - Esta função pode perder precisão em ±1 centavo para casos em que o valor absoluto
1329
+ ultrapasse trilhões devido a erros de arredondamento de ponto flutuante.
1330
+
1331
+ Exemplo:
1332
+
1333
+ ```python
1334
+ >>> from brutils.currency import convert_real_to_text
1335
+ >>> convert_real_to_text(1523.45)
1336
+ 'Mil, quinhentos e vinte e três reais e quarenta e cinco centavos'
1337
+ >>> convert_real_to_text(0.01)
1338
+ 'Um centavo'
1339
+ >>> convert_real_to_text(0.00)
1340
+ 'Zero reais'
1341
+ >>> convert_real_to_text(-50.25)
1342
+ 'Menos cinquenta reais e vinte e cinco centavos'
1343
+ >>> convert_real_to_text("invalid")
1344
+ None
1345
+ ```
1087
1346
 
1088
1347
  # Novos Utilitários e Reportar Bugs
1089
1348
 
@@ -1115,3 +1374,12 @@ Vamos construir juntos! 🚀🚀
1115
1374
  [github-discussions]: https://github.com/brazilian-utils/brutils-python/discussions
1116
1375
  [github-issues-doc]: https://docs.github.com/pt/issues/tracking-your-work-with-issues/creating-an-issue
1117
1376
  [github-issues]: https://github.com/brazilian-utils/brutils-python/issues
1377
+
1378
+ ## ❤️ Quem já Contribuiu
1379
+
1380
+ <a href="https://github.com/brazilian-utils/brutils-python/graphs/contributors">
1381
+ <img src="https://contrib.rocks/image?repo=brazilian-utils/brutils-python" />
1382
+ </a></br></br>
1383
+
1384
+ _Feito por [contrib.rocks](https://contrib.rocks)._
1385
+
@@ -1,31 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: brutils
3
- Version: 2.2.0
4
- Summary: Utils library for specific Brazilian businesses
5
- Home-page: https://github.com/brazilian-utils/brutils
6
- License: MIT
7
- Keywords: cpf,cnpj,cep,document,validation,brazil,brazilian
8
- Author: The Brazilian Utils Organization
9
- Requires-Python: >=3.8.1,<4.0.0
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Natural Language :: English
13
- Classifier: Natural Language :: Portuguese
14
- Classifier: Natural Language :: Portuguese (Brazilian)
15
- Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.9
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 :: Only
22
- Classifier: Programming Language :: Python :: 3.8
23
- Classifier: Topic :: Office/Business
24
- Classifier: Topic :: Software Development :: Internationalization
25
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
- Project-URL: Repository, https://github.com/brazilian-utils/brutils
27
- Description-Content-Type: text/markdown
28
-
29
1
  <div align="center">
30
2
  <h1>🇧🇷 Brazilian Utils</h1>
31
3
 
@@ -94,6 +66,8 @@ False
94
66
  - [generate\_phone](#generate_phone)
95
67
  - [Email](#email)
96
68
  - [is\_valid\_email](#is_valid_email)
69
+ - [Data](#date)
70
+ - [convert\_date\_to_text](#convert_date_to_text)
97
71
  - [Placa de Carro](#placa-de-carro)
98
72
  - [is\_valid\_license\_plate](#is_valid_license_plate)
99
73
  - [format\_license\_plate](#format_license_plate)
@@ -111,10 +85,20 @@ False
111
85
  - [format\_legal\_process](#format_legal_process)
112
86
  - [remove\_symbols\_legal\_process](#remove_symbols_legal_process)
113
87
  - [generate\_legal\_process](#generate_legal_process)
114
- - [Título Eleitoral](#titulo-eleitoral)
115
- - [is_valid_voter_id](#is_valid_voter_id)
116
- - [format_voter_id](#format_voter_id)
117
- - [generate_voter_id](#generate_voter_id)
88
+ - [Titulo Eleitoral](#titulo-eleitoral)
89
+ - [is\_valid\_voter\_id](#is_valid_voter_id)
90
+ - [format\_voter\_id](#format_voter_id)
91
+ - [generate\_voter\_id](#generate_voter_id)
92
+ - [IBGE](#ibge)
93
+ - [convert_code_to_uf](#convert_code_to_uf)
94
+ - [convert_uf_to_name](#convert_uf_to_name)
95
+ - [get_code_by_municipality_name](#get_code_by_municipality_name)
96
+ - [get\_municipality\_by\_code](#get_municipality_by_code)
97
+ - [Feriados](#feriados)
98
+ - [is_holiday](#is_holiday)
99
+ - [Monetário](#monetário)
100
+ - [format\_currency](#format_currency)
101
+ - [convert\_real\_to\_text](#convert_real_to_text)
118
102
 
119
103
  ## CPF
120
104
 
@@ -654,6 +638,33 @@ False
654
638
  False
655
639
  ```
656
640
 
641
+ ## Data
642
+
643
+ ## convert_date_to_text
644
+
645
+ Converte uma data em sua representação textual.
646
+
647
+ Argumentos:
648
+ - date (str): Uma string no formato dd/mm/aaaa
649
+
650
+ Retorna:
651
+ - A represetação textual da data ou None caso a data esteja mal formatada ou a data seja inválida.
652
+
653
+ Exemplo:
654
+
655
+ ````python
656
+ >>> from brutils import convert_date_to_text
657
+ >>> convert_date_to_text("25/12/2000")
658
+ "Vinte e cinco de dezembro de dois mil"
659
+ >>> convert_date_to_text("31/02/2000")
660
+ None
661
+ >>> convert_date_to_text("29/02/2024")
662
+ "Vinte e nove de fevereiro de dois mil e vinte e quatro"
663
+ >>> convert_date_to_text("1/08/2024")
664
+ "Primeiro de agosto de dois mil e vinte e quatro"
665
+ ````
666
+
667
+
657
668
  ## Placa de Carro
658
669
 
659
670
  ### is_valid_license_plate
@@ -1112,6 +1123,195 @@ Exemplo:
1112
1123
  '950125640248'
1113
1124
  ```
1114
1125
 
1126
+ ## IBGE
1127
+
1128
+ ### convert_code_to_uf
1129
+ Converte um determinado código do IBGE (string de 2 dígitos) para sua UF (abreviatura estadual) correspondente.
1130
+
1131
+ Args:
1132
+ * code (str): O código IBGE de 2 dígitos a ser convertido.
1133
+
1134
+ Retorna:
1135
+ * str or None: O código UF correspondente ao código IBGE, ou None se o
1136
+ código IBGE for inválido.
1137
+
1138
+ Exemplo:
1139
+
1140
+ ```python
1141
+ >>> from brutils.ibge.uf import convert_code_to_uf
1142
+ >>> convert_code_to_uf("12")
1143
+ 'AC'
1144
+ >>> convert_code_to_uf("33")
1145
+ 'RJ'
1146
+ >>> convert_code_to_uf("99")
1147
+ >>>
1148
+ ```
1149
+
1150
+ ### get_code_by_municipality_name
1151
+
1152
+ Retorna o código IBGE para um dado nome de município e código de UF.
1153
+
1154
+ Essa função recebe uma string representando o nome de um município e o código da UF, e retorna o código IBGE correspondente (string). A função lida com os nomes ignorando diferenças de maiúsculas, acentos, tratando o caractere "ç" como "c", e ignorando diferenças de maiúsculas para o código da UF.
1155
+
1156
+ Argumentos:
1157
+ * municipality_name (str): O nome do município.
1158
+ * uf (str): O código UF do estado.
1159
+
1160
+ Retorna:
1161
+ * str: O código IBGE do município. Retorna None se o nome não for válido ou não existir.
1162
+
1163
+ Exemplo:
1164
+
1165
+ ```python
1166
+ >>> from brutils import get_code_by_municipality_name
1167
+ >>> get_code_by_municipality_name("São Paulo", "SP")
1168
+ "3550308"
1169
+ >>> get_code_by_municipality_name("goiania", "go")
1170
+ "5208707"
1171
+ >>> get_code_by_municipality_name("Conceição do Coité", "BA")
1172
+ "2908408"
1173
+ >>> get_code_by_municipality_name("conceicao do Coite", "Ba")
1174
+ "2908408"
1175
+ >>> get_code_by_municipality_name("Municipio Inexistente", "")
1176
+ None
1177
+ >>> get_code_by_municipality_name("Municipio Inexistente", "RS")
1178
+ None
1179
+ ```
1180
+
1181
+ ### get_municipality_by_code
1182
+
1183
+ Retorna o nome do município e a UF para um código do IBGE.
1184
+
1185
+ Args:
1186
+ * code (str): O código do IBGE para o município.
1187
+
1188
+ Returns:
1189
+ * tuple: Retorna uma Tupla formatado como ("Município", "UF").
1190
+ * None: Retorna None se o código for inválido.
1191
+
1192
+ Example:
1193
+
1194
+ ```python
1195
+ >>> from brutils import get_municipality_by_code
1196
+ >>> get_municipality_by_code(3550308)
1197
+ ("São Paulo", "SP")
1198
+ ```
1199
+
1200
+ ### convert_uf_to_name
1201
+ Converte um código de UF brasileiro (por exemplo, 'SP') no nome completo do estado ('São Paulo').
1202
+
1203
+ A busca é case-insensitive (não diferencia maiúsculas de minúsculas) e ignora espaços em branco ao redor.
1204
+
1205
+ Argumentos:
1206
+ * uf (str): Código de UF com duas letras.
1207
+
1208
+ Retorna:
1209
+ * str | None: O nome completo do estado, ou ``None`` se o código for inválido.
1210
+
1211
+ Exemplo:
1212
+
1213
+ ```python
1214
+ >>> from brutils.ibge.uf import convert_uf_to_name
1215
+ >>> convert_uf_to_name('SP')
1216
+ 'São Paulo'
1217
+ >>> convert_uf_to_name('rj')
1218
+ 'Rio de Janeiro'
1219
+ ```
1220
+
1221
+ ## Feriados
1222
+
1223
+ ### is_holiday
1224
+
1225
+ Verifica se uma determinada data é um feriado nacional ou estadual no Brasil.
1226
+
1227
+ Esta função recebe um objeto `datetime` como a data e uma UF opcional (Unidade Federativa) para especificar feriados estaduais. Retorna `True` se a data for um feriado, `False` se não for, ou `None` se a data ou UF forem inválidas. Nota: a função não abrange feriados municipais.
1228
+
1229
+ Argumentos:
1230
+
1231
+ - `date (datetime)`: A data a ser verificada.
1232
+ - `uf (str, opcional)`: A abreviação do estado (UF) para verificar feriados estaduais. Se não fornecido, apenas feriados nacionais são considerados.
1233
+
1234
+ Retorna:
1235
+
1236
+ - `bool | None`: `True` se a data for um feriado, `False` se não for, ou `None` se a data ou UF forem inválidas.
1237
+
1238
+ Exemplo:
1239
+
1240
+ ```python
1241
+ >>> from datetime import datetime
1242
+ >>> from brutils import is_holiday
1243
+
1244
+ >>> is_holiday(datetime(2024, 1, 1))
1245
+ True
1246
+ >>> is_holiday(datetime(2024, 1, 2))
1247
+ False
1248
+ >>> is_holiday(datetime(2024, 3, 2), uf="SP")
1249
+ False
1250
+ >>> is_holiday(datetime(2024, 12, 25), uf="RJ")
1251
+ True
1252
+ ```
1253
+
1254
+ ## Monetário
1255
+
1256
+ ### format_currency
1257
+
1258
+ Formata um número seguindo o padrão monetário brasileiro. O número será formatado
1259
+ adicionando o símbolo R$ como prefixo, vírgula como separador decimal, e ponto como
1260
+ agrupador de milhar.
1261
+
1262
+ Argumentos:
1263
+ * float ou Decimal: Um número com ou sem casas decimais.
1264
+
1265
+ Retorna:
1266
+ * str ou None: O número formatado seguindo o padrão brasileiro.
1267
+
1268
+ Exemplo:
1269
+
1270
+ ```python
1271
+ >>> from brutils.currency import format_currency
1272
+ >>> format_currency(1259.03)
1273
+ 'R$ 1.259,03'
1274
+ >>> format_currency(0)
1275
+ 'R$ 0,00'
1276
+ >>> format_currency("not a number")
1277
+ None
1278
+ ```
1279
+
1280
+ ### convert_real_to_text
1281
+
1282
+ Converte um valor monetário em reais para sua representação por extenso. Esta função recebe um número decimal representando um valor monetário em reais e o converte para uma string com o valor escrito por extenso em português do Brasil. Ela trata tanto a parte inteira (reais) quanto a parte fracionária (centavos), respeitando a gramática correta para os casos de singular e plural, bem como casos especiais como zero e valores negativos.
1283
+
1284
+ Argumentos:
1285
+ - amount (decimal): O valor monetário a ser convertido por extenso.
1286
+ - A parte inteira representa os reais.
1287
+ - A parte decimal representa os centavos.
1288
+ - 2 casas decimais.
1289
+
1290
+ Retorna:
1291
+ - str: Uma string com o valor monetário escrito por extenso em português do Brasil.
1292
+ - Retorna "Zero reais" para o valor 0,00.
1293
+ - Retorna None se o valor for inválido ou absolutamente maior que 1 quatrilhão.
1294
+ - Trata valores negativos, adicionando "Menos" no início da string.
1295
+
1296
+ Limitações:
1297
+ - Esta função pode perder precisão em ±1 centavo para casos em que o valor absoluto
1298
+ ultrapasse trilhões devido a erros de arredondamento de ponto flutuante.
1299
+
1300
+ Exemplo:
1301
+
1302
+ ```python
1303
+ >>> from brutils.currency import convert_real_to_text
1304
+ >>> convert_real_to_text(1523.45)
1305
+ 'Mil, quinhentos e vinte e três reais e quarenta e cinco centavos'
1306
+ >>> convert_real_to_text(0.01)
1307
+ 'Um centavo'
1308
+ >>> convert_real_to_text(0.00)
1309
+ 'Zero reais'
1310
+ >>> convert_real_to_text(-50.25)
1311
+ 'Menos cinquenta reais e vinte e cinco centavos'
1312
+ >>> convert_real_to_text("invalid")
1313
+ None
1314
+ ```
1115
1315
 
1116
1316
  # Novos Utilitários e Reportar Bugs
1117
1317
 
@@ -1144,3 +1344,10 @@ Vamos construir juntos! 🚀🚀
1144
1344
  [github-issues-doc]: https://docs.github.com/pt/issues/tracking-your-work-with-issues/creating-an-issue
1145
1345
  [github-issues]: https://github.com/brazilian-utils/brutils-python/issues
1146
1346
 
1347
+ ## ❤️ Quem já Contribuiu
1348
+
1349
+ <a href="https://github.com/brazilian-utils/brutils-python/graphs/contributors">
1350
+ <img src="https://contrib.rocks/image?repo=brazilian-utils/brutils-python" />
1351
+ </a></br></br>
1352
+
1353
+ _Feito por [contrib.rocks](https://contrib.rocks)._