-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from lappis-unb/update_analytics
Update analytics
- Loading branch information
Showing
21 changed files
with
455 additions
and
581 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ events.db | |
events.db-shm | ||
events.db-wal | ||
rasa.db | ||
*.db* | ||
|
||
### Rasa visualize ### | ||
graph.html | ||
|
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
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
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,53 @@ | ||
import re | ||
|
||
|
||
def isCpfValid(cpf): | ||
""" If cpf in the Brazilian format is valid, it returns True, otherwise, it returns False. """ | ||
|
||
# Check if type is str | ||
if not isinstance(cpf, str): | ||
return False | ||
|
||
# Remove some unwanted characters | ||
cpf = re.sub("[^0-9]", "", cpf) | ||
|
||
# Checks if string has 11 characters | ||
if len(cpf) != 11: | ||
return False | ||
|
||
sum = 0 | ||
weight = 10 | ||
|
||
""" Calculating the first cpf check digit. """ | ||
for n in range(9): | ||
sum = sum + int(cpf[n]) * weight | ||
|
||
# Decrement weight | ||
weight = weight - 1 | ||
|
||
verifyingDigit = 11 - sum % 11 | ||
|
||
if verifyingDigit > 9: | ||
firstVerifyingDigit = 0 | ||
else: | ||
firstVerifyingDigit = verifyingDigit | ||
|
||
""" Calculating the second check digit of cpf. """ | ||
sum = 0 | ||
weight = 11 | ||
for n in range(10): | ||
sum = sum + int(cpf[n]) * weight | ||
|
||
# Decrement weight | ||
weight = weight - 1 | ||
|
||
verifyingDigit = 11 - sum % 11 | ||
|
||
if verifyingDigit > 9: | ||
secondVerifyingDigit = 0 | ||
else: | ||
secondVerifyingDigit = verifyingDigit | ||
|
||
if cpf[-2:] == "%s%s" % (firstVerifyingDigit, secondVerifyingDigit): | ||
return True | ||
return False |
Oops, something went wrong.