tools/generatelocaledef
author Andrzej Szeszo <aszeszo@gmail.com>
Sun, 17 Apr 2011 01:38:03 +0100
changeset 566 262d41059e9b
parent 0 542988ea726d
permissions -rwxr-xr-x
Added tag oi148b for changeset 459f0c0bc498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     1
#!/usr/sfw/bin/python
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     2
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     3
# CDDL HEADER START
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     4
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").  
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     8
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
     9
# You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    11
# See the License for the specific language governing permissions
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    12
# and limitations under the License.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    13
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    15
# file and include the License file at src/OPENSOLARIS.LICENSE.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    19
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    20
# CDDL HEADER END
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    21
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    22
# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    23
# Use is subject to license terms.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    24
#
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    25
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    26
from optparse import OptionParser
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    27
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    28
import logging
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    29
logging.basicConfig()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    30
log = logging.getLogger()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    31
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    32
import re
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    33
import os
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    34
import sys
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    35
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    36
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    37
localedef_include_re = re.compile('^include\s+(\S+)$')
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    38
localedef_include_re_multiline = re.compile('^include\s+(\S+)$', re.M)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    39
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    40
def process_include(includesdir, include):
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    41
	"""Used to non-recursively process a given include and return the resulting text with the includes filled in"""
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    42
	filename = os.path.join(includesdir, include)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    43
	result = open(filename, "r").read()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    44
	log.debug("Tail of '%s' : '%r'" % (include, result[-3:]))
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    45
	log.debug("Length of result: '%d'" % len(result))
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    46
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    47
	#Some includes have further includes, as a temporary quick fix further
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    48
	#process these. Can't process all includes as with UTF-8 ones this will
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    49
	#be far too slow.
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    50
	sub_includes = [
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    51
		"LC_CTYPE/alpha.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    52
		"LC_CTYPE/alpha.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    53
		"LC_CTYPE/alpha.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    54
		"LC_CTYPE/alpha.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    55
		"LC_CTYPE/alpha.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    56
		"LC_CTYPE/alpha.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    57
		"LC_CTYPE/alpha.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    58
		"LC_CTYPE/alpha.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    59
		"LC_CTYPE/alpha.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    60
		"LC_CTYPE/cntrl.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    61
		"LC_CTYPE/cntrl.common",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    62
		"LC_CTYPE/cntrl.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    63
		"LC_CTYPE/cntrl.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    64
		"LC_CTYPE/cntrl.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    65
		"LC_CTYPE/cntrl.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    66
		"LC_CTYPE/cntrl.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    67
		"LC_CTYPE/cntrl.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    68
		"LC_CTYPE/digit.common",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    69
		"LC_CTYPE/graph.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    70
		"LC_CTYPE/graph.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    71
		"LC_CTYPE/graph.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    72
		"LC_CTYPE/graph.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    73
		"LC_CTYPE/graph.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    74
		"LC_CTYPE/graph.iso4",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    75
		"LC_CTYPE/graph.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    76
		"LC_CTYPE/graph.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    77
		"LC_CTYPE/graph.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    78
		"LC_CTYPE/graph.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    79
		"LC_CTYPE/lower.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    80
		"LC_CTYPE/lower.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    81
		"LC_CTYPE/lower.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    82
		"LC_CTYPE/lower.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    83
		"LC_CTYPE/lower.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    84
		"LC_CTYPE/lower.iso4",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    85
		"LC_CTYPE/lower.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    86
		"LC_CTYPE/lower.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    87
		"LC_CTYPE/lower.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    88
		"LC_CTYPE/lower.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    89
		"LC_CTYPE/print.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    90
		"LC_CTYPE/print.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    91
		"LC_CTYPE/print.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    92
		"LC_CTYPE/print.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    93
		"LC_CTYPE/print.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    94
		"LC_CTYPE/print.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    95
		"LC_CTYPE/print.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    96
		"LC_CTYPE/print.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    97
		"LC_CTYPE/print.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    98
		"LC_CTYPE/punct.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
    99
		"LC_CTYPE/punct.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   100
		"LC_CTYPE/punct.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   101
		"LC_CTYPE/punct.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   102
		"LC_CTYPE/punct.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   103
		"LC_CTYPE/punct.iso4",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   104
		"LC_CTYPE/punct.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   105
		"LC_CTYPE/punct.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   106
		"LC_CTYPE/punct.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   107
		"LC_CTYPE/punct.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   108
		"LC_CTYPE/space.common",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   109
		"LC_CTYPE/tolower.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   110
		"LC_CTYPE/tolower.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   111
		"LC_CTYPE/tolower.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   112
		"LC_CTYPE/tolower.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   113
		"LC_CTYPE/tolower.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   114
		"LC_CTYPE/tolower.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   115
		"LC_CTYPE/tolower.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   116
		"LC_CTYPE/tolower.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   117
		"LC_CTYPE/tolower.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   118
		"LC_CTYPE/toupper.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   119
		"LC_CTYPE/toupper.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   120
		"LC_CTYPE/toupper.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   121
		"LC_CTYPE/toupper.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   122
		"LC_CTYPE/toupper.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   123
		"LC_CTYPE/toupper.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   124
		"LC_CTYPE/toupper.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   125
		"LC_CTYPE/toupper.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   126
		"LC_CTYPE/toupper.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   127
		"LC_CTYPE/upper.1251",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   128
		"LC_CTYPE/upper.iso1",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   129
		"LC_CTYPE/upper.iso13",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   130
		"LC_CTYPE/upper.iso15",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   131
		"LC_CTYPE/upper.iso2",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   132
		"LC_CTYPE/upper.iso4",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   133
		"LC_CTYPE/upper.iso5",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   134
		"LC_CTYPE/upper.iso7",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   135
		"LC_CTYPE/upper.iso9",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   136
		"LC_CTYPE/upper.koi8",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   137
		"LC_CTYPE/xdigit.common",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   138
		"LC_TIME/abday.albanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   139
		"LC_TIME/abday.austrian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   140
		"LC_TIME/abday.bulgarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   141
		"LC_TIME/abday.catalan",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   142
		"LC_TIME/abday.croatian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   143
		"LC_TIME/abday.czech",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   144
		"LC_TIME/abday.danish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   145
		"LC_TIME/abday.dutch",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   146
		"LC_TIME/abday.english",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   147
		"LC_TIME/abday.estonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   148
		"LC_TIME/abday.finnish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   149
		"LC_TIME/abday.french",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   150
		"LC_TIME/abday.french_swiss",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   151
		"LC_TIME/abday.german",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   152
		"LC_TIME/abday.greek",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   153
		"LC_TIME/abday.hungarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   154
		"LC_TIME/abday.icelandic",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   155
		"LC_TIME/abday.italian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   156
		"LC_TIME/abday.latvian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   157
		"LC_TIME/abday.lithuanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   158
		"LC_TIME/abday.macedonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   159
		"LC_TIME/abday.nynorsk",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   160
		"LC_TIME/abday.polish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   161
		"LC_TIME/abday.portuguese",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   162
		"LC_TIME/abday.romanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   163
		"LC_TIME/abday.russian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   164
		"LC_TIME/abday.slovakian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   165
		"LC_TIME/abday.slovenian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   166
		"LC_TIME/abday.spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   167
		"LC_TIME/abday.swedish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   168
		"LC_TIME/abday.turkish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   169
		"LC_TIME/abday.yugoslavian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   170
		"LC_TIME/abmon.albanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   171
		"LC_TIME/abmon.austrian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   172
		"LC_TIME/abmon.bulgarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   173
		"LC_TIME/abmon.catalan",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   174
		"LC_TIME/abmon.col_spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   175
		"LC_TIME/abmon.croatian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   176
		"LC_TIME/abmon.czech",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   177
		"LC_TIME/abmon.danish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   178
		"LC_TIME/abmon.dutch",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   179
		"LC_TIME/abmon.english",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   180
		"LC_TIME/abmon.estonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   181
		"LC_TIME/abmon.finnish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   182
		"LC_TIME/abmon.french",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   183
		"LC_TIME/abmon.german",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   184
		"LC_TIME/abmon.greek",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   185
		"LC_TIME/abmon.hungarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   186
		"LC_TIME/abmon.icelandic",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   187
		"LC_TIME/abmon.italian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   188
		"LC_TIME/abmon.latvian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   189
		"LC_TIME/abmon.lithuanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   190
		"LC_TIME/abmon.macedonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   191
		"LC_TIME/abmon.nynorsk",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   192
		"LC_TIME/abmon.polish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   193
		"LC_TIME/abmon.portuguese",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   194
		"LC_TIME/abmon.romanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   195
		"LC_TIME/abmon.russian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   196
		"LC_TIME/abmon.slovakian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   197
		"LC_TIME/abmon.slovenian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   198
		"LC_TIME/abmon.spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   199
		"LC_TIME/abmon.swedish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   200
		"LC_TIME/abmon.turkish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   201
		"LC_TIME/abmon.yugoslavian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   202
		"LC_TIME/day.albanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   203
		"LC_TIME/day.bulgarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   204
		"LC_TIME/day.catalan",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   205
		"LC_TIME/day.croatian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   206
		"LC_TIME/day.czech",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   207
		"LC_TIME/day.danish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   208
		"LC_TIME/day.dutch",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   209
		"LC_TIME/day.english",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   210
		"LC_TIME/day.estonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   211
		"LC_TIME/day.finnish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   212
		"LC_TIME/day.french",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   213
		"LC_TIME/day.german",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   214
		"LC_TIME/day.greek",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   215
		"LC_TIME/day.hungarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   216
		"LC_TIME/day.icelandic",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   217
		"LC_TIME/day.italian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   218
		"LC_TIME/day.latvian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   219
		"LC_TIME/day.lithuanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   220
		"LC_TIME/day.macedonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   221
		"LC_TIME/day.nynorsk",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   222
		"LC_TIME/day.polish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   223
		"LC_TIME/day.portuguese",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   224
		"LC_TIME/day.romanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   225
		"LC_TIME/day.russian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   226
		"LC_TIME/day.slovakian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   227
		"LC_TIME/day.slovenian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   228
		"LC_TIME/day.spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   229
		"LC_TIME/day.swedish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   230
		"LC_TIME/day.turkish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   231
		"LC_TIME/day.yugoslavian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   232
		"LC_TIME/define.albanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   233
		"LC_TIME/define.austrian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   234
		"LC_TIME/define.bokmal",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   235
		"LC_TIME/define.bulgarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   236
		"LC_TIME/define.catalan",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   237
		"LC_TIME/define.col_spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   238
		"LC_TIME/define.croatian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   239
		"LC_TIME/define.czech",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   240
		"LC_TIME/define.danish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   241
		"LC_TIME/define.dutch",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   242
		"LC_TIME/define.english",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   243
		"LC_TIME/define.estonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   244
		"LC_TIME/define.finnish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   245
		"LC_TIME/define.french",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   246
		"LC_TIME/define.french_swiss",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   247
		"LC_TIME/define.german",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   248
		"LC_TIME/define.german_swiss",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   249
		"LC_TIME/define.greek",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   250
		"LC_TIME/define.hungarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   251
		"LC_TIME/define.icelandic",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   252
		"LC_TIME/define.italian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   253
		"LC_TIME/define.latvian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   254
		"LC_TIME/define.lithuanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   255
		"LC_TIME/define.macedonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   256
		"LC_TIME/define.nynorsk",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   257
		"LC_TIME/define.polish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   258
		"LC_TIME/define.portuguese",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   259
		"LC_TIME/define.romanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   260
		"LC_TIME/define.russian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   261
		"LC_TIME/define.slovakian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   262
		"LC_TIME/define.slovenian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   263
		"LC_TIME/define.spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   264
		"LC_TIME/define.swedish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   265
		"LC_TIME/define.turkish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   266
		"LC_TIME/define.yugoslavian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   267
		"LC_TIME/mon.albanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   268
		"LC_TIME/mon.austrian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   269
		"LC_TIME/mon.bulgarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   270
		"LC_TIME/mon.catalan",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   271
		"LC_TIME/mon.croatian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   272
		"LC_TIME/mon.czech",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   273
		"LC_TIME/mon.danish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   274
		"LC_TIME/mon.dutch",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   275
		"LC_TIME/mon.english",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   276
		"LC_TIME/mon.estonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   277
		"LC_TIME/mon.finnish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   278
		"LC_TIME/mon.french",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   279
		"LC_TIME/mon.german",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   280
		"LC_TIME/mon.greek",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   281
		"LC_TIME/mon.hungarian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   282
		"LC_TIME/mon.icelandic",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   283
		"LC_TIME/mon.italian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   284
		"LC_TIME/mon.latvian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   285
		"LC_TIME/mon.lithuanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   286
		"LC_TIME/mon.macedonian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   287
		"LC_TIME/mon.nynorsk",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   288
		"LC_TIME/mon.polish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   289
		"LC_TIME/mon.portuguese",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   290
		"LC_TIME/mon.romanian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   291
		"LC_TIME/mon.russian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   292
		"LC_TIME/mon.slovakian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   293
		"LC_TIME/mon.slovenian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   294
		"LC_TIME/mon.spanish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   295
		"LC_TIME/mon.swedish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   296
		"LC_TIME/mon.turkish",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   297
		"LC_TIME/mon.yugoslavian",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   298
	]
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   299
	if include in sub_includes:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   300
		includes = localedef_include_re_multiline.findall(result)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   301
		if len(includes) > 0:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   302
			for sub_include in includes:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   303
				sub_include_text = process_include(includesdir, sub_include)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   304
				result = result.replace("include %s\n" % sub_include, sub_include_text)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   305
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   306
	if result[-3:] == "\\c\n":
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   307
		log.debug("Stripping '\\c\\n' from '%s'" % include)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   308
		result = result[:-3]
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   309
	return result
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   310
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   311
usage = """%prog -d include_dir -i input_file -o output_file
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   312
"""
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   313
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   314
def main():
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   315
	parser = OptionParser(usage=usage)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   316
	parser.add_option("-i", "--input", action="store", type="string",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   317
		dest="input_filename", help="Input filename")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   318
	parser.add_option("-o", "--output", action="store", type="string",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   319
		dest="output_filename", help="Output filename")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   320
	parser.add_option("-d", "--includes", action="store", type="string",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   321
		dest="includes_directory", help="Directory containing include files")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   322
	parser.add_option("-v", "--verbose", action="store_true",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   323
		dest="verbose", default=0, help="Be more verbose")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   324
	parser.add_option("-q", "--quiet", action="store_false",
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   325
		dest="quite", help="Be quiet")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   326
	parser.add_option("", "--dummy", action="store_true", default=0,
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   327
		dest="dummy", help="Dummy mode, spit out an empty file (useful for build testing)")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   328
	(options, args) = parser.parse_args()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   329
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   330
	if options.verbose:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   331
		log.setLevel(logging.DEBUG) #set verbosity to show all messages of severity >= DEBUG
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   332
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   333
	log.info("Starting up")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   334
	input_lines = open(options.input_filename, "r").readlines()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   335
	output_fp = open(options.output_filename, "w")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   336
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   337
	if options.dummy:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   338
		log.info("Dummy mode")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   339
		output_fp.write("Dummy output\n")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   340
		output_fp.close()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   341
		log.info("Finished")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   342
		sys.exit(0)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   343
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   344
	for line in input_lines:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   345
		#log.debug("Processing line '%s'" % line)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   346
		includes = localedef_include_re.findall(line)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   347
		if len(includes) > 0:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   348
			include = includes[0]
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   349
			log.info("Processing include '%s'" % include)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   350
			include_text = process_include(options.includes_directory, include)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   351
			output_fp.write(include_text)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   352
		else:
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   353
			output_fp.write(line)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   354
	output_fp.close()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   355
	log.info("Finished")
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   356
	sys.exit(0)
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   357
	
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   358
if __name__ == "__main__":
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   359
	main()
542988ea726d initial version of Nevada G11N repository
simford
parents:
diff changeset
   360