pyqode.python.backend package

Module contents

The backend package contains everything needed to implement the server side of a python editor.

Classes

JediCompletionProvider

class pyqode.python.backend.JediCompletionProvider

Bases: builtins.object

Provides code completion using the awesome jedi library

static complete(code, line, column, path, encoding, prefix)

Completes python code using jedi.

Returns:a list of completion.

Functions

calltips

pyqode.python.backend.calltips(request_data)

Worker that returns a list of calltips.

A calltips is a tuple made of the following parts:
  • module_name: name of the module of the function invoked
  • call_name: name of the function that is being called
  • params: the list of parameter names.
  • index: index of the current parameter
  • bracket_start

:returns tuple(module_name, call_name, params)

defined_names

pyqode.python.backend.defined_names(request_data)

Returns the list of defined names for the document.

goto_assignments

pyqode.python.backend.goto_assignments(request_data)

Go to assignements worker.

icon_from_typename

pyqode.python.backend.icon_from_typename(name, icon_type)

Returns the icon resource filename that corresponds to the given typename.

Parameters:name – name of the completion. Use to make the distinction between public and private completions (using the count of starting ‘_’)
Pram typename:the typename reported by jedi
Returns:The associate icon resource filename or None.

quick_doc

pyqode.python.backend.quick_doc(request_data)

Worker that returns the documentation of the symbol under cursor.

run_frosted

pyqode.python.backend.run_frosted(request_data)

Worker that run a frosted (the fork of pyflakes) code analysis on the current editor text.

run_pep8

pyqode.python.backend.run_pep8(request_data)

Worker that run the pep8 tool on the current editor text.

:returns a list of tuples (msg, msg_type, line_number)

Server script

Main server script for a pyqode.python backend. You can directly use this script in your application if it fits your needs or use it as a starting point for writing your own server.

usage: server.py [-h] [-s [SYSPATH [SYSPATH ...]]] port

positional arguments:
  port                  the local tcp port to use to run the server

optional arguments:
  -h, --help            show this help message and exit
  -s [SYSPATH [SYSPATH ...]], --syspath [SYSPATH [SYSPATH ...]]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main server script for a pyqode.python backend. You can directly use this
script in your application if it fits your needs or use it as a starting point
for writing your own server.

::

    usage: server.py [-h] [-s [SYSPATH [SYSPATH ...]]] port

    positional arguments:
      port                  the local tcp port to use to run the server

    optional arguments:
      -h, --help            show this help message and exit
      -s [SYSPATH [SYSPATH ...]], --syspath [SYSPATH [SYSPATH ...]]

"""
import argparse
import sys


if __name__ == '__main__':
    """
    Server process' entry point
    """
    # setup argument parser and parse command line args
    parser = argparse.ArgumentParser()
    parser.add_argument("port", help="the local tcp port to use to run "
                        "the server")
    parser.add_argument('-s', '--syspath', nargs='*')
    args = parser.parse_args()

    # add user paths to sys.path
    if args.syspath:
        for path in args.syspath:
            print('append path %s to sys.path' % path)
            sys.path.append(path)

    from pyqode.core import backend
    from pyqode.python.backend.workers import JediCompletionProvider

    # setup completion providers
    backend.CodeCompletionWorker.providers.append(JediCompletionProvider())
    backend.CodeCompletionWorker.providers.append(
        backend.DocumentWordsProvider())

    # starts the server
    backend.serve_forever(args)