script: improve a bit create-table.py and regenerate the Georgian charsets.

- Avoid trailing whitespaces.
- Print which tool and version were used for the generation (to help for
  future debugging in case of discrepancies between versions or
  implementations).
This commit is contained in:
Jehan 2022-12-20 14:38:51 +01:00
parent 7875272a8c
commit bdd71d88f8
3 changed files with 53 additions and 36 deletions

View File

@ -50,7 +50,8 @@ language = \
'incomplete': []
}
## Table generated by script/create-table.py with iconv ##
## Table generated by script/create-table.py with: ##
## iconv (Debian GLIBC 2.31-13+deb11u5) 2.31 ##
# X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF #
charmap = \
[

View File

@ -50,7 +50,8 @@ language = \
'incomplete': []
}
## Table generated by script/create-table.py with iconv ##
## Table generated by script/create-table.py with: ##
## iconv (Debian GLIBC 2.31-13+deb11u5) 2.31 ##
# X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF #
charmap = \
[

View File

@ -60,8 +60,22 @@ charset = charset[0]
use_iconv = False
try:
b' '.decode(charset)
dec_version = 'Python {}'.format(sys.version).splitlines()[0]
except LookupError:
use_iconv = True
try:
call = subprocess.Popen(['iconv', '--version'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
if call.poll() is not None:
(_, error) = call.communicate(input='')
sys.stderr.write('Error: `iconv` ended with error "{}".\n'.format(error))
exit(1)
(dec_version, _) = call.communicate(input='')
dec_version = dec_version.decode('UTF-8').splitlines()[0]
except FileNotFoundError:
sys.stderr.write('Error: `iconv` is not installed.\n')
exit(1)
def get_utf8_char(bchar, charset, iconv):
if iconv:
@ -90,7 +104,8 @@ def get_utf8_char(bchar, charset, iconv):
# It would mean an illegal character.
return None
print('## Table generated by {} with {} ##'.format(script_path, 'iconv' if use_iconv else 'Python decode()'))
print('## Table generated by {} with: ##'.format(script_path))
print('## {} ##'.format(dec_version))
print('# X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF #')
print('charmap = \\')