-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '394' of github.com:BeneBr/brutils-python into 394
- Loading branch information
Showing
15 changed files
with
192 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Comandos nos comentários | ||
on: | ||
issue_comment: | ||
types: created | ||
|
||
permissions: | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
issue_assign: | ||
runs-on: ubuntu-22.04 | ||
if: (!github.event.issue.pull_request) && github.event.comment.body == 'bora!' | ||
concurrency: | ||
group: ${{ github.actor }}-issue-assign | ||
steps: | ||
- run: | | ||
echo "Issue ${{ github.event.issue.number }} atribuida a ${{ github.event.comment.user.login }}" | ||
echo "Verifique [o guia de contribuição](https://github.com/brazilian-utils/brutils-python/blob/main/CONTRIBUTING.md) para mais informações sobre como submeter sua Pull Request." | ||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees | ||
- name: Create or Update Comment | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Issue ${{ github.event.issue.number }} atribuida a ${{ github.event.comment.user.login }} :rocket:" | ||
"Verifique [o guia de contribuição](https://github.com/brazilian-utils/brutils-python/blob/main/CONTRIBUTING.md) para mais informações sobre como submeter sua Pull Request." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .uf import UF | ||
from .uf import CODE_TO_UF, UF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from brutils.data.enums.uf import CODE_TO_UF | ||
|
||
|
||
def convert_code_to_uf(code): # type: (str) -> str | None | ||
""" | ||
Converts a given IBGE code (2-digit string) to its corresponding UF (state abbreviation). | ||
This function takes a 2-digit IBGE code and returns the corresponding UF code. | ||
It handles all Brazilian states and the Federal District. | ||
Args: | ||
code (str): The 2-digit IBGE code to be converted. | ||
Returns: | ||
str or None: The UF code corresponding to the IBGE code, | ||
or None if the IBGE code is invalid. | ||
Example: | ||
>>> convert_code_to_uf('12') | ||
'AC' | ||
>>> convert_code_to_uf('33') | ||
'RJ' | ||
>>> convert_code_to_uf('99') | ||
>>> | ||
""" | ||
|
||
result = None | ||
|
||
if code in CODE_TO_UF.values: | ||
result = CODE_TO_UF(code).name | ||
|
||
return result |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from unittest import TestCase | ||
|
||
from brutils.ibge.uf import convert_code_to_uf | ||
|
||
|
||
class TestUF(TestCase): | ||
def test_convert_code_to_uf(self): | ||
# Testes para códigos válidos | ||
self.assertEqual(convert_code_to_uf("12"), "AC") | ||
self.assertEqual(convert_code_to_uf("33"), "RJ") | ||
self.assertEqual(convert_code_to_uf("31"), "MG") | ||
self.assertEqual(convert_code_to_uf("52"), "GO") | ||
|
||
# Testes para códigos inválidos | ||
self.assertIsNone(convert_code_to_uf("99")) | ||
self.assertIsNone(convert_code_to_uf("00")) | ||
self.assertIsNone(convert_code_to_uf("")) | ||
self.assertIsNone(convert_code_to_uf("AB")) |