diff --git a/misc/egn.py b/misc/egn.py index 879122c..9f0b8fb 100755 --- a/misc/egn.py +++ b/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 " -__depends__ = ["Python-2.3"] +__version__ = "0.0.2" +__author__ = "Doncho Gunchev " +__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")