-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdni.py
executable file
·34 lines (26 loc) · 819 Bytes
/
dni.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, argparse
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--first', required=True, action='store', help='First')
parser.add_argument('-l', '--last', required=True, action='store', help='Last')
parser.add_argument('-o', '--outputfile', required=True, action='store', help='Output file')
my_args = parser.parse_args()
return my_args
def letra_dni(dni):
letras="TRWAGMYFPDXBNJZSQVHLCKEO"
valor = dni%23
return letras[valor]
def main():
args = get_args()
first = args.first
last = args.last
outfile = args.outputfile
dni_arr = []
init_range = 0
for i in range(int(first),int(last)+1):
dni_arr.append(format(i, '08d')+letra_dni(i))
with open(outfile, 'w') as f:
for item in dni_arr:
f.write("%s\n" % item)
if __name__ == "__main__":
main()