Skip to main content

Mr. Igor provides the parts you need to build your Frankenprogram.

Project description

Overview

mr.igor is an extension to pyflakes that will learn where you import things from, and then automatically fill in missing imports from the place they are most often imported.

But how does it know?

“It’th a knack.”

Usage: igor [–print | –reap] filename

This script will record all imports from filename in Igor’s database, and then add imports at the top of the file for any names that were not imported but were found in the database.

If the –print option is specified then the rewritten file will be written to stdout. (This allows the use of igor as a filter for editors.) Otherwise the file will be modified inplace.

If the –reap option is specified then imports will be added to the database from the specified file, but nothing will be written to stdout and the file will not be modified.

Only “from x import y” style imports are tracked and inserted. Aliases (“from x import y as z”) are not supported.

mr.igor stores its database in ~/.mr.igor.db.

Usage with TextMate

Go to the TextMate Bundle Editor and add a new command with the following settings:

Save

Current File

Command(s)
#!/bin/bash
igor --print $TM_FILEPATH
Input

None

Output

Replace Document

Activation

Key Equivalent: ⌘I

Scope Selector

source.python

Now you can save the current file and run it through Igor using the ⌘I keyboard shortcut.

Usage with Vim

The following key mapping will configure ⌘I to run the current file through Igor and then reload the current buffer:

nmap <D-i> :!igor %<CR> <bar> :e!<CR>

Changelog

2011/10/2

  • Released version 1.3. [davisagli]

  • Insert imports after initial set of comments, to fix issue when PEP0263 encoding is declared in python files. [naro]

  • Updated to be compatible with (and require) pyflakes 0.5. Tested with Python 2.6 and 2.7. [davisagli]

2010/1/7

  • Released version 1.2. [davisagli]

  • Added –reap option. [davisagli]

2009/12/14

  • Added usage info for integration with Vim. Thanks to Stephan Eletzhofer. [davisagli]

  • Released version 1.1. [davisagli]

  • Fix issue where a syntax error would cause the file to be clobbered when using print mode as a filter. [davisagli]

  • Fix issue where print mode would not print anything if no new imports were found. [davisagli]

  • Fix issue where multiple imports in the same line were not recorded. [davisagli]

  • Released version 1.0. [davisagli]

  • Added functional test. [davisagli]

  • Refactor to improve testability; avoid monkeypatching. [davisagli]

2009/12/13

  • Add help for console script. [davisagli]

  • Use ~/.mr.igor.db as default database location. [davisagli]

  • Added –print option. [davisagli]

  • Added igor console script. [davisagli]

2009/12/12

  • Initial proof-of-concept. [davisagli]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mr.igor-1.3.zip (11.2 kB view details)

Uploaded Source

File details

Details for the file mr.igor-1.3.zip.

File metadata

  • Download URL: mr.igor-1.3.zip
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mr.igor-1.3.zip
Algorithm Hash digest
SHA256 faeb00486d425b755b0f4052c55b3ee1faf4255ed0124bb9046334282a9eeb48
MD5 7ca46f1a5d004bcaa6012bc52fe1e83c
BLAKE2b-256 45bdfeb4203f90755a599f18db4e270ae2680068d53444b00e0ef3ee31d5439d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page