コード例 #1
0
ファイル: pylint-leo.py プロジェクト: hanseychen/leo-editor
def main(tables_table):
    '''Call run on all tables in tables_table.'''
    if False and tables_table and sys.platform.startswith('win') and scope != 'file':
        g.cls()
    # Do these imports **after** clearing the screen.
    from pylint import lint
        # in pythonN/Lib/site-packages.
    t = 0.0
    for table, theDir in tables_table:
        for fn in table:
            t += run(theDir, fn)
    print('time: %5.2f sec.' % t)
コード例 #2
0
ファイル: pylint-leo.py プロジェクト: gilshwartz/leo-editor
def main(tables_table):
    
    if tables_table and sys.platform.startswith('win'):
        if False and scope != 'file':
            g.cls()
    # Do these imports **after** clearing the screen.
    from pylint import lint
        # in pythonN/Lib/site-packages.
    t1 = time.clock()
    for table,theDir in tables_table:
        for fn in table:
            run(theDir,fn)
    print('time: %s' % g.timeSince(t1))
コード例 #3
0
def main(tables_table, silent):
    '''Call run on all tables in tables_table.'''
    if False and tables_table and sys.platform.startswith(
            'win') and scope != 'file':
        g.cls()
    # Do these imports **after** clearing the screen.
    from pylint import lint
    # in pythonN/Lib/site-packages.
    t = 0.0
    for table, theDir in tables_table:
        for fn in table:
            t += run(theDir, fn, silent)
    print('time: %5.2f sec.' % t)
コード例 #4
0
ファイル: pylint-leo.py プロジェクト: jurov/leo-editor
def main(tables_table):

    if tables_table and sys.platform.startswith("win"):
        if False and scope != "file":
            g.cls()
    # Do these imports **after** clearing the screen.
    from pylint import lint

    # in pythonN/Lib/site-packages.
    t = 0.0
    for table, theDir in tables_table:
        for fn in table:
            t += run(theDir, fn)
    print("time: %5.2f sec." % t)
コード例 #5
0
def test_leo_client_and_server(event=None):
    """
    Test leoserver.py with leoclient.py.

    The test-all command does *not* run this command, because there is
    no corresponding test*.py file.
    """
    g.cls()
    leo_dir = os.path.abspath(os.path.join(g.app.loadDir, '..', '..'))
    assert os.path.exists(leo_dir), repr(leo_dir)
    os.chdir(leo_dir)
    g.execute_shell_commands(
        'start cmd /k "python -m leo.core.leoserver --trace=request,response,verbose"'
    )
    time.sleep(1.5)
    g.execute_shell_commands('start cmd /k "python -m leo.core.leoclient"')
コード例 #6
0
ファイル: pylint-leo.py プロジェクト: prodigeni/leo-editor
def main(tables_table):

    if tables_table and sys.platform.startswith('win'):
        if False and scope != 'file':
            g.cls()
            # os.system('cls')

    # Do these imports **after** clearing the screen.
    from pylint import lint
    # in pythonN/Lib/site-packages.

    t1 = time.clock()
    for table, theDir in tables_table:
        for fn in table:
            run(theDir, fn)
    if 0:
        print('astroid.bases.ekr_infer_stmts_items: %s' %
              astroid.bases.ekr_infer_stmts_items)
    print('time: %s' % g.timeSince(t1))
コード例 #7
0
ファイル: leoTips.py プロジェクト: ATikhonov2/leo-editor
def make_tips(c):
    """
    A script to make entries in the global tips array.
    
    Each printed entry has the form:
        
        UserTip(
            n=anInt
            tags=[list of tags],
            title=aString,
            text='''
            
            aString
            
            ''')
        
    After running this script, copy the result from the console to the
    <define tips> section of leoTips.py.
    """
    import requests
    url = 'https://api.github.com/repos/leo-editor/leo-editor/issues?labels=Tip&state='

    def get_tips(data):
        """get_tips - get tips from GitHub issues
        :param dict data: GitHub API issues list
        :return: list of Tips
        """
        tips = []
        for issue in data:
            body, n, title = issue['body'], issue['number'], issue['title']
            lines = g.splitLines(body)
            for i, s in enumerate(lines):
                if s.strip().lower().startswith('tags:'):
                    lines = lines[:i] + lines[i + 1:]
                    text = ''.join(lines).strip()
                    s = s.strip().rstrip('.').strip()
                    s = s[len('tags:'):].strip()
                    tags = [z.strip() for z in s.split(',')]
                    break
            else:
                tags = []
                text = body.strip()
            tips.append(
                UserTip(
                    n=n,
                    tags=tags,
                    text=text.strip(),
                    title=title.strip(),
                ))
        return tips

    g.cls()
    template = '''\
UserTip(
    n=%s,
    tags=%s,
    title="%s",
    text="""\
    
%s

"""),
'''
    template = g.adjustTripleString(template, c.tab_width)
    for kind in ('open', ):  # 'closed':
        data = requests.get(url + kind).json()
        for tip in get_tips(data):
            tags = [f"{z}" for z in tip.tags or []]
            title = tip.title.lstrip('Tip:').lstrip('tip:').strip()
            print(template % (tip.n, tags, title, tip.text))
コード例 #8
0
def test(c):
    g.cls()
    t1 = time.time()
    RopeController(c).run()
    print('done: %s sec.' % g.timeSince(t1))
コード例 #9
0
ファイル: miniTkLeo.py プロジェクト: leo-editor/leo-model
def main(fname):
    #@+others
    #@+node:vitalije.20180518114847.1: *3* create_app
    def create_app():
        app = Tk()
        app.columnconfigure(0, weight=1)
        app.rowconfigure(0, weight=1)
        # Adjust fonts
        font.nametofont('TkFixedFont').config(size=18)
        font.nametofont('TkTextFont').config(size=18)
        font.nametofont('TkDefaultFont').config(size=18)
        return app

    #@+node:vitalije.20180518114953.1: *3* create_gui
    def create_gui(app):

        f1 = PanedWindow(
            app,
            orient='horizontal',
            width=800,
            height=600,
            sashrelief='ridge',
            sashwidth=4,
        )
        f1.grid(
            row=0,
            column=0,
            sticky="nesw",
        )
        f2 = PanedWindow(f1, orient='vertical')
        canvW = Canvas(f2, bg='#113333')
        f2.add(canvW)
        logW = scrolledtext.ScrolledText(f2,
                                         bg='#223399',
                                         fg='#cccc99',
                                         font=font.nametofont('TkDefaultFont'))
        f2.add(logW)
        bodyW = makeBodyW(f1)
        f1.add(f2)
        f1.add(bodyW)
        return f1, f2, bodyW, canvW, logW

    #@+node:vitalije.20180518114840.1: *3* load_xml
    def load_xml(fname):
        ltm = loadLeo(fname)
        ltm.selectedPosition = ltm.positions[1]
        ltmbytes = ltm.tobytes()
        return ltm, ltmbytes

    #@+node:vitalije.20180518115038.1: *3* start_thread & helper functions
    def start_thread(app, f1, f2, ltmbytes):

        #@+others
        #@+node:ekr.20180530110733.1: *4* f_later
        def f_later():
            f1.sash_place(0, 270, 1)
            f2.sash_place(0, 1, 350)
            app.geometry("800x600+120+50")
            app.wm_title(fname)
            app.after_idle(update_model)

        #@+node:ekr.20180530110731.1: *4* loadex (collects stats)
        def loadex():
            '''The target of threading.Thread.'''
            if profile_load:  # Profile the code.
                cProfile.runctx(
                    'loadex_helper()',
                    globals(),
                    locals(),
                    'profile_stats',  # 'profile-%s.out' % process_name
                )
                print('===== writing profile_stats')
                p = pstats.Stats('profile_stats')
                p.strip_dirs().sort_stats('tottime').print_stats(50)
                # .print_stats('leoDataModel.py', 50)
            else:
                loadex_helper()

        def loadex_helper():
            ltm2 = LeoTreeModel.frombytes(ltmbytes)
            loaddir = os.path.dirname(fname)
            loadExternalFiles(ltm2, loaddir)
            G.q.put(ltm2)

        #@+node:ekr.20180530110733.2: *4* update_model
        def update_model():
            try:
                m = G.q.get(False)
                ltm.positions = m.positions
                ltm.nodes = m.nodes
                ltm.parPos = m.parPos
                ltm.levels = m.levels
                ltm.attrs = m.attrs
                ltm.gnx2pos = m.gnx2pos
                draw_tree(G.tree, ltm)
                tend = time.monotonic()
                t1 = (tend - tstart)
                if bridge:
                    logW.insert('end', '***Bridge loaded***\n')
                logW.insert('end', 'External files loaded in %.3fs\n' % t1)
            except queue.Empty:
                app.after(100, update_model)

        #@-others
        threading.Thread(target=loadex, name='externals-loader').start()
        app.after_idle(f_later)

    #@-others
    c = None
    if bridge:
        import leo.core.leoBridge as leoBridge
        controller = leoBridge.controller(
            gui='nullGui',
            loadPlugins=False,
            readSettings=False,
            silent=False,  # Print signons, so we know why loading is slow.  
            verbose=False,
        )
        g = controller.globals()
        c = controller.openLeoFile(fname)
        g.trace(c)
    else:
        import leo.core.leoGlobals as g
        g.cls()
    #
    tstart = time.monotonic()
    ltm, ltmbytes = load_xml(fname)
    app = create_app()
    f1, f2, bodyW, canvW, logW = create_gui(app)
    start_thread(app, f1, f2, ltmbytes)
    return bunch(
        c=c,  # EKR
        g=g,  # EKR
        ltm=ltm,
        app=app,
        tree=canvW,
        body=bodyW,
        log=logW,
        q=queue.Queue(1),
        topIndex=IntVar())
コード例 #10
0
ファイル: leoRope.py プロジェクト: Darriall/leo-editor
def test(c):
    g.cls()
    t1 = time.clock()
    RopeController(c).run()
    print('done: %s sec.' % g.timeSince(t1))
コード例 #11
0
def make_tips(c):
    '''
    A script to make entries in the global tips array.
    
    Each printed entry has the form:
        
        UserTip(
            n=anInt
            tags=[list of tags],
            title=aString,
            text="""
            
            aString
            
            """)
        
    After running this script, copy the result from the console to the
    <define tips> section of leoTips.py.
    '''
    import requests
    url = 'https://api.github.com/repos/leo-editor/leo-editor/issues?labels=Tip&state='
    
    def get_tips(data):
        """get_tips - get tips from GitHub issues
        :param dict data: GitHub API issues list
        :return: list of Tips
        """
        tips = []
        for issue in data:
            body, n, title = issue['body'], issue['number'], issue['title']
            lines = g.splitLines(body)
            for i, s in enumerate(lines):
                if s.strip().lower().startswith('tags:'):
                    lines = lines[:i] + lines[i+1:]
                    text = ''.join(lines).strip()
                    s = s.strip().rstrip('.').strip()
                    s = s[len('tags:'):].strip()
                    tags = [z.strip() for z in s.split(',')]
                    break
            else:
                tags = []
                text = body.strip()
            tips.append(
                UserTip(
                    n=n,
                    tags=tags,
                    text=text.strip(),
                    title=title.strip(),
                ))
        return tips
    
    g.cls()
    template = '''\
UserTip(
    n=%s,
    tags=%s,
    title="%s",
    text="""\
    
%s

"""),
'''
    template = g.adjustTripleString(template, c.tab_width)
    for kind in ('open',): # 'closed':
        data = requests.get(url+kind).json()
        for tip in get_tips(data):
            tags = ["%s" % (z) for z in tip.tags or []]
            title = tip.title.lstrip('Tip:').lstrip('tip:').strip()
            print(template % (tip.n, tags, title, tip.text))
コード例 #12
0
ファイル: leoRope.py プロジェクト: xdvrx1/leo-editor
def test(c):
    g.cls()
    t1 = time.time()
    RopeController(c).run()
    print(f"done: {g.timeSince(t1)} sec.")