Exemplo n.º 1
0
grepcmd = " | ".join(
    grepcmds) + " | uniq | head -n 499 | perl -pe 's/^([^;]+?;.+?);.*/$1/'"

suggestions = os.popen(grepcmd).read().decode("utf-8")

if not suggestions:
    print "<i><small>Nothing found</small></i>"
    os.popen("rm -f /tmp/TM_db.busy 2&>/dev/null")

# print suggestions
print "<p class='res'>"
cnt = 0
for i in suggestions.splitlines():
    cnt += 1
    c, n = i.strip().split(';')
    t = ""
    if "COMBINING" in n or "HEBREW MARK" in n or "HEBREW ACCENT" in n or "HEBREW POINT" in n or "LAO TONE" in n or "LAO VOWEL" in n or "LAO SEMIVOWEL" in n or "LAO CAN" in n or "LAO NIG" in n:
        t = u"<small>◌</small>"
    print "<span onclick='insertChar(this)' onmouseout='clearName()'; onmouseover='showName(\"U+%s : %s\")' class='char'>%s%s</span> " % (
        c, n, t, wunichr(int(c.strip(), 16)))

pl = ""
if cnt > 1: pl = "es"
if cnt > 498:
    print "</p><i><small>More than 500 matches found. Please narrow down.</small></i>"
else:
    print "</p><i><small>" + str(cnt) + " match" + pl + "</small></i>"

os.popen("rm -f /tmp/TM_db.busy 2&>/dev/null")
Exemplo n.º 2
0
    sys.exit(206)

if len(sys.argv) != 2:
    print "No argument given!"
    sys.exit(206)

source = sys.argv[1]
if not os.path.exists(bundleLibPath + source + ".txt"):
    print "Source does not exist."
    sys.exit(206)

line, x = os.environ["TM_CURRENT_LINE"], int(os.environ["TM_LINE_INDEX"])
if not x: sys.exit(200)
inputleft = list(codepoints(unicode(line[:x], "UTF-8")))
tail = unicode(line[x:], "UTF-8")
char = wunichr(inputleft[-1])
head = inputleft[:-1]

# get the suggestion for 'char' by using grep against source.txt
frel = open(bundleLibPath + source + ".txt", "rb")
reldata = frel.read().decode("UTF-8")
frel.close()
for part in reldata.splitlines():
    if char in part: break
if not part:
    print "Nothing found for: U+" + "%04X " % int(inputleft[-1]) + char + "."
    sys.exit(206)

if pyversion > 250:
    suggestions = list(set(codepoints(part)))
else:
Exemplo n.º 3
0
if not (direction == 'toFull' or direction == 'toHalf'):
    print "Wrong argument. Only 'toFull' or 'toHalf'."
    sys.exit(206)

text = sys.stdin.read()

convData = codecs.open( bundleLibPath +"HanZenKaku.txt", "r", "UTF-8" )
halffull = convData.read().strip()

if not halffull:
    print "File error for HanZenKaku.txt"
    sys.exit(206)

conv = {}

for c in halffull.splitlines():
    half, full = c.split('\t')
    if direction == 'toFull':
        conv[half] = full
    else:
        conv[full] = half

for c in codepoints(text):
    try:
        half = conv[wunichr(c)]
        sys.stdout.write(half)
    except KeyError:
        sys.stdout.write(wunichr(c))

sys.exit(201)
    if pat:
        grepcmds.append("zgrep -E '^[^;]+?;[^;]*?%s%s%s[^;]*?;' '%s%s'" % (grepopt, pat, grepopt, bundleLibPath, sourceFile))

grepcmd = " | ".join(grepcmds) + " | uniq | head -n 499 | perl -pe 's/^([^;]+?;.+?);.*/$1/'"

suggestions = os.popen(grepcmd).read().decode("utf-8")

if not suggestions:
    print "<i><small>Nothing found</small></i>"
    os.popen("rm -f /tmp/TM_db.busy 2&>/dev/null")

# print suggestions
print "<p class='res'>"
cnt = 0
for i in suggestions.splitlines():
    cnt += 1
    c, n = i.strip().split(';')
    t = ""
    if "COMBINING" in n or "HEBREW MARK" in n or "HEBREW ACCENT" in n or "HEBREW POINT" in n or "LAO TONE" in n or "LAO VOWEL" in n or "LAO SEMIVOWEL" in n or "LAO CAN" in n or "LAO NIG" in n:
        t = u"<small>◌</small>"
    print "<span onclick='insertChar(this)' onmouseout='clearName()'; onmouseover='showName(\"U+%s : %s\")' class='char'>%s%s</span> " % (c, n, t, wunichr(int(c.strip(),16)))

pl = ""
if cnt > 1: pl = "es"
if cnt>498:
    print "</p><i><small>More than 500 matches found. Please narrow down.</small></i>"
else:
    print "</p><i><small>"+str(cnt)+" match"+pl+"</small></i>"

os.popen("rm -f /tmp/TM_db.busy 2&>/dev/null")
Exemplo n.º 5
0
if len(sys.argv) != 2:
    print "No argument given!"
    sys.exit(206)

source = sys.argv[1]
if not os.path.exists(bundleLibPath + source + ".txt"):
     print "Source does not exist."
     sys.exit(206)


line, x = os.environ["TM_CURRENT_LINE"], int(os.environ["TM_LINE_INDEX"])
if not x: sys.exit(200)
inputleft = list(codepoints(unicode(line[:x], "UTF-8")))
tail = unicode(line[x:], "UTF-8")
char = wunichr(inputleft[-1])
head = inputleft[:-1]

# get the suggestion for 'char' by using grep against source.txt
frel = open(bundleLibPath + source + ".txt", "rb")
reldata = frel.read().decode("UTF-8")
frel.close()
for part in reldata.splitlines():
    if char in part: break
if not part:
    print "Nothing found for: U+" + "%04X " % int(inputleft[-1]) + char + "."
    sys.exit(206)

if pyversion > 250:
    suggestions = list(set(codepoints(part)))
else: