Skip to content

Commit 369ec31

Browse files
committed
Read comment_char and escape_char from source file
Fixes #4
1 parent c70d27b commit 369ec31

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

bin/locale-extract-category

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ lines = ''
2222
for line in sys.stdin:
2323
lines += line
2424

25-
match = re.search(lc_section_pattern, lines, re.DOTALL)
26-
27-
# Lines below should be matched from lines too
28-
sys.stdout.write('comment_char %\n')
29-
sys.stdout.write('escape_char /\n')
30-
31-
if match:
32-
sys.stdout.write(match.group(1).lstrip('\n'))
25+
match_comment_char = re.search(COMMENT_CHAR_PATTERN, lines, re.MULTILINE)
26+
match_escape_char = re.search(ESCAPE_CHAR_PATTERN, lines, re.MULTILINE)
27+
match_category = re.search(lc_section_pattern, lines, re.DOTALL)
28+
29+
if match_comment_char:
30+
sys.stdout.write(match_comment_char.group(1) + '\n')
31+
if match_escape_char:
32+
sys.stdout.write(match_escape_char.group(1) + '\n')
33+
if match_category:
34+
sys.stdout.write(match_category.group(1).lstrip('\n'))
3335

3436
sys.exit(0)

glibc_locale_tools/glibc_locale_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
A re pattern to match a LC_* section (category, e.g. LC_TIME) in a locale file (e.g. nl_NL).
2727
"""
2828

29+
COMMENT_CHAR_PATTERN = r'^(comment_char\s+(.*))$'
30+
"""
31+
A re pattern to match a comment_char line.
32+
"""
33+
34+
ESCAPE_CHAR_PATTERN = r'^(escape_char\s+(.*))$'
35+
"""
36+
A re pattern to match a escape_char line.
37+
"""
38+
2939

3040
def unicode_decode(unicode_char):
3141
"""

glibc_locale_tools/test/data/da_DK.LC_TIME.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
comment_char %
2-
escape_char /
2+
escape_char /
33
abday "<U0073><U00F8><U006E>";"<U006D><U0061><U006E>";/
44
"<U0074><U0069><U0072>";"<U006F><U006E><U0073>";/
55
"<U0074><U006F><U0072>";"<U0066><U0072><U0065>";/

glibc_locale_tools/test/data/en_US.LC_TIME.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
comment_char %
2-
escape_char /
2+
escape_char /
33
abday "<U0053><U0075><U006E>";"<U004D><U006F><U006E>";/
44
"<U0054><U0075><U0065>";"<U0057><U0065><U0064>";/
55
"<U0054><U0068><U0075>";"<U0046><U0072><U0069>";/

0 commit comments

Comments
 (0)