mirror of
https://github.com/gunchev/home_bin.git
synced 2025-11-20 12:15:46 +00:00
Update egn.py to work with python3
This commit is contained in:
parent
3e443cfaec
commit
fe54258919
1 changed files with 10 additions and 12 deletions
22
misc/egn.py
22
misc/egn.py
|
|
@ -5,14 +5,15 @@
|
|||
This program check if the given EGN (Universal Citizen Number)
|
||||
is valid in Bulgaria. All EGNs are accepted as arguments.
|
||||
|
||||
You can also import egn_check from here.
|
||||
You can also import egn_check from this file.
|
||||
"""
|
||||
|
||||
__version__ = "0.0.1"
|
||||
__author__ = "Doncho Gunchev <gunchev@gmail.com>"
|
||||
__depends__ = ["Python-2.3"]
|
||||
__version__ = "0.0.2"
|
||||
__author__ = "Doncho Gunchev <gunchev@gmail.com>"
|
||||
__depends__ = ["Python-3"]
|
||||
__copyright__ = "GPLv2+/BSD"
|
||||
|
||||
|
||||
def egn_check(egn):
|
||||
'''Check if the given EGN (Bulgarian Universal Citizen Number) is valid.'''
|
||||
if len(egn) != 10:
|
||||
|
|
@ -23,21 +24,18 @@ def egn_check(egn):
|
|||
check_sum += int(egn[i]) * multipliers[i]
|
||||
check_sum %= 11
|
||||
if check_sum > 9:
|
||||
check_sum = 0 # hmm? should it not just subtract 10?
|
||||
# print "check_sum = %i, egn[9] = %s" % (check_sum, egn[9])
|
||||
check_sum = 0 # hmm? should it not just subtract 10?
|
||||
return int(egn[9]) == check_sum
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
print("EGN check version " + __version__ + ", by Mr.700")
|
||||
if len(sys.argv) < 2:
|
||||
print "EGN check version " + __version__ + ", by Mr.700"
|
||||
print
|
||||
print __doc__.strip()
|
||||
print("\n" + __doc__.strip())
|
||||
else:
|
||||
print "EGN check version " + __version__ + ", by Mr.700"
|
||||
for arg in sys.argv[1:]:
|
||||
if egn_check(arg):
|
||||
print arg + " - OK"
|
||||
print(arg + " - OK")
|
||||
else:
|
||||
print arg + " - BAD"
|
||||
print(arg + " - BAD")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue