ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Py​Rock

Sublime Text plugin to generate python import statements

Details

Installs

  • Total 73
  • Win 37
  • Mac 20
  • Linux 16
Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

PyRock

Sublime Text Plugin Download Code Coverage Contributors Stargazers Issues Release


Sublime plugin to generate import statement for python

Features

  • Generate's Import statement
  • Supports virtual enviroment

Upcoming Features

  • AI autocomplete
  • Copy python import statement (module, class, method)
  • Copy python path (module)
  • Copy unittest path (module, class, method)

Installation

  • From sublime package control install package enter name PyRock
  • OR
  • Clone this git repo and put it in your sublime packages folder

Settings

{
    "paths_to_scan": [], // Not used as of now
    "python_venv_path": "",
    "python_interpreter_path": "", // Not used as of now
    "log_level": "info",
    "import_scan_depth": 4
}
  • paths_to_scan: This is still in development, it will have no effect as of now.
  • python_interpreter_path: This is still in development, it will have no effect as of now.
  • python_venv_path : Specifies which python env to use when indexing files, if not given it will choose the default python interpreter of your system (Make sure you have set any default python, otherwise it will not be able to index). It takes the full path to activate file of the virtual environment, for example:
"python_venv_path": "~/home/venv/bin/activate"
  • log_level: By default set to info, accepted values info, debug, error, warning
  • import_scan_depth: This defines how deep it will scan any python package, the higher the number the more deep it will go, 4 is an optimal depth, you can increase it but it will also increase the time to index all files, so change it carefully.

Usage

  • Upon installation it automatically reads the settings and scans your python environment for packages and index them. You will see progress of indexing in status bar, like this:
    Indexing progress

  • For some reason if indexing didn't happened or you want to re-index after you have removed/installed packages in your python environment, you can do so by calling Re-Index Imports from command pallate or just right-click to open menu and under PyRock you will see Re-Index Imports
    Re-index

  • To generate python import, select the text (min 2 characters) then right click and under PyRock click Import Symbol, it will show you the suggestion out which you select any and it will add that import statement into your python script. Import symbol import suggestions

Key Bindings

  • By default key bindings for this plugin are disabled, to enable it you simply goto Preferences -> Package Settings -> PyRock -> Key Bindings and then copy paste from left view to your right view and uncomment it or you can copy the below directly to your right view and save it:
[
  // Both of the key binding generate import statement suggestions for the selected text
  {
    "keys": ["super+shift+;"],
    "command": "py_rock",
    "args": { "action": "import_symbol" }
  },
  {
    "keys": ["ctrl+shift+;"],
    "command": "py_rock",
    "args": { "action": "import_symbol" }
  }
]

Compatibility

  • Require Sublime Text version >= 4
  • Works for Python Imports only
  • Best experience with linter support [Optional]