2006-08-07 14:05:07 +00:00
|
|
|
# This file is part of lyx2lyx
|
|
|
|
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2011-08-25 23:10:36 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-08-07 14:05:07 +00:00
|
|
|
|
2024-06-15 09:06:06 +00:00
|
|
|
"""This module parses lib/languages and prints it as a python
|
2006-08-07 14:05:07 +00:00
|
|
|
dictionary, ready to use by other python modules"""
|
|
|
|
|
|
|
|
import pprint
|
|
|
|
|
2024-06-15 09:06:06 +00:00
|
|
|
|
2006-08-07 14:05:07 +00:00
|
|
|
def parse_line(line):
|
2024-06-15 09:06:06 +00:00
|
|
|
"Parse line from languages and return it as a list."
|
2006-08-07 14:05:07 +00:00
|
|
|
j = 0
|
|
|
|
tmp = []
|
2024-06-15 09:06:06 +00:00
|
|
|
while j < len(line):
|
2006-08-07 14:05:07 +00:00
|
|
|
token = line[j:].split()[0]
|
|
|
|
if not token:
|
|
|
|
break
|
|
|
|
if token[0] != '"':
|
|
|
|
tmp.append(token)
|
|
|
|
j += len(token) + 1
|
2024-06-15 09:06:06 +00:00
|
|
|
elif line[j + 1 :].find('"') != -1:
|
2006-08-07 14:05:07 +00:00
|
|
|
k = line.find('"', j + 1)
|
2024-06-15 09:06:06 +00:00
|
|
|
tmp.append(line[j + 1 : k])
|
2006-08-07 14:05:07 +00:00
|
|
|
j = k + 1
|
|
|
|
else:
|
2024-06-15 09:06:06 +00:00
|
|
|
tmp.append(line[j + 1 :])
|
2006-08-07 14:05:07 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
while j < len(line) and line[j].isspace():
|
|
|
|
j += 1
|
|
|
|
|
|
|
|
return tmp
|
|
|
|
|
|
|
|
|
2024-06-15 09:06:06 +00:00
|
|
|
if __name__ == "__main__":
|
2006-08-07 14:05:07 +00:00
|
|
|
lines = open("../languages", "rb")
|
|
|
|
lang = {}
|
|
|
|
for line in lines:
|
2024-06-15 09:06:06 +00:00
|
|
|
if line[:1] != "#":
|
2006-08-07 14:05:07 +00:00
|
|
|
tmp = parse_line(line[:-1])
|
|
|
|
lang[tmp[0]] = tmp[1:]
|
|
|
|
|
2024-06-15 09:06:06 +00:00
|
|
|
print("# This file is generated by generate_incoding_info.py from lib/languages file.")
|
|
|
|
print("# Do not change this file directly.")
|
|
|
|
print()
|
|
|
|
print("lang = ", end=" ")
|
2006-08-07 14:05:07 +00:00
|
|
|
pprint.pprint(lang)
|