File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- #!/usr/bin/env python2
1+ #!/usr/bin/env python3
2+
23import tarfile
4+ from io import TextIOWrapper
35
46unifont = 'unifont-8.0.01.tar.gz'
57loc = 'unifont-8.0.01/font/plane00/'
1315 with open ('header.txt' ) as g :
1416 f .write (g .read ())
1517 for name in hexfiles :
16- z = unizip .extractfile (name )
17- f .write (z .read ())
18- z .close ()
18+ with TextIOWrapper (unizip .extractfile (name )) as z :
19+ f .write (z .read ())
1920
2021
Original file line number Diff line number Diff line change 1- #!/usr/bin/env python2
1+ #!/usr/bin/env python3
22
33import os
44import string
55import tarfile
6+ from io import TextIOWrapper
7+
8+ import monobit
69
710bdf_name = 'uni_vga/u_vga16.bdf'
811unizip = 'uni-vga.tgz'
912
10- infile = tarfile .open (unizip , 'r:gz' ).extractfile (bdf_name )
11-
1213header = 'header.txt'
1314hex_name = 'univga_16.hex'
14- with open (hex_name , 'w' ) as outfile :
15- with open (header , 'r' ) as h :
16- for line in h :
17- outfile .write (line )
1815
19- for line in infile :
20- if not line :
21- continue
22- if line [: 8 ] == 'ENCODING' :
23- outfile . write ( ' \n %04X:' % int ( line [ 8 :]))
24- if len ( line ) == 3 and line [ 0 ] in string . hexdigits and line [ 1 ] in string . hexdigits and line [ 2 ] == ' \n ' :
25- outfile .write (line [: 2 ] )
26- outfile . write ( ' \n ' )
27- infile . close ()
16+ with tarfile . open ( unizip , 'r:gz' ). extractfile ( bdf_name ) as infile :
17+ uni_vga = monobit . load ( TextIOWrapper ( infile ), format = 'bdf' )
18+ with open ( hex_name , 'w' ) as outfile :
19+ with open ( header , 'r' ) as h :
20+ for line in h :
21+ outfile . write ( line )
22+ outfile .write (' \n ' )
23+ uni_vga . save ( outfile , format = 'hex ' )
24+
You can’t perform that action at this time.
0 commit comments