File: pyindex2lower-utf8.py

package info (click to toggle)
serpento 0.4.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 360 kB
  • ctags: 391
  • sloc: python: 1,762; ansic: 669; perl: 157; sh: 122; makefile: 72
file content (19 lines) | stat: -rwxr-xr-x 481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python
# read stdin (as pyindex file) and transform entries into lowercase
# typical usage:
# konwert UTF8-ascii <file.index | pyindex2lower.py | sort > ascii-file.index

import sys
import string
from utils import TAB

while 1:
    l = sys.stdin.readline()
    if not l:
        break
    entry, rest = string.split(l, TAB, 1)
    entry = unicode(entry, 'utf-8')
    entry = entry.lower()
    entry = entry.encode('utf-8')
    l = entry+TAB+rest
    sys.stdout.write(l)