Exemple #1
0
def main():
    import sys
    sys.path.append(sys.path[0]+'/../src/')

    import setting
    cnf = setting.main()

    for gloss in cnf.glossary_list:
        if "foss" in gloss['name']:
            break
    else:
        return False

    path = os.path.expanduser(gloss['path'])

    import core
    gloss = core.Glossary(path + 'en2ne/')

    liststore, ulta = gloss['numbers.tra']
    src = gloss.fullpath + 'numbers.tra'

    n2w = Adaptor(liststore, src)

    print(n2w.en.convert('1'))
    print(n2w.en.convert('12'))
    print(n2w.en.convert('123'))
    print(n2w.en.convert('1234'))
    print(n2w.en.convert('12345'))
    print(n2w.en.convert('123456'))
    print(n2w.en.convert('1234567'))
    print(n2w.ne.convert('12345679'))
    print(n2w.ne.convert('123456790'))
    print(n2w.ne.convert('०१२३४५६७८९1'))
Exemple #2
0
def main(core, cnf):
    win = Explorer(core, cnf)

    import setting

    global fonts
    cnf = setting.main()
    core.load_from_config(cnf)

    root = main(core, cnf)
    return root
Exemple #3
0
def sample():
    import sys
    sys.path.append(sys.path[0]+'/../')

    import setting
    from gi.repository import Pango

    root = main(setting.main())

    # in isolation testing, make Esc quit Gtk mainloop
    root.on_destroy = Gtk.main_quit
Exemple #4
0
def sample():
    pwd = sys.path[0]+'/../'
    sys.path.append(pwd)
    import setting
    cnf = setting.main(pwd)

    root = main(core, cnf)
    root.connect('delete-event', Gtk.main_quit)

    # in isolation testing, make Esc quit Gtk mainloop
    root.handle_esc = Gtk.main_quit
Exemple #5
0
    def do_startup(self):
        Gtk.Application.do_startup(self)

        self.cnf = setting.main(PWD)
        self.cnf.apply_args_request(self.opts)

        self.icon_theme = Gtk.IconTheme.get_default()
        self.pixbuf_logo = self.icon_theme.load_icon(
            'application-x-addon', 128,
            Gtk.IconLookupFlags.FORCE_SVG
        )
Exemple #6
0
def sample():
    pwd = sys.path[0]+'/../'
    sys.path.append(pwd)
    import setting
    import core
    core.fp3 = core.fp4 = open(os.devnull, 'w')

    cnf = setting.main(pwd)
    core.load_from_config(cnf)

    root = main(core, cnf)
    root.connect('delete-event', Gtk.main_quit)

    # in isolation testing, make Esc quit Gtk mainloop
    root.handle_esc = Gtk.main_quit
Exemple #7
0
    def do_startup(self):
        Gtk.Application.do_startup(self)
        self.commander = commander.Shell(self)
        self.commander.rc['version'] = lambda *a: str(__version__)
        self.commander.rc['help'] = lambda *a: self.on_help()

        self.cnf = setting.main(PWD)
        self.cnf.apply_args_request(self.opts)

        verify_mime(self.cnf)
        self.no_of_gloss = core.load_from_config(self.cnf)

        self.plugins = { k: v for k, v in scan_plugins(self.cnf) }

        self.icon_theme = Gtk.IconTheme.get_default()

        logo = self.icon_theme.load_icon(
            'accessories-dictionary', 128,
            Gtk.IconLookupFlags.FORCE_SVG
        )
        # NOTE: new 'accessories-dictionary' logo sucks, wtf aspect ratio
        self.pixbuf_logo = logo.scale_simple(128, 100, GdkPixbuf.InterpType.BILINEAR)
Exemple #8
0
import setting
import tap
import move
import display

from threading import Thread

s = setting.main()
if s.cfg_ok:
    all_key = []
    for i in range(s.keynum):
        all_key += [tap.key(*s.key_setting[i], **s.tap_setting)]
    akey = tap.allKey(**s.tap_setting)
    tap_main = tap.main(all_key, akey)
    move_main = move.main(20)
    dis_main = display.main(all_key, akey, move_main, s.keynum,
                            **s.dis_setting)

    bgtap_cal = Thread(target=tap_main.start)
    bgmove_cal = Thread(target=move_main.start)

    bgtap_cal.start()
    bgmove_cal.start()
    dis_main.start()
Exemple #9
0
            except Exception as e:
                print(e)
                # if not hasattr(e, 'meta_info'):
                # TODO robustness and show error in gui
                if not cnf.core['gloss-fix']:
                    n += 1
                    continue
                cmd = cnf.editor_goto_line_uri(*e.meta_info)
                # NOTE: we need something to hang on till we edit
                ## vvvv DON'T USES Popen vvvv
                if os.system(' '.join(cmd)): exit()
                print('RELOAD')
                continue
            n += 1
            count += 1
    return count


if __name__ == '__main__':
    import setting
    cnf = setting.main()

    load_from_config(cnf)

    from pprint import pprint
    pprint(Glossary.search('hello'))
    pprint(Glossary.search_hashtag('#color'))

    import doctest
    doctest.testmod()