GithubHelp home page GithubHelp logo

orestis / pysmell Goto Github PK

View Code? Open in Web Editor NEW
259.0 8.0 19.0 722 KB

PySmell is an attempt to create an IDE completion helper for python.

Home Page: http://code.google.com/p/pysmell/

Vim Script 1.83% Emacs Lisp 3.28% Python 94.90%

pysmell's Introduction

#PySmell

PySmell is a python IDE completion helper.

It tries to statically analyze Python source code, without executing it, and generates information about a project's structure that IDE tools can use.

There is currently support for Vim, Emacs and TextMate. Feel free to contribute your own favourite editor bindings, or to improve the existing ones.

##Download and Installation

PySmell is available at PyPI. The best way to install PySmell is by downloading the source distribution and doing python setup.py install. While easy_install pysmell also works, I haven't yet found a way of distributing the editor scripts with it (suggestions welcome).

You should be able to import pysmell inside your Python interpreter and invoke pysmell at the command line.

You can track the development of PySmell by visiting GitHub. You can click 'Download' to get it as a zip/tar if you don't have git installed. python setup.py develop will setup your enviroment.

##Usage

Before you invoke PySmell, you need to generate a PYSMELLTAGS file:

cd /root/of/project
pysmell .

If you want to specifically include or exclude some files or directories (eg. tests), you can use:

pysmell [Package Package File File ...] [-x Excluded Excluded ...]

Check for more options by invoking pysmell without any arguments

##Using external libraries

PySmell can handle completions of external libraries, like the Standard Library and Django.

To use external libraries, you have to first analyze the libraries you want, eg. for stdlib:

pysmell . -x site-packages test -o ~/PYSMELLTAGS.stdlib

This will create PYSMELLTAGS.stdlib in your HOME. Copy that in the root of your project, and repeat for other libraries by changing the extension. Note that you still have to have a root PYSMELLTAGS file with no extension at the very root of your project.

##Partial tags

Sometimes it's useful to not pollute global namespaces with tags of sub-projects. For example, assume that there is a Tests package, which has hundreds of tests, together with a few testing-related modules. You only want to see these completions when working on test file.

To accomplish that, you can put PYSMELLTAGS.* files inside subdirectories, and they will be used only when you're working on a file somewhere in that directory or its children.

pysmell Tests/FunctionalTest.py Tests/UndoTestCase.py -o Tests/PYSMELLTAGS.Tests

The information in FunctionalTest and UndoTestCase will only be accessible when editing a file inside the Tests package.

##Vim

To use PySmell omnicompletion from inside Vim, you have to have:

  1. Python support in vim (:echo has('python'))
  2. The pysmell package in the PYTHONPATH that Vim uses: python import pysmell should work.
  3. Drop pysmell.vim in ~/.vim/plugin
  4. :setlocal omnifunc=pysmell#Complete Note: If you want to always use pysmell for python, do: autocmd FileType python setlocal omnifunc=pysmell#Complete
  5. [OPTIONAL] Select a matcher of your liking - look at pysmell.vim for options. Eg: :let g:pysmell_matcher='camel-case'

You can then use ^X^O to invoke Vim's omnicompletion.

You can generate debugging information by doing:

:let g:pysmell_debug=1
:e PYSMELL_DEBUG

Debug information will be appended in that buffer, copy and paste it into the report.

##TextMate

Double-click PySmell.tmbundle :)

Complete with alt-esc - look into the bundle for more commands.

You can find the bundle in the source distribution - it's not installed with the egg, because it's too much trouble.

Set TM_PYTHON in your Shell Variables to point to the Python where you installed PySmell.

##Emacs

Put pysmell.el into your load-path, and inside your .emacs file put:

(require 'pysmell)
(add-hook 'python-mode-hook (lambda () (pysmell-mode 1)))

Complete with M-/, create tags with M-x pysmell-make-tags

Pymacs is required as well.

##Reporting issues

PySmell is hosted at Google Code.

Look in the issues list first. Star issues that you feel strongly about, or create your own.

If you can create a unit test that exposes that behaviour, it'd be great!

pysmell's People

Contributors

frac avatar goj avatar mthalmei avatar orestis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysmell's Issues

SyntaxError: Missing parentheses in call to 'print' when installing?

When running

me@my-mbp pysmell-0.7.3 % python3 setup.py install

I received this error

 File "/Users/andrei/Downloads/pysmell-0.7.3/setup.py", line 27
    print post_install_message
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(post_install_message)?

I am new to python and I just installed python3 on Catalina via brew.

I am presuming I'm doing something wrong or missing something as it is unlikely for the package to be un-installable.

Could someone point me in the right direction to successfully installing pysmell?

Thank you!

Error detected while processing /Users/user_name/.vim/bundle/pysmell/pysmell.vim:

I should note first, this issue occurs on Mac, not Linux. Presently, I'm using OS X (10.8.2), I cannot speak for any other OS X versions.

When opening any python script, the file opens for editing as you would expect:

$ vi setup.py 

When opening any python script using sudo on a Mac, it opens but with an error:

$ sudo vi setup.py 
Error detected while processing /Users/user_name/.vim/bundle/pysmell/pysmell.vim:
line   41:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named pysmell
Press ENTER or type command to continue

The error does not hinder editing of the file, pressing ENTER again leads to expected editing and saving behavior. It's just irritating.

NOTE1: I've followed the prescribed method for using sudo on OS X:

  1. Add my user to the Admin group
  2. sudo visudo (and modify line to)
    %admin ALL=(ALL) NOPASSWD: ALL
    so I wouldn't get nagged for a password.

NOTE2:
I'm using MacVim (MacPorts; next time I'll use the binary - I already know) with some expected exports/aliases:

$ cat .bash_profile 
source "$HOME/.bashrc"

$ grep vim .bashrc
alias vi='/opt/local/bin/mvim -v'
alias vim='/opt/local/bin/mvim -v'
export EDITOR='/opt/local/bin/mvim -v'

I'm not sure why this is happening or if it's even something that can/should be fixed. It doesn't happen on Linux so the severity is somewhat low.

As I have seen no mention of this issue in the wild I assume there is a fix and it's just "known" somehow. In the case anyone else runs into it, it will be documented here.

Cheers,

TT

[Request] VIM: load tags from predefined folder

It would be nice if the Vim plugin loaded tags from a predefined folder and don't issue error message if the PYSMELLTAGS is missing. This way you can open a simple foo.py file inside your Desktop and have completions for all tags in that predefined folder.

I've written a patch which does this by defining another variable named g:pysmell_extradir which is searched for extra pysmell tags files.

diff -r 2ff3d6dee548 pysmell.vim
--- pysmell.vim Sat Feb 12 15:29:32 2011 -0200
+++ pysmell.vim Sun Feb 13 14:09:01 2011 -0200
@@ -32,9 +32,13 @@
 if !exists('g:pysmell_matcher')
     let g:pysmell_matcher='case-insensitive'
 endif
+if !exists('g:pysmell_extradir')
+    let g:pysmell_extradir=$HOME.'/.vim/python.tags.d'
+endif

 python << eopython
 from pysmell import vimhelper, idehelper
+from dircache import listdir
 import vim
 import string
 TRANSLATEQUOTES = string.maketrans("\'\"", "\"\'")
@@ -73,8 +77,12 @@
 def vimcompletePYSMELL(origSource, origLineNo, origCol, base):
     fullPath = vim.current.buffer.name
     PYSMELLDICT = idehelper.findPYSMELLDICT(fullPath)
+    extradir = vim.eval('g:pysmell_extradir')
     if not PYSMELLDICT:
-        vim.command("echoerr 'No PYSMELLTAGS found. You have to generate one.'")
+        PYSMELLDICT = {}
+    for tagsfile in listdir(extradir):
+        idehelper.tryReadPYSMELLDICT(extradir, tagsfile, PYSMELLDICT)
+    if len(PYSMELLDICT) == 0:
         return

     try:

README -> README.md

You will likely want to rename README to README.md. Just recognized ## syntax, thus rename will cure :)

Application Addon for GNOME Software

To give pysmell a bit more visibility in Fedora, I'd like to provide Application Addon metadata for Gnome Software [1]. According to the AppData specifications, I am going to add following metadata into our package:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Athos Ribeiro <[email protected]> -->
<component type="addon">
  <id>vim-pysmell</id>
  <extends>gvim.desktop</extends>
  <name>pysmell</name>
  <summary>PySmell is a python IDE completion helper</summary>
  <url type="homepage">https://code.google.com/p/pysmell/</url>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>BSD</project_license>
  <updatecontact>[email protected]</updatecontact>
</component>

Would you be willing to accept such file into official sources? That would also benefit other Linux distributions/desktop environments using AppData [2]

See [3] for related issue in command-T

[1] https://fedoraproject.org/wiki/Packaging:AppData#.metainfo.xml_file_creation
[2] http://blogs.gnome.org/hughsie/2014/06/11/application-addons-in-gnome-software/
[3] wincent/command-t#99

[request] make pysmell runnable in-place

Right now it's almost possible to use the tagged .tgz without installing or manually moving anything. The only manual steps I had to do were:

  • make a symlink at bin/pysmell linking to ../pysmell/tags.py, so that bin/ may be added to $PATH
  • put pysmell.vim into a subfolder ending in "/plugin/pysmell.vim", so that the path may be appended to vim's runtimepath (using pathogen, for example)

If it's not too much effort, it would be great if this could be done to the source here, so that the tagged revisions downloadable from github could be used without manually having to do this stuff (or install anything).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.