Beispiel #1
0
def hello(a,b):
    # ret = ''.join([chr(c) for c in range(a,a+min(b-a, 500))])
    segments = cut([
        classify(chr(c))
        for c in range(a,b)], 30)
    # ret = '<br/>'.join([''.join(a) for a in segments])
    ret = '<br/>'.join([''.join(a) for a in segments])

    # js_map = {chr(c): uname(chr(c)) for c in range(a,b)}
    js_map = {}

    for c in range(a,b):
        try:
            name = uname(chr(c))
        except ValueError:
            name = "no value found"
        js_map[chr(c)] = "u+"+hex(c)+" "+name

    js_map_str = "char_names = %s"%repr(js_map)
    return html(
        head(style)
        +body(
            div('','id="tooltip"')
            +ret
            +script2(js_map_str)
            +script("tooltip.js")
            +script("post_char.js")
            +script("simple-ajax.js")
            )
        )
Beispiel #2
0
 def __init__(self, codepoint):
     self.char = unichr(codepoint)
     self.hex = '%04x' % codepoint
     self.dec = codepoint
     self.entity = '&#x%x;' % codepoint
     try:
         self.name = uname(self.char)
         self.category = category(self.char)
     except ValueError:
         pass
Beispiel #3
0
def fds():
    print(uniblock[0])
    intervals = {(i[0], i[1]):i[2] for i in uniblock}
    chars = ''
    # chars = open("unicode-favchars.txt", encoding="utf-8").read()+additions
    chars += open("unicode-favchars2.txt", encoding="utf-8").read()

    chars = list(set(chars))
    # f = open("unicode-sorted.txt", encoding="utf-8")
    things = {}
    for c in chars:
        # cat = unicodedata.category(c)
        
        # dig = unicodedata.digit(c)
        categ, categ_name = interval_find(ord(c),intervals)
        cat = categ_name

        if not cat in things: things[cat]=[]
        things[cat].append(c)
    # return '<br/>'.join(
    #     [cat+' '.join(
    #         [c for c in things[cat]]
    #         ) for cat in things]
    #     )
    js_map={}
    for c in chars:
        try:
            name = uname(c)
        except ValueError:
            name = "no value found"
        js_map[c] = "u+"+hex(ord(c))+" "+name

    js_map_str = "char_names = %s"%repr(js_map)

    made = table(''.join(
        [tr([cat,' '.join([classify(c) for c in things[cat]])])
            for cat in things])
        )


    return html(
        head(style)
        +body(
            div('','id="tooltip"')
            # +tag3(' '.join(chars), div)
            +tag3(multiline(sorted(chars), 20), 'div', 'style="font-size:3em"')
            +made
            +script2(js_map_str)
            +script("tooltip.js")
            +script("post_char.js")
            +script("simple-ajax.js")
            )
        )
Beispiel #4
0
def units_of_filename(fn):
    unit = ''
    for char in fn:
        if char not in okay:
            if unit:
                yield unit
                unit = ''
            yield uname(char).replace(' ', '-')
        else:
            unit += char
    if unit:
        yield unit
Beispiel #5
0
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('-w', '--width', type=int, default=1)
parser.add_argument('files', nargs='*')
args = parser.parse_args()
files = args.files
if not files:
    files.append('-')
w=args.width
CC = Counter() 
for fn in files:
    if fn=='-':
        f = stdin
    else:
        f = open(fn)
    for line in f:
        if w==1:
             CC.update(line)
        else:
             for i in range(len(line)-w):
                 CC[line[i:i+w]] += 1

for (char, count) in CC.most_common():
    if w==1:
        print("<%c>: %s[%d]: %d" % (char, uname(char,"***UNKNOWN***"), ord(char), count))
    else:
        print("<%s>: %d" % (char, count))


Beispiel #6
0
def isMeemOrYeh(x):
    nm = uname(x)
    return MEEM in nm or YEH in x
Beispiel #7
0
def uName(c):
    try:
        un = uname(c)
    except Exception:
        un = "NO NAME"
    return un