├── .netrwhist ├── Changelog.rst ├── Makefile ├── README.md ├── README.rst ├── after └── ftplugin │ └── python.vim ├── autoload ├── pathogen.vim ├── pymode.vim └── pymode │ ├── breakpoint.vim │ ├── doc.vim │ ├── folding.vim │ ├── lint.vim │ ├── motion.vim │ ├── queue.vim │ ├── run.vim │ ├── troubleshooting.vim │ └── virtualenv.vim ├── bundle ├── vim-colorselector │ └── plugin │ │ └── colorselector.vim └── vim-mxml │ └── syntax │ ├── dtd.vim │ └── mxml.vim ├── colors ├── github.vim ├── ir_black.vim ├── mayansmoke.vim ├── pyte.vim ├── rails_envy.vim ├── railscasts.vim ├── solarized_dark.vim ├── solarized_light.vim ├── sorcerer.vim ├── wombat.vim └── zenburn.vim ├── doc ├── NERD_tree.txt ├── pymode.txt ├── ropevim.txt ├── taglist.txt └── tags ├── easy-vimrc ├── experimental-vimrc ├── ftplugin └── python │ └── pymode.vim ├── gvimrc ├── indent └── verilog.vim ├── plugin ├── NERD_tree.vim ├── after │ └── ftdetect │ │ └── FileTypes.vim ├── pymode.vim ├── settings │ ├── Ack.vim │ ├── Calendar.vim │ ├── Ctags.vim │ ├── CtrlP.vim │ ├── Fugitive.vim │ ├── NERDTree.vim │ ├── Powerline.vim │ ├── PresentationMode.vim │ ├── Quickfix.vim │ ├── Rails.vim │ ├── ScriptRunner.vim │ ├── Settings.vim │ ├── SplitWindowResize.vim │ ├── Surround.vim │ ├── Utility.vim │ └── Vimwiki.vim └── taglist.vim ├── pro-vimrc ├── pylibs ├── __init__.py ├── __init__.pyc ├── autopep8.py ├── autopep8.pyc ├── logilab │ ├── __init__.py │ ├── astng │ │ ├── COPYING │ │ ├── COPYING.LESSER │ │ ├── README │ │ ├── README.Python3 │ │ ├── __init__.py │ │ ├── __pkginfo__.py │ │ ├── as_string.py │ │ ├── bases.py │ │ ├── brain │ │ │ └── py2stdlib.py │ │ ├── builder.py │ │ ├── exceptions.py │ │ ├── inference.py │ │ ├── inspector.py │ │ ├── manager.py │ │ ├── mixins.py │ │ ├── node_classes.py │ │ ├── nodes.py │ │ ├── protocols.py │ │ ├── raw_building.py │ │ ├── rebuilder.py │ │ ├── scoped_nodes.py │ │ └── utils.py │ └── common │ │ ├── COPYING │ │ ├── COPYING.LESSER │ │ ├── README │ │ ├── README.Python3 │ │ ├── __init__.py │ │ ├── __pkginfo__.py │ │ ├── announce.txt │ │ ├── cache.py │ │ ├── changelog.py │ │ ├── clcommands.py │ │ ├── cli.py │ │ ├── compat.py │ │ ├── configuration.py │ │ ├── contexts.py │ │ ├── corbautils.py │ │ ├── daemon.py │ │ ├── date.py │ │ ├── dbf.py │ │ ├── debugger.py │ │ ├── decorators.py │ │ ├── deprecation.py │ │ ├── fileutils.py │ │ ├── graph.py │ │ ├── hg.py │ │ ├── interface.py │ │ ├── logging_ext.py │ │ ├── modutils.py │ │ ├── optik_ext.py │ │ ├── optparser.py │ │ ├── pdf_ext.py │ │ ├── proc.py │ │ ├── pyro_ext.py │ │ ├── pytest.py │ │ ├── registry.py │ │ ├── shellutils.py │ │ ├── sphinx_ext.py │ │ ├── sphinxutils.py │ │ ├── table.py │ │ ├── tasksqueue.py │ │ ├── testlib.py │ │ ├── textutils.py │ │ ├── tree.py │ │ ├── umessage.py │ │ ├── ureports │ │ ├── __init__.py │ │ ├── docbook_writer.py │ │ ├── html_writer.py │ │ ├── nodes.py │ │ └── text_writer.py │ │ ├── urllib2ext.py │ │ ├── vcgutils.py │ │ ├── visitor.py │ │ ├── xmlrpcutils.py │ │ └── xmlutils.py ├── mccabe.py ├── pep8.py ├── pep8.pyc ├── pyflakes │ ├── __init__.py │ ├── __init__.pyc │ ├── checker.py │ ├── checker.pyc │ ├── messages.py │ └── messages.pyc ├── pylint │ ├── README │ ├── README.Python3 │ ├── __init__.py │ ├── __pkginfo__.py │ ├── checkers │ │ ├── __init__.py │ │ ├── base.py │ │ ├── classes.py │ │ ├── design_analysis.py │ │ ├── exceptions.py │ │ ├── format.py │ │ ├── imports.py │ │ ├── logging.py │ │ ├── misc.py │ │ ├── newstyle.py │ │ ├── raw_metrics.py │ │ ├── similar.py │ │ ├── string_format.py │ │ ├── typecheck.py │ │ ├── utils.py │ │ └── variables.py │ ├── config.py │ ├── interfaces.py │ ├── lint.py │ ├── reporters │ │ ├── __init__.py │ │ ├── guireporter.py │ │ ├── html.py │ │ └── text.py │ └── utils.py ├── pymode │ ├── __init__.py │ ├── __init__.pyc │ ├── auto.py │ ├── auto.pyc │ ├── interface.py │ ├── interface.pyc │ ├── lint.py │ ├── lint.pyc │ ├── queue.py │ └── queue.pyc ├── rope │ ├── __init__.py │ ├── __init__.pyc │ ├── base │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── arguments.py │ │ ├── arguments.pyc │ │ ├── ast.py │ │ ├── ast.pyc │ │ ├── astutils.py │ │ ├── astutils.pyc │ │ ├── builtins.py │ │ ├── builtins.pyc │ │ ├── change.py │ │ ├── change.pyc │ │ ├── codeanalyze.py │ │ ├── codeanalyze.pyc │ │ ├── default_config.py │ │ ├── evaluate.py │ │ ├── evaluate.pyc │ │ ├── exceptions.py │ │ ├── exceptions.pyc │ │ ├── fscommands.py │ │ ├── fscommands.pyc │ │ ├── history.py │ │ ├── history.pyc │ │ ├── libutils.py │ │ ├── libutils.pyc │ │ ├── oi │ │ │ ├── __init__.py │ │ │ ├── __init__.pyc │ │ │ ├── doa.py │ │ │ ├── doa.pyc │ │ │ ├── memorydb.py │ │ │ ├── memorydb.pyc │ │ │ ├── objectdb.py │ │ │ ├── objectdb.pyc │ │ │ ├── objectinfo.py │ │ │ ├── objectinfo.pyc │ │ │ ├── runmod.py │ │ │ ├── soa.py │ │ │ ├── soa.pyc │ │ │ ├── soi.py │ │ │ ├── soi.pyc │ │ │ ├── transform.py │ │ │ └── transform.pyc │ │ ├── prefs.py │ │ ├── prefs.pyc │ │ ├── project.py │ │ ├── project.pyc │ │ ├── pycore.py │ │ ├── pycore.pyc │ │ ├── pynames.py │ │ ├── pynames.pyc │ │ ├── pynamesdef.py │ │ ├── pynamesdef.pyc │ │ ├── pyobjects.py │ │ ├── pyobjects.pyc │ │ ├── pyobjectsdef.py │ │ ├── pyobjectsdef.pyc │ │ ├── pyscopes.py │ │ ├── pyscopes.pyc │ │ ├── resourceobserver.py │ │ ├── resourceobserver.pyc │ │ ├── resources.py │ │ ├── resources.pyc │ │ ├── simplify.py │ │ ├── simplify.pyc │ │ ├── stdmods.py │ │ ├── stdmods.pyc │ │ ├── taskhandle.py │ │ ├── taskhandle.pyc │ │ ├── utils.py │ │ ├── utils.pyc │ │ ├── worder.py │ │ └── worder.pyc │ ├── contrib │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── autoimport.py │ │ ├── autoimport.pyc │ │ ├── changestack.py │ │ ├── codeassist.py │ │ ├── codeassist.pyc │ │ ├── finderrors.py │ │ ├── findit.py │ │ ├── findit.pyc │ │ ├── fixmodnames.py │ │ ├── fixsyntax.py │ │ ├── fixsyntax.pyc │ │ ├── generate.py │ │ └── generate.pyc │ └── refactor │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── change_signature.py │ │ ├── change_signature.pyc │ │ ├── encapsulate_field.py │ │ ├── extract.py │ │ ├── extract.pyc │ │ ├── functionutils.py │ │ ├── functionutils.pyc │ │ ├── importutils │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── actions.py │ │ ├── actions.pyc │ │ ├── importinfo.py │ │ ├── importinfo.pyc │ │ ├── module_imports.py │ │ └── module_imports.pyc │ │ ├── inline.py │ │ ├── inline.pyc │ │ ├── introduce_factory.py │ │ ├── introduce_factory.pyc │ │ ├── introduce_parameter.py │ │ ├── localtofield.py │ │ ├── method_object.py │ │ ├── method_object.pyc │ │ ├── move.py │ │ ├── move.pyc │ │ ├── multiproject.py │ │ ├── occurrences.py │ │ ├── occurrences.pyc │ │ ├── patchedast.py │ │ ├── patchedast.pyc │ │ ├── rename.py │ │ ├── rename.pyc │ │ ├── restructure.py │ │ ├── restructure.pyc │ │ ├── similarfinder.py │ │ ├── similarfinder.pyc │ │ ├── sourceutils.py │ │ ├── sourceutils.pyc │ │ ├── suites.py │ │ ├── suites.pyc │ │ ├── topackage.py │ │ ├── topackage.pyc │ │ ├── usefunction.py │ │ ├── usefunction.pyc │ │ ├── wildcards.py │ │ └── wildcards.pyc ├── ropemode │ ├── __init__.py │ ├── __init__.pyc │ ├── decorators.py │ ├── decorators.pyc │ ├── dialog.py │ ├── dialog.pyc │ ├── environment.py │ ├── environment.pyc │ ├── filter.py │ ├── filter.pyc │ ├── interface.py │ ├── interface.pyc │ ├── refactor.py │ └── refactor.pyc ├── ropevim.py └── ropevim.pyc ├── pylint.ini ├── screenshots └── vim-2012-03-27-macvim.png ├── snippets ├── _.snippets ├── coffee.snippets ├── eruby.snippets ├── gitignore.snippets ├── html.snippets ├── javascript.snippets ├── mkd.snippets ├── ruby.snippets └── scala.snippets ├── syntax ├── nerdtree.vim ├── python.vim ├── verilog.vim └── verilog_systemverilog.vim ├── update.sh └── vimrc /.netrwhist: -------------------------------------------------------------------------------- 1 | let g:netrw_dirhistmax =10 2 | let g:netrw_dirhist_cnt =0 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | clean: 3 | find . -name "*.pyc" -delete 4 | -------------------------------------------------------------------------------- /after/ftplugin/python.vim: -------------------------------------------------------------------------------- 1 | " Fix omnifunc 2 | if g:pymode && g:pymode_rope && g:pymode_rope_vim_completion 3 | setlocal omnifunc=RopeOmni 4 | endif 5 | 6 | " Motion {{{ 7 | 8 | if !pymode#Default('g:pymode_motion', 1) || g:pymode_motion 9 | 10 | nnoremap ]] :call pymode#motion#move('^\(class\\|def\)\s', '') 11 | nnoremap [[ :call pymode#motion#move('^\(class\\|def\)\s', 'b') 12 | nnoremap ]C :call pymode#motion#move('^\(class\\|def\)\s', '') 13 | nnoremap [C :call pymode#motion#move('^\(class\\|def\)\s', 'b') 14 | nnoremap ]M :call pymode#motion#move('^\s*def\s', '') 15 | nnoremap [M :call pymode#motion#move('^\s*def\s', 'b') 16 | 17 | onoremap ]] :call pymode#motion#move('^\(class\\|def\)\s', '') 18 | onoremap [[ :call pymode#motion#move('^\(class\\|def\)\s', 'b') 19 | onoremap ]C :call pymode#motion#move('^\(class\\|def\)\s', '') 20 | onoremap [C :call pymode#motion#move('^\(class\\|def\)\s', 'b') 21 | onoremap ]M :call pymode#motion#move('^\s*def\s', '') 22 | onoremap [M :call pymode#motion#move('^\s*def\s', 'b') 23 | 24 | vnoremap ]] :call pymode#motion#vmove('^\(class\\|def\)\s', '') 25 | vnoremap [[ :call pymode#motion#vmove('^\(class\\|def\)\s', 'b') 26 | vnoremap ]M :call pymode#motion#vmove('^\s*def\s', '') 27 | vnoremap [M :call pymode#motion#vmove('^\s*def\s', 'b') 28 | 29 | onoremap C :call pymode#motion#select('^\s*class\s', 0) 30 | onoremap aC :call pymode#motion#select('^\s*class\s', 0) 31 | onoremap iC :call pymode#motion#select('^\s*class\s', 1) 32 | vnoremap aC :call pymode#motion#select('^\s*class\s', 0) 33 | vnoremap iC :call pymode#motion#select('^\s*class\s', 1) 34 | 35 | onoremap M :call pymode#motion#select('^\s*def\s', 0) 36 | onoremap aM :call pymode#motion#select('^\s*def\s', 0) 37 | onoremap iM :call pymode#motion#select('^\s*def\s', 1) 38 | vnoremap aM :call pymode#motion#select('^\s*def\s', 0) 39 | vnoremap iM :call pymode#motion#select('^\s*def\s', 1) 40 | 41 | endif 42 | 43 | " }}} 44 | -------------------------------------------------------------------------------- /autoload/pymode/breakpoint.vim: -------------------------------------------------------------------------------- 1 | fun! pymode#breakpoint#Set(lnum) "{{{ 2 | let line = getline(a:lnum) 3 | if strridx(line, g:pymode_breakpoint_cmd) != -1 4 | normal dd 5 | else 6 | let plnum = prevnonblank(a:lnum) 7 | call append(line('.')-1, repeat(' ', indent(plnum)).g:pymode_breakpoint_cmd) 8 | normal k 9 | endif 10 | 11 | " Disable lint 12 | let pymode_lint = g:pymode_lint 13 | let g:pymode_lint = 0 14 | 15 | " Save file 16 | if &modifiable && &modified | write | endif 17 | 18 | let g:pymode_lint = pymode_lint 19 | 20 | endfunction "}}} 21 | -------------------------------------------------------------------------------- /autoload/pymode/doc.vim: -------------------------------------------------------------------------------- 1 | " Python-mode search by documentation 2 | 3 | 4 | fun! pymode#doc#Show(word) "{{{ 5 | if a:word == '' 6 | echoerr "No name/symbol under cursor!" 7 | else 8 | py import StringIO 9 | py sys.stdout, _ = StringIO.StringIO(), sys.stdout 10 | py help(vim.eval('a:word')) 11 | py sys.stdout, out = _, sys.stdout.getvalue() 12 | call pymode#TempBuffer() 13 | py vim.current.buffer.append(out.split('\n'), 0) 14 | wincmd p 15 | endif 16 | endfunction "}}} 17 | 18 | 19 | " vim: fdm=marker:fdl=0 20 | -------------------------------------------------------------------------------- /autoload/pymode/folding.vim: -------------------------------------------------------------------------------- 1 | " Python-mode folding functions 2 | 3 | 4 | let s:blank_regex = '^\s*$' 5 | let s:def_regex = '^\s*\(class\|def\) \w\+' 6 | 7 | 8 | fun! pymode#folding#text() " {{{ 9 | let fs = v:foldstart 10 | while getline(fs) =~ '^\s*@' 11 | let fs = nextnonblank(fs + 1) 12 | endwhile 13 | let line = getline(fs) 14 | 15 | let nucolwidth = &fdc + &number * &numberwidth 16 | let windowwidth = winwidth(0) - nucolwidth - 3 17 | let foldedlinecount = v:foldend - v:foldstart 18 | 19 | " expand tabs into spaces 20 | let onetab = strpart(' ', 0, &tabstop) 21 | let line = substitute(line, '\t', onetab, 'g') 22 | 23 | let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) 24 | let fillcharcount = windowwidth - len(line) - len(foldedlinecount) 25 | return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' 26 | endfunction "}}} 27 | 28 | 29 | fun! pymode#folding#expr(lnum) "{{{ 30 | 31 | let line = getline(a:lnum) 32 | let indent = indent(a:lnum) 33 | 34 | if line =~ s:def_regex 35 | return ">".(indent / &shiftwidth + 1) 36 | endif 37 | 38 | if line =~ '^\s*@' 39 | return -1 40 | endif 41 | 42 | if line =~ s:blank_regex 43 | let prev_line = getline(a:lnum - 1) 44 | if prev_line =~ s:blank_regex 45 | return -1 46 | else 47 | return foldlevel(prevnonblank(a:lnum)) 48 | endif 49 | endif 50 | 51 | if indent == 0 52 | return 0 53 | endif 54 | 55 | return '=' 56 | 57 | endfunction "}}} 58 | 59 | 60 | " vim: fdm=marker:fdl=0 61 | -------------------------------------------------------------------------------- /autoload/pymode/lint.vim: -------------------------------------------------------------------------------- 1 | fun! pymode#lint#Check() "{{{ 2 | " DESC: Run checkers on current file. 3 | " 4 | if !g:pymode_lint | return | endif 5 | 6 | if &modifiable && &modified 7 | try 8 | write 9 | catch /E212/ 10 | echohl Error | echo "File modified and I can't save it. Cancel code checking." | echohl None 11 | return 0 12 | endtry 13 | endif 14 | 15 | let g:pymode_lint_buffer = bufnr('%') 16 | 17 | py lint.check_file() 18 | 19 | endfunction " }}} 20 | 21 | 22 | fun! pymode#lint#Parse() 23 | " DESC: Parse result of code checking. 24 | " 25 | call setqflist(g:qf_list, 'r') 26 | 27 | if g:pymode_lint_signs 28 | call pymode#PlaceSigns() 29 | endif 30 | 31 | if g:pymode_lint_cwindow 32 | call pymode#QuickfixOpen(0, g:pymode_lint_hold, g:pymode_lint_maxheight, g:pymode_lint_minheight, g:pymode_lint_jump) 33 | endif 34 | 35 | if !len(g:qf_list) 36 | call pymode#WideMessage('Code checking is completed. No errors found.') 37 | endif 38 | 39 | endfunction 40 | 41 | 42 | fun! pymode#lint#Toggle() "{{{ 43 | let g:pymode_lint = g:pymode_lint ? 0 : 1 44 | call pymode#lint#toggle_win(g:pymode_lint, "Pymode lint") 45 | endfunction "}}} 46 | 47 | 48 | fun! pymode#lint#ToggleWindow() "{{{ 49 | let g:pymode_lint_cwindow = g:pymode_lint_cwindow ? 0 : 1 50 | call pymode#lint#toggle_win(g:pymode_lint_cwindow, "Pymode lint cwindow") 51 | endfunction "}}} 52 | 53 | 54 | fun! pymode#lint#ToggleChecker() "{{{ 55 | let g:pymode_lint_checker = g:pymode_lint_checker == "pylint" ? "pyflakes" : "pylint" 56 | echomsg "Pymode lint checker: " . g:pymode_lint_checker 57 | endfunction "}}} 58 | 59 | 60 | fun! pymode#lint#toggle_win(toggle, msg) "{{{ 61 | if a:toggle 62 | echomsg a:msg." enabled" 63 | botright cwindow 64 | if &buftype == "quickfix" 65 | wincmd p 66 | endif 67 | else 68 | echomsg a:msg." disabled" 69 | cclose 70 | endif 71 | endfunction "}}} 72 | 73 | 74 | fun! pymode#lint#show_errormessage() "{{{ 75 | if g:pymode_lint_buffer != bufnr('%') 76 | return 0 77 | endif 78 | let errors = getqflist() 79 | if !len(errors) 80 | return 81 | endif 82 | let [_, line, _, _] = getpos(".") 83 | for e in errors 84 | if e['lnum'] == line 85 | call pymode#WideMessage(e['text']) 86 | else 87 | echo 88 | endif 89 | endfor 90 | endfunction " }}} 91 | 92 | 93 | fun! pymode#lint#Auto() "{{{ 94 | if &modifiable && &modified 95 | try 96 | write 97 | catch /E212/ 98 | echohl Error | echo "File modified and I can't save it. Cancel operation." | echohl None 99 | return 0 100 | endtry 101 | endif 102 | py auto.fix_current_file() 103 | cclose 104 | edit 105 | endfunction "}}} 106 | -------------------------------------------------------------------------------- /autoload/pymode/motion.vim: -------------------------------------------------------------------------------- 1 | " Python-mode motion functions 2 | 3 | 4 | fun! pymode#motion#move(pattern, flags, ...) "{{{ 5 | let cnt = v:count1 - 1 6 | let [line, column] = searchpos(a:pattern, a:flags . 'sW') 7 | let indent = indent(line) 8 | while cnt && line 9 | let [line, column] = searchpos(a:pattern, a:flags . 'W') 10 | if indent(line) == indent 11 | let cnt = cnt - 1 12 | endif 13 | endwhile 14 | return [line, column] 15 | endfunction "}}} 16 | 17 | 18 | fun! pymode#motion#vmove(pattern, flags) range "{{{ 19 | call cursor(a:lastline, 0) 20 | let end = pymode#motion#move(a:pattern, a:flags) 21 | call cursor(a:firstline, 0) 22 | normal! v 23 | call cursor(end) 24 | endfunction "}}} 25 | 26 | 27 | fun! pymode#motion#pos_le(pos1, pos2) "{{{ 28 | return ((a:pos1[0] < a:pos2[0]) || (a:pos1[0] == a:pos2[0] && a:pos1[1] <= a:pos2[1])) 29 | endfunction "}}} 30 | 31 | 32 | fun! pymode#motion#select(pattern, inner) "{{{ 33 | let cnt = v:count1 - 1 34 | let orig = getpos('.')[1:2] 35 | let snum = pymode#BlockStart(orig[0], a:pattern) 36 | if getline(snum) !~ a:pattern 37 | return 0 38 | endif 39 | let enum = pymode#BlockEnd(snum, indent(snum)) 40 | while cnt 41 | let lnum = search(a:pattern, 'nW') 42 | if lnum 43 | let enum = pymode#BlockEnd(lnum, indent(lnum)) 44 | call cursor(enum, 1) 45 | endif 46 | let cnt = cnt - 1 47 | endwhile 48 | if pymode#motion#pos_le([snum, 0], orig) && pymode#motion#pos_le(orig, [enum, 1]) 49 | if a:inner 50 | let snum = snum + 1 51 | let enum = prevnonblank(enum) 52 | endif 53 | 54 | call cursor(snum, 1) 55 | normal! v 56 | call cursor(enum, len(getline(enum))) 57 | endif 58 | endfunction "}}} 59 | 60 | 61 | " vim: fdm=marker:fdl=0 62 | -------------------------------------------------------------------------------- /autoload/pymode/queue.vim: -------------------------------------------------------------------------------- 1 | fun! pymode#queue#Poll() "{{{ 2 | py queue.check_task() 3 | call feedkeys("\\", 't') 4 | endfunction "}}} 5 | -------------------------------------------------------------------------------- /autoload/pymode/run.vim: -------------------------------------------------------------------------------- 1 | " DESC: Save file if it modified and run python code 2 | fun! pymode#run#Run(line1, line2) "{{{ 3 | if &modifiable && &modified | write | endif 4 | py import StringIO 5 | py sys.stdout, _ = StringIO.StringIO(), sys.stdout 6 | call pymode#WideMessage("Code running.") 7 | try 8 | py execfile(vim.eval('expand("%s:p")')) 9 | py sys.stdout, out = _, sys.stdout.getvalue() 10 | call pymode#TempBuffer() 11 | py vim.current.buffer.append(out.split('\n'), 0) 12 | wincmd p 13 | call pymode#WideMessage("") 14 | 15 | catch /.*/ 16 | 17 | echohl Error | echo "Run-time error." | echohl none 18 | 19 | endtry 20 | endfunction "}}} 21 | -------------------------------------------------------------------------------- /autoload/pymode/troubleshooting.vim: -------------------------------------------------------------------------------- 1 | " DESC: Get debug information about pymode problem 2 | fun! pymode#troubleshooting#Test() "{{{ 3 | new 4 | setlocal buftype=nofile bufhidden=delete noswapfile nowrap 5 | call append('0', ['Pymode diagnostic', 6 | \ '===================', 7 | \ 'VIM:' . v:version . ' multi_byte:' . has('multi_byte') . ' pymode: ' . g:pymode_version, 8 | \ '']) 9 | 10 | let python = 1 11 | let output = [] 12 | 13 | if !exists('#filetypeplugin') 14 | call append('$', ['WARNING: ', 'Python-mode required :filetype plugin indent on', '']) 15 | endif 16 | 17 | if !has('python') 18 | call append('$', ['WARNING: ', 'Python-mode required vim compiled with +python.', 19 | \ '"lint, rope, run, doc, virtualenv" features disabled.', '']) 20 | let python = 0 21 | endif 22 | 23 | call append('$', 'Pymode variables:') 24 | call append('$', '-------------------') 25 | call append('$', 'pymode:' . g:pymode) 26 | call append('$', 'pymode_lint:' . g:pymode_lint) 27 | call append('$', 'pymode_rope:' . g:pymode_rope) 28 | call append('$', 'pymode_path:' . g:pymode_path) 29 | call append('$', 'pymode_doc:' . g:pymode_doc) 30 | call append('$', 'pymode_run:' . g:pymode_run) 31 | call append('$', 'pymode_virtualenv:' . g:pymode_virtualenv) 32 | call append('$', 'pymode_breakpoint:' . g:pymode_breakpoint) 33 | call append('$', 'pymode_path:' . g:pymode_path) 34 | call append('$', 'pymode_folding:' . g:pymode_folding) 35 | call append('$', 'pymode_syntax:' . g:pymode_syntax) 36 | call append('$', 'pymode_utils_whitespaces:' . g:pymode_utils_whitespaces) 37 | call append('$', 'pymode_options_indent:' . g:pymode_options_indent) 38 | call append('$', 'pymode_options_other:' . g:pymode_options_other) 39 | 40 | if len(g:pymode_virtualenv_enabled) 41 | call append('$', 'Enabled virtualenv:') 42 | call append('$', '-------------------') 43 | call append('$', g:pymode_virtualenv_enabled) 44 | call append('$', '') 45 | endif 46 | 47 | if python 48 | call append('$', 'VIM python paths:') 49 | call append('$', '-----------------') 50 | python << EOF 51 | vim.command('let l:output = %s' % repr(sys.path)) 52 | EOF 53 | call append('$', output) 54 | call append('$', '') 55 | endif 56 | 57 | endfunction "}}} 58 | -------------------------------------------------------------------------------- /autoload/pymode/virtualenv.vim: -------------------------------------------------------------------------------- 1 | fun! pymode#virtualenv#Activate() "{{{ 2 | 3 | if !exists("$VIRTUAL_ENV") 4 | return 5 | endif 6 | 7 | for env in g:pymode_virtualenv_enabled 8 | if env == $VIRTUAL_ENV 9 | return 0 10 | endif 11 | endfor 12 | 13 | call add(g:pymode_virtualenv_enabled, $VIRTUAL_ENV) 14 | 15 | python << EOF 16 | import sys, vim, os 17 | 18 | ve_dir = os.environ['VIRTUAL_ENV'] 19 | ve_dir in sys.path or sys.path.insert(0, ve_dir) 20 | activate_this = os.path.join(os.path.join(ve_dir, 'bin'), 'activate_this.py') 21 | 22 | # Fix for windows 23 | if not os.path.exists(activate_this): 24 | activate_this = os.path.join(os.path.join(ve_dir, 'Scripts'), 'activate_this.py') 25 | 26 | execfile(activate_this, dict(__file__=activate_this)) 27 | EOF 28 | endfunction "}}} 29 | -------------------------------------------------------------------------------- /colors/pyte.vim: -------------------------------------------------------------------------------- 1 | 2 | set background=light 3 | 4 | hi clear 5 | if exists("syntax_on") 6 | syntax reset 7 | endif 8 | 9 | let colors_name = "pyte" 10 | 11 | if version >= 700 12 | hi CursorLine guibg=#f6f6f6 13 | hi CursorColumn guibg=#eaeaea 14 | hi MatchParen guifg=white guibg=#80a090 gui=bold 15 | 16 | "Tabpages 17 | hi TabLine guifg=black guibg=#b0b8c0 gui=italic 18 | hi TabLineFill guifg=#9098a0 19 | hi TabLineSel guifg=black guibg=#f0f0f0 gui=italic,bold 20 | 21 | "P-Menu (auto-completion) 22 | hi Pmenu guifg=white guibg=#808080 23 | "PmenuSel 24 | "PmenuSbar 25 | "PmenuThumb 26 | endif 27 | " 28 | " Html-Titles 29 | hi Title guifg=#202020 gui=bold 30 | hi Underlined guifg=#202020 gui=underline 31 | 32 | 33 | hi Cursor guifg=black guibg=#b0b4b8 34 | hi lCursor guifg=black guibg=white 35 | hi LineNr guifg=#ffffff guibg=#c0d0e0 36 | 37 | hi Normal guifg=#202020 guibg=#f0f0f0 38 | 39 | hi StatusLine guifg=white guibg=#8090a0 gui=bold,italic 40 | hi StatusLineNC guifg=#506070 guibg=#a0b0c0 gui=italic 41 | hi VertSplit guifg=#a0b0c0 guibg=#a0b0c0 gui=NONE 42 | 43 | hi Folded guifg=#708090 guibg=#c0d0e0 44 | 45 | hi NonText guifg=#c0c0c0 guibg=#e0e0e0 46 | " Kommentare 47 | hi Comment guifg=#a0b0c0 gui=italic 48 | 49 | " Konstanten 50 | hi Constant guifg=#a07040 51 | hi String guifg=#4070a0 52 | hi Number guifg=#40a070 53 | hi Float guifg=#70a040 54 | "hi Statement guifg=#0070e0 gui=NONE 55 | " Python: def and so on, html: tag-names 56 | hi Statement guifg=#007020 gui=bold 57 | 58 | 59 | " HTML: arguments 60 | hi Type guifg=#e5a00d gui=italic 61 | " Python: Standard exceptions, True&False 62 | hi Structure guifg=#007020 gui=italic 63 | hi Function guifg=#06287e gui=italic 64 | 65 | hi Identifier guifg=#5b3674 gui=italic 66 | 67 | hi Repeat guifg=#7fbf58 gui=bold 68 | hi Conditional guifg=#4c8f2f gui=bold 69 | 70 | " Cheetah: #-Symbol, function-names 71 | hi PreProc guifg=#1060a0 gui=NONE 72 | " Cheetah: def, for and so on, Python: Decorators 73 | hi Define guifg=#1060a0 gui=bold 74 | 75 | hi Error guifg=red guibg=white gui=bold,underline 76 | hi Todo guifg=#a0b0c0 guibg=NONE gui=italic,bold,underline 77 | 78 | " Python: %(...)s - constructs, encoding 79 | hi Special guifg=#70a0d0 gui=italic 80 | 81 | hi Operator guifg=#408010 82 | 83 | " color of s etc... 84 | hi SpecialKey guifg=#d8a080 guibg=#e8e8e8 gui=italic 85 | 86 | " Diff 87 | hi DiffChange guifg=NONE guibg=#e0e0e0 gui=italic,bold 88 | hi DiffText guifg=NONE guibg=#f0c8c8 gui=italic,bold 89 | hi DiffAdd guifg=NONE guibg=#c0e0d0 gui=italic,bold 90 | hi DiffDelete guifg=NONE guibg=#f0e0b0 gui=italic,bold 91 | 92 | 93 | -------------------------------------------------------------------------------- /colors/wombat.vim: -------------------------------------------------------------------------------- 1 | " Maintainer: Lars H. Nielsen (dengmao@gmail.com) 2 | " Last Change:January 22 2007 3 | 4 | set background=dark 5 | 6 | hi clear 7 | 8 | if exists("syntax_on") 9 | syntax reset 10 | endif 11 | 12 | let colors_name = "wombat" 13 | 14 | " Vim >= 7.0 specific colors 15 | if version >= 700 16 | hi CursorLine guibg=#2d2d2d 17 | hi CursorColumn guibg=#2d2d2d 18 | hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=bold 19 | hi Pmenu guifg=#f6f3e8 guibg=#444444 20 | hi PmenuSel guifg=#000000 guibg=#cae682 21 | endif 22 | 23 | " General colors 24 | hi Cursor guifg=NONE guibg=#656565 gui=none 25 | hi Normal guifg=#f6f3e8 guibg=#242424 gui=none 26 | "hi NonText guifg=#808080 guibg=#303030 gui=none 27 | hi NonText guifg=#303030 guibg=#303030 gui=none 28 | hi LineNr guifg=#857b6f guibg=#000000 gui=none 29 | hi StatusLine guifg=#f6f3e8 guibg=#444444 gui=italic 30 | hi StatusLineNC guifg=#857b6f guibg=#444444 gui=none 31 | hi VertSplit guifg=#444444 guibg=#444444 gui=none 32 | hi Folded guibg=#384048 guifg=#a0a8b0 gui=none 33 | hi Title guifg=#f6f3e8 guibg=NONE gui=bold 34 | hi Visual guifg=#f6f3e8 guibg=#444444 gui=none 35 | hi SpecialKey guifg=#808080 guibg=#343434 gui=none 36 | 37 | " Syntax highlighting 38 | hi Comment guifg=#99968b gui=italic 39 | hi Todo guifg=#8f8f8f gui=italic 40 | hi Constant guifg=#e5786d gui=none 41 | hi String guifg=#95e454 gui=italic 42 | hi Identifier guifg=#cae682 gui=none 43 | hi Function guifg=#cae682 gui=none 44 | hi Type guifg=#cae682 gui=none 45 | hi Statement guifg=#8ac6f2 gui=none 46 | hi Keyword guifg=#8ac6f2 gui=none 47 | hi PreProc guifg=#e5786d gui=none 48 | hi Number guifg=#e5786d gui=none 49 | hi Special guifg=#e7f6da gui=none 50 | -------------------------------------------------------------------------------- /easy-vimrc: -------------------------------------------------------------------------------- 1 | " Easy version Vimrc 2 | " I kept all other settings in plugins/settings directory 3 | " 4 | " Eddie Kao 5 | " http://blog.eddie.com.tw 6 | " eddie@digik.com.tw 7 | 8 | runtime bundle/vim-pathogen/autoload/pathogen.vim 9 | filetype off 10 | call pathogen#runtime_append_all_bundles() 11 | filetype plugin indent on 12 | call pathogen#infect() 13 | call pathogen#helptags() 14 | 15 | " ============= 16 | " custom key 17 | " ============= 18 | " add a new line without entering insert mode 19 | noremap o 20 | 21 | " map backspce to delete a character 22 | noremap X 23 | 24 | " map ctrl+c and ctrl+v 25 | noremap y 26 | noremap P 27 | 28 | " cancel searched highlight 29 | noremap ; :nohlsearch 30 | 31 | " navigating for long lines 32 | map j gj 33 | map k gk 34 | map gk 35 | map gj 36 | imap gki 37 | imap gji 38 | 39 | " select ALL 40 | map ggVG 41 | -------------------------------------------------------------------------------- /experimental-vimrc: -------------------------------------------------------------------------------- 1 | " Experimental version Vimrc 2 | " I kept all other settings in plugins/settings directory 3 | " 4 | " Eddie Kao 5 | " http://blog.eddie.com.tw 6 | " eddie@digik.com.tw 7 | 8 | " toogle to keep the cursor in the center of the window 9 | function! ToggleZZMode() 10 | if exists("g:eddie_zz_mode") 11 | if g:eddie_zz_mode == 1 12 | let g:eddie_zz_mode=0 13 | let &scrolloff=3 14 | echo "Switch to Normal Mode" 15 | else 16 | let g:eddie_zz_mode=1 17 | let &scrolloff=999-&scrolloff 18 | echo "Switch to ZZ Mode" 19 | end 20 | else 21 | let g:eddie_zz_mode=1 22 | let &scrolloff=999-&scrolloff 23 | echo "Switch to ZZ Mode" 24 | end 25 | endfunction 26 | 27 | if filereadable(expand("~/.vim/pro-vimrc")) 28 | " load pro-vimrc first 29 | source ~/.vim/pro-vimrc 30 | " some experimental settings 31 | set nomodeline 32 | set notimeout 33 | set ttimeout 34 | set ttimeoutlen=10 35 | set shell=zsh 36 | nnoremap mm :call ToggleZZMode() 37 | else 38 | echo "~/.vim/pro-vimrc doesn't exist" 39 | endif 40 | -------------------------------------------------------------------------------- /gvimrc: -------------------------------------------------------------------------------- 1 | set guioptions=ce 2 | set antialias 3 | colorscheme rails_envy 4 | set linespace=2 5 | 6 | if has("gui_macvim") 7 | set guifont=Monaco:h17 8 | elseif has("gui_gtk") 9 | set guifont=Monospace\ 14 10 | else 11 | set guifont=Monaco:h17 12 | end 13 | 14 | if has("gui_macvim") 15 | set transparency=0 16 | 17 | " disable IM while leaving insert mode 18 | "autocmd InsertEnter * set noimdisable 19 | "autocmd InsertLeave * set imdisable 20 | 21 | " move a line of text using ALT+[jk] or Comamnd+[jk] on mac 22 | nmap mz:m+`z 23 | nmap mz:m-2`z 24 | vmap :m'>+`mzgv`yo`z 25 | vmap :m'<-2`>my` 29 | macmenu &File.Close key= 30 | 31 | " remap cmd + w to close tab 32 | map :tabclose 33 | 34 | " remap cmd + n to new tab 35 | map :tabnew 36 | 37 | " map cmd + enter to switch to full screen 38 | map :set invfu 39 | 40 | " map cmd+1~9 to switch tab 1~9 41 | for i in range(1, 9) 42 | exec "nnoremap ".i."gt" 43 | endfor 44 | 45 | endif 46 | -------------------------------------------------------------------------------- /plugin/after/ftdetect/FileTypes.vim: -------------------------------------------------------------------------------- 1 | " Objective-C 2 | autocmd! BufNewFile,BufRead *.m set filetype=objc 3 | 4 | " ActionScript 5 | autocmd! BufNewFile,BufRead *.as set filetype=actionscript 6 | autocmd! BufNewFile,BufRead *.mxml set filetype=mxml 7 | 8 | " SCSS 9 | autocmd! BufNewFile,BufRead *.scss set filetype=scss.css 10 | 11 | " eRuby 12 | autocmd! BufNewFile,BufRead *.erb set filetype=eruby.html 13 | 14 | " JSON 15 | autocmd! BufNewFile,BufRead *.json set filetype=javascript 16 | 17 | " GitIgnore 18 | autocmd! BufNewFile,BufRead *.gitignore set filetype=gitignore 19 | 20 | " ZSH 21 | autocmd! BufNewFile,BufRead *.zsh-theme set filetype=zsh 22 | 23 | " Nginx Config 24 | autocmd! BufNewFile,BufRead nginx.conf set filetype=nginx 25 | -------------------------------------------------------------------------------- /plugin/settings/Ack.vim: -------------------------------------------------------------------------------- 1 | if executable("ack") 2 | noremap FF :Ack 3 | else 4 | noremap FF :echo "Sorry, you need to install ack first!" 5 | endif 6 | -------------------------------------------------------------------------------- /plugin/settings/Calendar.vim: -------------------------------------------------------------------------------- 1 | function! ToggleCalendar() 2 | execute ":Calendar" 3 | if exists("g:calendar_open") 4 | if g:calendar_open == 1 5 | execute "q" 6 | unlet g:calendar_open 7 | else 8 | g:calendar_open = 1 9 | end 10 | else 11 | let g:calendar_open = 1 12 | end 13 | endfunction 14 | 15 | map :call ToggleCalendar() 16 | -------------------------------------------------------------------------------- /plugin/settings/Ctags.vim: -------------------------------------------------------------------------------- 1 | let Tlist_Ctags_Cmd='/usr/bin/ctags' 2 | let Tlist_WinWidth=40 3 | let Tlist_GainFocus_On_ToggleOpen=1 4 | map :TlistToggle 5 | set tags+=./tags;/ 6 | set tags+=gems.tags 7 | autocmd FileType ruby let &l:tags = pathogen#legacyjoin(pathogen#uniq(pathogen#split(&tags) + map(split($GEM_PATH,':'),'v:val."/gems/*/tags"'))) 8 | -------------------------------------------------------------------------------- /plugin/settings/CtrlP.vim: -------------------------------------------------------------------------------- 1 | nnoremap :CtrlPMRU 2 | nnoremap u :CtrlPMRU 3 | 4 | let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' 5 | let g:ctrlp_working_path_mode=0 6 | let g:ctrlp_match_window_bottom=1 7 | let g:ctrlp_max_height=15 8 | let g:ctrlp_match_window_reversed=0 9 | let g:ctrlp_mruf_max=500 10 | let g:ctrlp_follow_symlinks=1 11 | -------------------------------------------------------------------------------- /plugin/settings/Fugitive.vim: -------------------------------------------------------------------------------- 1 | " shortcuts mapping 2 | nnoremap gs :Gstatus 3 | nnoremap gd :Gdiff 4 | nnoremap gc :Gcommit 5 | nnoremap gl :Glog 6 | nnoremap gp :Git push 7 | -------------------------------------------------------------------------------- /plugin/settings/NERDTree.vim: -------------------------------------------------------------------------------- 1 | nnoremap :NERDTree 2 | let NERDTreeShowBookmarks=0 3 | let NERDTreeChDirMode=2 4 | let NERDTreeMouseMode=2 5 | let g:nerdtree_tabs_focus_on_files=1 6 | let g:nerdtree_tabs_open_on_gui_startup=0 7 | " open directory of current opened file 8 | map r :NERDTreeFind 9 | 10 | " make nerdtree look nice 11 | let NERDTreeMinimalUI=1 12 | let NERDTreeDirArrows=1 13 | let g:NERDTreeWinSize=30 14 | -------------------------------------------------------------------------------- /plugin/settings/Powerline.vim: -------------------------------------------------------------------------------- 1 | let g:Powerline_symbols='unicode' 2 | -------------------------------------------------------------------------------- /plugin/settings/PresentationMode.vim: -------------------------------------------------------------------------------- 1 | " toggle between working mode and presentation mode 2 | " borrowed from skalnik(https://github.com/skalnik) 3 | " 4 | " font size change only work for GUI-version Vim 5 | 6 | function! PresentationModeOn() 7 | colorscheme github 8 | 9 | if has("gui_macvim") 10 | set guifont=Monaco:h25 " for Mac 11 | elseif has("gui_gtk") 12 | set guifont=Monospace\ 22 " for ubuntu 13 | end 14 | endfunction 15 | 16 | function! PresentationModeOff() 17 | colorscheme rails_envy 18 | 19 | if has("gui_macvim") 20 | set guifont=Monaco:h17 " for Mac 21 | elseif has("gui_gtk") 22 | set guifont=Monospace\ 14 " for ubuntu 23 | end 24 | endfunction 25 | 26 | function! TogglePresentationMode() 27 | if !exists('w:present') 28 | let w:present=0 29 | endif 30 | 31 | if w:present==0 32 | call PresentationModeOn() 33 | let w:present=1 34 | else 35 | call PresentationModeOff() 36 | let w:present=0 37 | endif 38 | endfunction 39 | 40 | map z :call TogglePresentationMode() 41 | -------------------------------------------------------------------------------- /plugin/settings/Quickfix.vim: -------------------------------------------------------------------------------- 1 | " QuickFix Window, which is borrowed from c9s 2 | command -bang -nargs=? QFix call QFixToggle(0) 3 | 4 | function! QFixToggle(forced) 5 | if exists("g:qfix_win") && a:forced == 0 6 | cclose 7 | unlet g:qfix_win 8 | else 9 | copen 10 10 | let g:qfix_win=bufnr("$") 11 | endif 12 | endfunction 13 | 14 | nnoremap q :QFix 15 | 16 | autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$") 17 | -------------------------------------------------------------------------------- /plugin/settings/Rails.vim: -------------------------------------------------------------------------------- 1 | map gg :topleft 100 :split Gemfile 2 | map gr :topleft 100 :split config/routes.rb 3 | -------------------------------------------------------------------------------- /plugin/settings/ScriptRunner.vim: -------------------------------------------------------------------------------- 1 | " ActionScript 2 | autocmd BufRead,BufNewFile *.as map :silent !$FLEX_HOME/bin/mxmlc % \| iconv -f big5 -t utf-8:redraw!:echon "Done!" 3 | autocmd BufRead,BufNewFile *.mxml map :silent !$FLEX_HOME/bin/mxmlc % \| iconv -f big5 -t utf-8:redraw!:echon "Done!" 4 | 5 | " VimScript 6 | autocmd BufRead,BufNewFile *.vim map :source %:echon "script reloaded!" 7 | 8 | " CoffeeScript 9 | if executable("coffee") 10 | autocmd BufRead,BufNewFile *.coffee map :CoffeeRun 11 | else 12 | autocmd BufRead,BufNewFile *.coffee map :echo "you need to install CoffeeScript first!" 13 | endif 14 | 15 | " Javascript 16 | if executable("js") 17 | autocmd BufRead,BufNewFile *.js map :% w !js % 18 | else 19 | autocmd BufRead,BufNewFile *.js map :echo "you need to install SpiderMonkey first!" 20 | endif 21 | 22 | " PHP 23 | if executable("php") 24 | autocmd BufRead,BufNewFile *.php map :% w !php 25 | else 26 | autocmd BufRead,BufNewFile *.php map :echo "you need to install PHP first!" 27 | endif 28 | 29 | " Python 30 | if executable("python") 31 | autocmd BufRead,BufNewFile *.py map :% w !python 32 | else 33 | autocmd BufRead,BufNewFile *.py map :echo "you need to install Python first!" 34 | endif 35 | 36 | " Ruby 37 | if executable("ruby") 38 | autocmd BufRead,BufNewFile *.rb map :% w !ruby -w 39 | else 40 | autocmd BufRead,BufNewFile *.rb map :echo "you need to install Ruby first!" 41 | endif 42 | 43 | " Scala 44 | if executable("scala") 45 | autocmd BufRead,BufNewFile *.scala map :% w !scala % 46 | else 47 | autocmd BufRead,BufNewFile *.scala map :echo "you need to install Scala first!" 48 | end 49 | 50 | " Perl 51 | if executable("perl") 52 | autocmd BufRead,BufNewFile *.pl map :% w !perl % 53 | else 54 | autocmd BufRead,BufNewFile *.pl map :echo "you need to install Perl first!" 55 | end 56 | -------------------------------------------------------------------------------- /plugin/settings/SplitWindowResize.vim: -------------------------------------------------------------------------------- 1 | " split window resize 2 | if bufwinnr(1) 3 | map 0 :resize +10 4 | map 9 :resize -10 5 | map . :vertical resize +30 6 | map , :vertical resize -30 7 | map = :vertical resize +30 8 | map - :vertical resize -30 9 | endif 10 | 11 | " make the current window bigger 12 | set winheight=5 13 | set winminheight=5 14 | "set winheight=999 15 | -------------------------------------------------------------------------------- /plugin/settings/Surround.vim: -------------------------------------------------------------------------------- 1 | let g:surround_113="#{\r}" " v 2 | let g:surround_35="#{\r}" " # 3 | let g:surround_45="<% \r %>" " - 4 | let g:surround_61="<%= \r %>" " = 5 | -------------------------------------------------------------------------------- /plugin/settings/Utility.vim: -------------------------------------------------------------------------------- 1 | "cmap mm .!md5 -qs '' 2 | -------------------------------------------------------------------------------- /plugin/settings/Vimwiki.vim: -------------------------------------------------------------------------------- 1 | let g:vimwiki_camel_case = 0 2 | let g:vimwiki_list = [{'path': '~/Dropbox/vimwiki'}] 3 | -------------------------------------------------------------------------------- /pro-vimrc: -------------------------------------------------------------------------------- 1 | " Pro version Vimrc 2 | " I kept all other settings in plugins/settings directory 3 | " 4 | " Eddie Kao 5 | " http://blog.eddie.com.tw 6 | " eddie@digik.com.tw 7 | 8 | runtime bundle/vim-pathogen/autoload/pathogen.vim 9 | filetype off 10 | call pathogen#runtime_append_all_bundles() 11 | filetype plugin indent on 12 | call pathogen#infect() 13 | call pathogen#helptags() 14 | 15 | " force myself to not to use the error keys 16 | map 17 | map 18 | map 19 | map 20 | inoremap 21 | inoremap 22 | inoremap 23 | inoremap 24 | 25 | " cancel searched highlight 26 | noremap :nohlsearch 27 | -------------------------------------------------------------------------------- /pylibs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/__init__.py -------------------------------------------------------------------------------- /pylibs/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/__init__.pyc -------------------------------------------------------------------------------- /pylibs/autopep8.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/autopep8.pyc -------------------------------------------------------------------------------- /pylibs/logilab/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/logilab/__init__.py -------------------------------------------------------------------------------- /pylibs/logilab/astng/README: -------------------------------------------------------------------------------- 1 | ASTNG 2 | ===== 3 | 4 | What's this ? 5 | ------------- 6 | 7 | The aim of this module is to provide a common base representation of 8 | python source code for projects such as pychecker, pyreverse, 9 | pylint... Well, actually the development of this library is essentially 10 | governed by pylint's needs. 11 | 12 | It provides a compatible representation which comes from the `_ast` module. 13 | It rebuilds the tree generated by the builtin _ast module by recursively 14 | walking down the AST and building an extended ast (let's call it astng ;). The 15 | new node classes have additional methods and attributes for different usages. 16 | They include some support for static inference and local name scopes. 17 | Furthermore, astng builds partial trees by inspecting living objects. 18 | 19 | Main modules are: 20 | 21 | * `bases`, `node_classses` and `scoped_nodes` contain the classes for the 22 | different type of nodes of the tree. 23 | 24 | * the `manager` contains a high level object to get astng trees from 25 | source files and living objects. It maintains a cache of previously 26 | constructed tree for quick access 27 | 28 | 29 | Installation 30 | ------------ 31 | 32 | Extract the tarball, jump into the created directory and run :: 33 | 34 | python setup.py install 35 | 36 | For installation options, see :: 37 | 38 | python setup.py install --help 39 | 40 | 41 | If you have any questions, please mail the 42 | python-project@lists.logilab.org mailing list for support. See 43 | http://lists.logilab.org/mailman/listinfo/python-projects for 44 | subscription information and archives. 45 | 46 | Test 47 | ---- 48 | 49 | Tests are in the 'test' subdirectory. To launch the whole tests suite 50 | at once, you may use the 'pytest' utility from logilab-common (simply 51 | type 'pytest' from within this directory) or if you're running python 52 | >= 2.7, using discover, for instance:: 53 | 54 | python -m unittest discover -p "unittest*.py" 55 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/README.Python3: -------------------------------------------------------------------------------- 1 | Python3 2 | ======= 3 | 4 | Approach 5 | -------- 6 | 7 | We maintain a Python 2 base and use 2to3 to generate Python 3 code. 8 | 9 | 2to3 is integrated into the distutils installation process and will be run as a 10 | build step when invoked by the python3 interpreter:: 11 | 12 | python3 setup.py install --no-compile 13 | 14 | 15 | Debian 16 | ------ 17 | 18 | For the Debian packaging, you can use the debian.py3k/ content against 19 | the debian/ folder:: 20 | 21 | cp debian.py3k/* debian/ 22 | 23 | 24 | Resources 25 | --------- 26 | http://wiki.python.org/moin/PortingPythonToPy3k 27 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/__init__.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # copyright 2003-2010 Sylvain Thenault, all rights reserved. 4 | # contact mailto:thenault@gmail.com 5 | # 6 | # This file is part of logilab-astng. 7 | # 8 | # logilab-astng is free software: you can redistribute it and/or modify it 9 | # under the terms of the GNU Lesser General Public License as published by the 10 | # Free Software Foundation, either version 2.1 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # logilab-astng is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License along 19 | # with logilab-astng. If not, see . 20 | """Python Abstract Syntax Tree New Generation 21 | 22 | The aim of this module is to provide a common base representation of 23 | python source code for projects such as pychecker, pyreverse, 24 | pylint... Well, actually the development of this library is essentially 25 | governed by pylint's needs. 26 | 27 | It extends class defined in the python's _ast module with some 28 | additional methods and attributes. Instance attributes are added by a 29 | builder object, which can either generate extended ast (let's call 30 | them astng ;) by visiting an existent ast tree or by inspecting living 31 | object. Methods are added by monkey patching ast classes. 32 | 33 | Main modules are: 34 | 35 | * nodes and scoped_nodes for more information about methods and 36 | attributes added to different node classes 37 | 38 | * the manager contains a high level object to get astng trees from 39 | source files and living objects. It maintains a cache of previously 40 | constructed tree for quick access 41 | 42 | * builder contains the class responsible to build astng trees 43 | """ 44 | __doctype__ = "restructuredtext en" 45 | 46 | import sys 47 | if sys.version_info >= (3, 0): 48 | BUILTINS_MODULE = 'builtins' 49 | else: 50 | BUILTINS_MODULE = '__builtin__' 51 | 52 | # WARNING: internal imports order matters ! 53 | 54 | # make all exception classes accessible from astng package 55 | from logilab.astng.exceptions import * 56 | 57 | # make all node classes accessible from astng package 58 | from logilab.astng.nodes import * 59 | 60 | # trigger extra monkey-patching 61 | from logilab.astng import inference 62 | 63 | # more stuff available 64 | from logilab.astng import raw_building 65 | from logilab.astng.bases import YES, Instance, BoundMethod, UnboundMethod 66 | from logilab.astng.node_classes import are_exclusive, unpack_infer 67 | from logilab.astng.scoped_nodes import builtin_lookup 68 | 69 | # make a manager instance (borg) as well as Project and Package classes 70 | # accessible from astng package 71 | from logilab.astng.manager import ASTNGManager, Project 72 | MANAGER = ASTNGManager() 73 | del ASTNGManager 74 | 75 | # load brain plugins 76 | from os import listdir 77 | from os.path import join, dirname 78 | BRAIN_MODULES_DIR = join(dirname(__file__), 'brain') 79 | if BRAIN_MODULES_DIR not in sys.path: 80 | # add it to the end of the list so user path take precedence 81 | sys.path.append(BRAIN_MODULES_DIR) 82 | # load modules in this directory 83 | for module in listdir(BRAIN_MODULES_DIR): 84 | if module.endswith('.py'): 85 | __import__(module[:-3]) 86 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/__pkginfo__.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # copyright 2003-2010 Sylvain Thenault, all rights reserved. 4 | # contact mailto:thenault@gmail.com 5 | # 6 | # This file is part of logilab-astng. 7 | # 8 | # logilab-astng is free software: you can redistribute it and/or modify it 9 | # under the terms of the GNU Lesser General Public License as published by the 10 | # Free Software Foundation, either version 2.1 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # logilab-astng is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License along 19 | # with logilab-astng. If not, see . 20 | """logilab.astng packaging information""" 21 | 22 | distname = 'logilab-astng' 23 | 24 | modname = 'astng' 25 | subpackage_of = 'logilab' 26 | 27 | numversion = (0, 24, 0) 28 | version = '.'.join([str(num) for num in numversion]) 29 | 30 | install_requires = ['logilab-common >= 0.53.0'] 31 | 32 | license = 'LGPL' 33 | 34 | author = 'Logilab' 35 | author_email = 'python-projects@lists.logilab.org' 36 | mailinglist = "mailto://%s" % author_email 37 | web = "http://www.logilab.org/project/%s" % distname 38 | ftp = "ftp://ftp.logilab.org/pub/%s" % modname 39 | 40 | description = "rebuild a new abstract syntax tree from Python's ast" 41 | 42 | from os.path import join 43 | include_dirs = ['brain', 44 | join('test', 'regrtest_data'), 45 | join('test', 'data'), join('test', 'data2')] 46 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/brain/py2stdlib.py: -------------------------------------------------------------------------------- 1 | """ASTNG hooks for the Python 2 standard library. 2 | 3 | Currently help understanding of : 4 | 5 | * hashlib.md5 and hashlib.sha1 6 | """ 7 | 8 | from logilab.astng import MANAGER 9 | from logilab.astng.builder import ASTNGBuilder 10 | 11 | MODULE_TRANSFORMS = {} 12 | 13 | def hashlib_transform(module): 14 | fake = ASTNGBuilder(MANAGER).string_build(''' 15 | 16 | class md5(object): 17 | def __init__(self, value): pass 18 | def hexdigest(self): 19 | return u'' 20 | 21 | class sha1(object): 22 | def __init__(self, value): pass 23 | def hexdigest(self): 24 | return u'' 25 | 26 | ''') 27 | for hashfunc in ('sha1', 'md5'): 28 | module.locals[hashfunc] = fake.locals[hashfunc] 29 | 30 | def collections_transform(module): 31 | fake = ASTNGBuilder(MANAGER).string_build(''' 32 | 33 | class defaultdict(dict): 34 | default_factory = None 35 | def __missing__(self, key): pass 36 | 37 | class deque(object): 38 | maxlen = 0 39 | def __init__(iterable=None, maxlen=None): pass 40 | def append(self, x): pass 41 | def appendleft(self, x): pass 42 | def clear(self): pass 43 | def count(self, x): return 0 44 | def extend(self, iterable): pass 45 | def extendleft(self, iterable): pass 46 | def pop(self): pass 47 | def popleft(self): pass 48 | def remove(self, value): pass 49 | def reverse(self): pass 50 | def rotate(self, n): pass 51 | 52 | ''') 53 | 54 | for klass in ('deque', 'defaultdict'): 55 | module.locals[klass] = fake.locals[klass] 56 | 57 | def pkg_resources_transform(module): 58 | fake = ASTNGBuilder(MANAGER).string_build(''' 59 | 60 | def resource_exists(package_or_requirement, resource_name): 61 | pass 62 | 63 | def resource_isdir(package_or_requirement, resource_name): 64 | pass 65 | 66 | def resource_filename(package_or_requirement, resource_name): 67 | pass 68 | 69 | def resource_stream(package_or_requirement, resource_name): 70 | pass 71 | 72 | def resource_string(package_or_requirement, resource_name): 73 | pass 74 | 75 | def resource_listdir(package_or_requirement, resource_name): 76 | pass 77 | 78 | def extraction_error(): 79 | pass 80 | 81 | def get_cache_path(archive_name, names=()): 82 | pass 83 | 84 | def postprocess(tempname, filename): 85 | pass 86 | 87 | def set_extraction_path(path): 88 | pass 89 | 90 | def cleanup_resources(force=False): 91 | pass 92 | 93 | ''') 94 | 95 | for func_name, func in fake.locals.items(): 96 | module.locals[func_name] = func 97 | 98 | # for func in ('resource_exists', 'resource_isdir', 'resource_filename', 99 | # 'resource_stream', 'resource_string', 'resource_listdir', 100 | # 'extraction_error', 'get_cache_path', 'postprocess', 101 | # 'set_extraction_path', 'cleanup_resources'): 102 | 103 | # module.locals[func] = fake.locals[func] 104 | 105 | MODULE_TRANSFORMS['hashlib'] = hashlib_transform 106 | MODULE_TRANSFORMS['collections'] = collections_transform 107 | MODULE_TRANSFORMS['pkg_resources'] = pkg_resources_transform 108 | 109 | 110 | def transform(module): 111 | try: 112 | tr = MODULE_TRANSFORMS[module.name] 113 | except KeyError: 114 | pass 115 | else: 116 | tr(module) 117 | 118 | from logilab.astng import MANAGER 119 | MANAGER.register_transformer(transform) 120 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/exceptions.py: -------------------------------------------------------------------------------- 1 | # This program is free software; you can redistribute it and/or modify it under 2 | # the terms of the GNU Lesser General Public License as published by the Free Software 3 | # Foundation; either version 2 of the License, or (at your option) any later 4 | # version. 5 | # 6 | # This program is distributed in the hope that it will be useful, but WITHOUT 7 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 9 | # 10 | # You should have received a copy of the GNU Lesser General Public License along with 11 | # this program; if not, write to the Free Software Foundation, Inc., 12 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 13 | # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 14 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 15 | # copyright 2003-2010 Sylvain Thenault, all rights reserved. 16 | # contact mailto:thenault@gmail.com 17 | # 18 | # This file is part of logilab-astng. 19 | # 20 | # logilab-astng is free software: you can redistribute it and/or modify it 21 | # under the terms of the GNU Lesser General Public License as published by the 22 | # Free Software Foundation, either version 2.1 of the License, or (at your 23 | # option) any later version. 24 | # 25 | # logilab-astng is distributed in the hope that it will be useful, but 26 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 27 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 28 | # for more details. 29 | # 30 | # You should have received a copy of the GNU Lesser General Public License along 31 | # with logilab-astng. If not, see . 32 | """this module contains exceptions used in the astng library 33 | 34 | """ 35 | 36 | __doctype__ = "restructuredtext en" 37 | 38 | class ASTNGError(Exception): 39 | """base exception class for all astng related exceptions""" 40 | 41 | class ASTNGBuildingException(ASTNGError): 42 | """exception class when we are unable to build an astng representation""" 43 | 44 | class ResolveError(ASTNGError): 45 | """base class of astng resolution/inference error""" 46 | 47 | class NotFoundError(ResolveError): 48 | """raised when we are unable to resolve a name""" 49 | 50 | class InferenceError(ResolveError): 51 | """raised when we are unable to infer a node""" 52 | 53 | class UnresolvableName(InferenceError): 54 | """raised when we are unable to resolve a name""" 55 | 56 | class NoDefault(ASTNGError): 57 | """raised by function's `default_value` method when an argument has 58 | no default value 59 | """ 60 | 61 | -------------------------------------------------------------------------------- /pylibs/logilab/astng/nodes.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # copyright 2003-2010 Sylvain Thenault, all rights reserved. 4 | # contact mailto:thenault@gmail.com 5 | # 6 | # This file is part of logilab-astng. 7 | # 8 | # logilab-astng is free software: you can redistribute it and/or modify it 9 | # under the terms of the GNU Lesser General Public License as published by the 10 | # Free Software Foundation, either version 2.1 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # logilab-astng is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 16 | # for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License along 19 | # with logilab-astng. If not, see . 20 | """ 21 | on all nodes : 22 | .is_statement, returning true if the node should be considered as a 23 | statement node 24 | .root(), returning the root node of the tree (i.e. a Module) 25 | .previous_sibling(), returning previous sibling statement node 26 | .next_sibling(), returning next sibling statement node 27 | .statement(), returning the first parent node marked as statement node 28 | .frame(), returning the first node defining a new local scope (i.e. 29 | Module, Function or Class) 30 | .set_local(name, node), define an identifier on the first parent frame, 31 | with the node defining it. This is used by the astng builder and should not 32 | be used from out there. 33 | 34 | on From and Import : 35 | .real_name(name), 36 | 37 | 38 | """ 39 | 40 | __docformat__ = "restructuredtext en" 41 | 42 | from logilab.astng.node_classes import Arguments, AssAttr, Assert, Assign, \ 43 | AssName, AugAssign, Backquote, BinOp, BoolOp, Break, CallFunc, Compare, \ 44 | Comprehension, Const, Continue, Decorators, DelAttr, DelName, Delete, \ 45 | Dict, Discard, Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, For, \ 46 | From, Getattr, Global, If, IfExp, Import, Index, Keyword, \ 47 | List, Name, Nonlocal, Pass, Print, Raise, Return, Set, Slice, Starred, Subscript, \ 48 | TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, \ 49 | const_factory 50 | from logilab.astng.scoped_nodes import Module, GenExpr, Lambda, DictComp, \ 51 | ListComp, SetComp, Function, Class 52 | 53 | ALL_NODE_CLASSES = ( 54 | Arguments, AssAttr, Assert, Assign, AssName, AugAssign, 55 | Backquote, BinOp, BoolOp, Break, 56 | CallFunc, Class, Compare, Comprehension, Const, Continue, 57 | Decorators, DelAttr, DelName, Delete, 58 | Dict, DictComp, Discard, 59 | Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, 60 | For, From, Function, 61 | Getattr, GenExpr, Global, 62 | If, IfExp, Import, Index, 63 | Keyword, 64 | Lambda, List, ListComp, 65 | Name, Nonlocal, 66 | Module, 67 | Pass, Print, 68 | Raise, Return, 69 | Set, SetComp, Slice, Starred, Subscript, 70 | TryExcept, TryFinally, Tuple, 71 | UnaryOp, 72 | While, With, 73 | Yield, 74 | ) 75 | 76 | -------------------------------------------------------------------------------- /pylibs/logilab/common/README.Python3: -------------------------------------------------------------------------------- 1 | Python3 2 | ======= 3 | 4 | Approach 5 | -------- 6 | 7 | We maintain a Python 2 base and use 2to3 to generate Python 3 code. 8 | 9 | 2to3 is integrated into the distutils installation process and will be run as a 10 | build step when invoked by the python3 interpreter:: 11 | 12 | python3 setup.py install 13 | 14 | Tests 15 | ----- 16 | 17 | Set your PYTHONPATH and run pytest3 against the test directory. 18 | 19 | Debian 20 | ------ 21 | 22 | For the Debian packaging of python3-logilab-common, you can use the debian.sid/ 23 | content against the debian/ folder:: 24 | 25 | cp debian.sid/* debian/ 26 | 27 | Resources 28 | --------- 29 | http://wiki.python.org/moin/PortingPythonToPy3k 30 | -------------------------------------------------------------------------------- /pylibs/logilab/common/__pkginfo__.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """logilab.common packaging information""" 19 | __docformat__ = "restructuredtext en" 20 | import sys 21 | 22 | distname = 'logilab-common' 23 | modname = 'common' 24 | subpackage_of = 'logilab' 25 | subpackage_master = True 26 | 27 | numversion = (0, 58, 0) 28 | version = '.'.join([str(num) for num in numversion]) 29 | 30 | license = 'LGPL' # 2.1 or later 31 | description = "collection of low-level Python packages and modules used by Logilab projects" 32 | web = "http://www.logilab.org/project/%s" % distname 33 | ftp = "ftp://ftp.logilab.org/pub/%s" % modname 34 | mailinglist = "mailto://python-projects@lists.logilab.org" 35 | author = "Logilab" 36 | author_email = "contact@logilab.fr" 37 | 38 | 39 | from os.path import join 40 | scripts = [join('bin', 'pytest')] 41 | include_dirs = [join('test', 'data')] 42 | 43 | if sys.version_info < (2, 7): 44 | install_requires = ['unittest2 >= 0.5.1'] 45 | 46 | classifiers = ["Topic :: Utilities", 47 | "Programming Language :: Python", 48 | "Programming Language :: Python :: 2", 49 | "Programming Language :: Python :: 3", 50 | ] 51 | -------------------------------------------------------------------------------- /pylibs/logilab/common/announce.txt: -------------------------------------------------------------------------------- 1 | I'm pleased to announce the %(VERSION)s release of %(DISTNAME)s. 2 | 3 | What's new ? 4 | ------------ 5 | %(CHANGELOG)s 6 | 7 | 8 | What is %(DISTNAME)s ? 9 | ------------------------ 10 | %(LONG_DESC)s 11 | 12 | 13 | Home page 14 | --------- 15 | %(WEB)s 16 | 17 | Download 18 | -------- 19 | %(FTP)s 20 | 21 | Mailing list 22 | ------------ 23 | %(MAILINGLIST)s 24 | 25 | %(ADDITIONAL_DESCR)s 26 | -------------------------------------------------------------------------------- /pylibs/logilab/common/contexts.py: -------------------------------------------------------------------------------- 1 | from warnings import warn 2 | warn('logilab.common.contexts module is deprecated, use logilab.common.shellutils instead', 3 | DeprecationWarning, stacklevel=1) 4 | 5 | from logilab.common.shellutils import tempfile, pushd 6 | -------------------------------------------------------------------------------- /pylibs/logilab/common/daemon.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """A daemonize function (for Unices)""" 19 | 20 | __docformat__ = "restructuredtext en" 21 | 22 | import os 23 | import errno 24 | import signal 25 | import sys 26 | import time 27 | import warnings 28 | 29 | def setugid(user): 30 | """Change process user and group ID 31 | 32 | Argument is a numeric user id or a user name""" 33 | try: 34 | from pwd import getpwuid 35 | passwd = getpwuid(int(user)) 36 | except ValueError: 37 | from pwd import getpwnam 38 | passwd = getpwnam(user) 39 | 40 | if hasattr(os, 'initgroups'): # python >= 2.7 41 | os.initgroups(passwd.pw_name, passwd.pw_gid) 42 | else: 43 | import ctypes 44 | if ctypes.CDLL(None).initgroups(passwd.pw_name, passwd.pw_gid) < 0: 45 | err = ctypes.c_int.in_dll(ctypes.pythonapi,"errno").value 46 | raise OSError(err, os.strerror(err), 'initgroups') 47 | os.setgid(passwd.pw_gid) 48 | os.setuid(passwd.pw_uid) 49 | os.environ['HOME'] = passwd.pw_dir 50 | 51 | 52 | def daemonize(pidfile=None, uid=None, umask=077): 53 | """daemonize a Unix process. Set paranoid umask by default. 54 | 55 | Return 1 in the original process, 2 in the first fork, and None for the 56 | second fork (eg daemon process). 57 | """ 58 | # http://www.faqs.org/faqs/unix-faq/programmer/faq/ 59 | # 60 | # fork so the parent can exit 61 | if os.fork(): # launch child and... 62 | return 1 63 | # disconnect from tty and create a new session 64 | os.setsid() 65 | # fork again so the parent, (the session group leader), can exit. 66 | # as a non-session group leader, we can never regain a controlling 67 | # terminal. 68 | if os.fork(): # launch child again. 69 | return 2 70 | # move to the root to avoit mount pb 71 | os.chdir('/') 72 | # set umask if specified 73 | if umask is not None: 74 | os.umask(umask) 75 | # redirect standard descriptors 76 | null = os.open('/dev/null', os.O_RDWR) 77 | for i in range(3): 78 | try: 79 | os.dup2(null, i) 80 | except OSError, e: 81 | if e.errno != errno.EBADF: 82 | raise 83 | os.close(null) 84 | # filter warnings 85 | warnings.filterwarnings('ignore') 86 | # write pid in a file 87 | if pidfile: 88 | # ensure the directory where the pid-file should be set exists (for 89 | # instance /var/run/cubicweb may be deleted on computer restart) 90 | piddir = os.path.dirname(pidfile) 91 | if not os.path.exists(piddir): 92 | os.makedirs(piddir) 93 | f = file(pidfile, 'w') 94 | f.write(str(os.getpid())) 95 | f.close() 96 | os.chmod(pidfile, 0644) 97 | # change process uid 98 | if uid: 99 | setugid(uid) 100 | return None 101 | -------------------------------------------------------------------------------- /pylibs/logilab/common/interface.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """Bases class for interfaces to provide 'light' interface handling. 19 | 20 | TODO: 21 | _ implements a check method which check that an object implements the 22 | interface 23 | _ Attribute objects 24 | 25 | This module requires at least python 2.2 26 | """ 27 | __docformat__ = "restructuredtext en" 28 | 29 | 30 | class Interface(object): 31 | """Base class for interfaces.""" 32 | def is_implemented_by(cls, instance): 33 | return implements(instance, cls) 34 | is_implemented_by = classmethod(is_implemented_by) 35 | 36 | 37 | def implements(obj, interface): 38 | """Return true if the give object (maybe an instance or class) implements 39 | the interface. 40 | """ 41 | kimplements = getattr(obj, '__implements__', ()) 42 | if not isinstance(kimplements, (list, tuple)): 43 | kimplements = (kimplements,) 44 | for implementedinterface in kimplements: 45 | if issubclass(implementedinterface, interface): 46 | return True 47 | return False 48 | 49 | 50 | def extend(klass, interface, _recurs=False): 51 | """Add interface to klass'__implements__ if not already implemented in. 52 | 53 | If klass is subclassed, ensure subclasses __implements__ it as well. 54 | 55 | NOTE: klass should be e new class. 56 | """ 57 | if not implements(klass, interface): 58 | try: 59 | kimplements = klass.__implements__ 60 | kimplementsklass = type(kimplements) 61 | kimplements = list(kimplements) 62 | except AttributeError: 63 | kimplementsklass = tuple 64 | kimplements = [] 65 | kimplements.append(interface) 66 | klass.__implements__ = kimplementsklass(kimplements) 67 | for subklass in klass.__subclasses__(): 68 | extend(subklass, interface, _recurs=True) 69 | elif _recurs: 70 | for subklass in klass.__subclasses__(): 71 | extend(subklass, interface, _recurs=True) 72 | -------------------------------------------------------------------------------- /pylibs/logilab/common/optparser.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 3 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 4 | # 5 | # This file is part of logilab-common. 6 | # 7 | # logilab-common is free software: you can redistribute it and/or modify it under 8 | # the terms of the GNU Lesser General Public License as published by the Free 9 | # Software Foundation, either version 2.1 of the License, or (at your option) any 10 | # later version. 11 | # 12 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | # details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License along 18 | # with logilab-common. If not, see . 19 | """Extend OptionParser with commands. 20 | 21 | Example: 22 | 23 | >>> parser = OptionParser() 24 | >>> parser.usage = '%prog COMMAND [options] ...' 25 | >>> parser.add_command('build', 'mymod.build') 26 | >>> parser.add_command('clean', run_clean, add_opt_clean) 27 | >>> run, options, args = parser.parse_command(sys.argv[1:]) 28 | >>> return run(options, args[1:]) 29 | 30 | With mymod.build that defines two functions run and add_options 31 | """ 32 | __docformat__ = "restructuredtext en" 33 | 34 | from warnings import warn 35 | warn('lgc.optparser module is deprecated, use lgc.clcommands instead', DeprecationWarning, 36 | stacklevel=2) 37 | 38 | import sys 39 | import optparse 40 | 41 | class OptionParser(optparse.OptionParser): 42 | 43 | def __init__(self, *args, **kwargs): 44 | optparse.OptionParser.__init__(self, *args, **kwargs) 45 | self._commands = {} 46 | self.min_args, self.max_args = 0, 1 47 | 48 | def add_command(self, name, mod_or_funcs, help=''): 49 | """name of the command, name of module or tuple of functions 50 | (run, add_options) 51 | """ 52 | assert isinstance(mod_or_funcs, str) or isinstance(mod_or_funcs, tuple), \ 53 | "mod_or_funcs has to be a module name or a tuple of functions" 54 | self._commands[name] = (mod_or_funcs, help) 55 | 56 | def print_main_help(self): 57 | optparse.OptionParser.print_help(self) 58 | print '\ncommands:' 59 | for cmdname, (_, help) in self._commands.items(): 60 | print '% 10s - %s' % (cmdname, help) 61 | 62 | def parse_command(self, args): 63 | if len(args) == 0: 64 | self.print_main_help() 65 | sys.exit(1) 66 | cmd = args[0] 67 | args = args[1:] 68 | if cmd not in self._commands: 69 | if cmd in ('-h', '--help'): 70 | self.print_main_help() 71 | sys.exit(0) 72 | elif self.version is not None and cmd == "--version": 73 | self.print_version() 74 | sys.exit(0) 75 | self.error('unknown command') 76 | self.prog = '%s %s' % (self.prog, cmd) 77 | mod_or_f, help = self._commands[cmd] 78 | # optparse inserts self.description between usage and options help 79 | self.description = help 80 | if isinstance(mod_or_f, str): 81 | exec 'from %s import run, add_options' % mod_or_f 82 | else: 83 | run, add_options = mod_or_f 84 | add_options(self) 85 | (options, args) = self.parse_args(args) 86 | if not (self.min_args <= len(args) <= self.max_args): 87 | self.error('incorrect number of arguments') 88 | return run, options, args 89 | 90 | 91 | -------------------------------------------------------------------------------- /pylibs/logilab/common/pdf_ext.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """Manipulate pdf and fdf files (pdftk recommended). 19 | 20 | Notes regarding pdftk, pdf forms and fdf files (form definition file) 21 | fields names can be extracted with: 22 | 23 | pdftk orig.pdf generate_fdf output truc.fdf 24 | 25 | to merge fdf and pdf: 26 | 27 | pdftk orig.pdf fill_form test.fdf output result.pdf [flatten] 28 | 29 | without flatten, one could further edit the resulting form. 30 | with flatten, everything is turned into text. 31 | 32 | 33 | 34 | 35 | """ 36 | __docformat__ = "restructuredtext en" 37 | # XXX seems very unix specific 38 | # TODO: check availability of pdftk at import 39 | 40 | 41 | import os 42 | 43 | HEAD="""%FDF-1.2 44 | %\xE2\xE3\xCF\xD3 45 | 1 0 obj 46 | << 47 | /FDF 48 | << 49 | /Fields [ 50 | """ 51 | 52 | TAIL="""] 53 | >> 54 | >> 55 | endobj 56 | trailer 57 | 58 | << 59 | /Root 1 0 R 60 | >> 61 | %%EOF 62 | """ 63 | 64 | def output_field( f ): 65 | return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] ) 66 | 67 | def extract_keys(lines): 68 | keys = [] 69 | for line in lines: 70 | if line.startswith('/V'): 71 | pass #print 'value',line 72 | elif line.startswith('/T'): 73 | key = line[7:-2] 74 | key = ''.join(key.split('\x00')) 75 | keys.append( key ) 76 | return keys 77 | 78 | def write_field(out, key, value): 79 | out.write("<<\n") 80 | if value: 81 | out.write("/V (%s)\n" %value) 82 | else: 83 | out.write("/V /\n") 84 | out.write("/T (%s)\n" % output_field(key) ) 85 | out.write(">> \n") 86 | 87 | def write_fields(out, fields): 88 | out.write(HEAD) 89 | for (key, value, comment) in fields: 90 | write_field(out, key, value) 91 | write_field(out, key+"a", value) # pour copie-carbone sur autres pages 92 | out.write(TAIL) 93 | 94 | def extract_keys_from_pdf(filename): 95 | # what about using 'pdftk filename dump_data_fields' and parsing the output ? 96 | os.system('pdftk %s generate_fdf output /tmp/toto.fdf' % filename) 97 | lines = file('/tmp/toto.fdf').readlines() 98 | return extract_keys(lines) 99 | 100 | 101 | def fill_pdf(infile, outfile, fields): 102 | write_fields(file('/tmp/toto.fdf', 'w'), fields) 103 | os.system('pdftk %s fill_form /tmp/toto.fdf output %s flatten' % (infile, outfile)) 104 | 105 | def testfill_pdf(infile, outfile): 106 | keys = extract_keys_from_pdf(infile) 107 | fields = [] 108 | for key in keys: 109 | fields.append( (key, key, '') ) 110 | fill_pdf(infile, outfile, fields) 111 | 112 | -------------------------------------------------------------------------------- /pylibs/logilab/common/sphinx_ext.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | from logilab.common.decorators import monkeypatch 19 | 20 | from sphinx.ext import autodoc 21 | 22 | class DocstringOnlyModuleDocumenter(autodoc.ModuleDocumenter): 23 | objtype = 'docstring' 24 | def format_signature(self): 25 | pass 26 | def add_directive_header(self, sig): 27 | pass 28 | def document_members(self, all_members=False): 29 | pass 30 | 31 | def resolve_name(self, modname, parents, path, base): 32 | if modname is not None: 33 | return modname, parents + [base] 34 | return (path or '') + base, [] 35 | 36 | 37 | #autodoc.add_documenter(DocstringOnlyModuleDocumenter) 38 | 39 | def setup(app): 40 | app.add_autodocumenter(DocstringOnlyModuleDocumenter) 41 | 42 | 43 | 44 | from sphinx.ext.autodoc import (ViewList, Options, AutodocReporter, nodes, 45 | assemble_option_dict, nested_parse_with_titles) 46 | 47 | @monkeypatch(autodoc.AutoDirective) 48 | def run(self): 49 | self.filename_set = set() # a set of dependent filenames 50 | self.reporter = self.state.document.reporter 51 | self.env = self.state.document.settings.env 52 | self.warnings = [] 53 | self.result = ViewList() 54 | 55 | # find out what documenter to call 56 | objtype = self.name[4:] 57 | doc_class = self._registry[objtype] 58 | # process the options with the selected documenter's option_spec 59 | self.genopt = Options(assemble_option_dict( 60 | self.options.items(), doc_class.option_spec)) 61 | # generate the output 62 | documenter = doc_class(self, self.arguments[0]) 63 | documenter.generate(more_content=self.content) 64 | if not self.result: 65 | return self.warnings 66 | 67 | # record all filenames as dependencies -- this will at least 68 | # partially make automatic invalidation possible 69 | for fn in self.filename_set: 70 | self.env.note_dependency(fn) 71 | 72 | # use a custom reporter that correctly assigns lines to source 73 | # filename/description and lineno 74 | old_reporter = self.state.memo.reporter 75 | self.state.memo.reporter = AutodocReporter(self.result, 76 | self.state.memo.reporter) 77 | if self.name in ('automodule', 'autodocstring'): 78 | node = nodes.section() 79 | # necessary so that the child nodes get the right source/line set 80 | node.document = self.state.document 81 | nested_parse_with_titles(self.state, self.result, node) 82 | else: 83 | node = nodes.paragraph() 84 | node.document = self.state.document 85 | self.state.nested_parse(self.result, 0, node) 86 | self.state.memo.reporter = old_reporter 87 | return self.warnings + node.children 88 | -------------------------------------------------------------------------------- /pylibs/logilab/common/tasksqueue.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """Prioritized tasks queue""" 19 | 20 | __docformat__ = "restructuredtext en" 21 | 22 | from bisect import insort_left 23 | from Queue import Queue 24 | 25 | LOW = 0 26 | MEDIUM = 10 27 | HIGH = 100 28 | 29 | PRIORITY = { 30 | 'LOW': LOW, 31 | 'MEDIUM': MEDIUM, 32 | 'HIGH': HIGH, 33 | } 34 | REVERSE_PRIORITY = dict((values, key) for key, values in PRIORITY.iteritems()) 35 | 36 | 37 | 38 | class PrioritizedTasksQueue(Queue): 39 | 40 | def _init(self, maxsize): 41 | """Initialize the queue representation""" 42 | self.maxsize = maxsize 43 | # ordered list of task, from the lowest to the highest priority 44 | self.queue = [] 45 | 46 | def _put(self, item): 47 | """Put a new item in the queue""" 48 | for i, task in enumerate(self.queue): 49 | # equivalent task 50 | if task == item: 51 | # if new task has a higher priority, remove the one already 52 | # queued so the new priority will be considered 53 | if task < item: 54 | item.merge(task) 55 | del self.queue[i] 56 | break 57 | # else keep it so current order is kept 58 | task.merge(item) 59 | return 60 | insort_left(self.queue, item) 61 | 62 | def _get(self): 63 | """Get an item from the queue""" 64 | return self.queue.pop() 65 | 66 | def __iter__(self): 67 | return iter(self.queue) 68 | 69 | def remove(self, tid): 70 | """remove a specific task from the queue""" 71 | # XXX acquire lock 72 | for i, task in enumerate(self): 73 | if task.id == tid: 74 | self.queue.pop(i) 75 | return 76 | raise ValueError('not task of id %s in queue' % tid) 77 | 78 | class Task(object): 79 | def __init__(self, tid, priority=LOW): 80 | # task id 81 | self.id = tid 82 | # task priority 83 | self.priority = priority 84 | 85 | def __repr__(self): 86 | return '' % (self.id, id(self)) 87 | 88 | def __cmp__(self, other): 89 | return cmp(self.priority, other.priority) 90 | 91 | def __lt__(self, other): 92 | return self.priority < other.priority 93 | 94 | def __eq__(self, other): 95 | return self.id == other.id 96 | 97 | def merge(self, other): 98 | pass 99 | -------------------------------------------------------------------------------- /pylibs/logilab/common/urllib2ext.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import urllib2 3 | 4 | import kerberos as krb 5 | 6 | class GssapiAuthError(Exception): 7 | """raised on error during authentication process""" 8 | 9 | import re 10 | RGX = re.compile('(?:.*,)*\s*Negotiate\s*([^,]*),?', re.I) 11 | 12 | def get_negociate_value(headers): 13 | for authreq in headers.getheaders('www-authenticate'): 14 | match = RGX.search(authreq) 15 | if match: 16 | return match.group(1) 17 | 18 | class HTTPGssapiAuthHandler(urllib2.BaseHandler): 19 | """Negotiate HTTP authentication using context from GSSAPI""" 20 | 21 | handler_order = 400 # before Digest Auth 22 | 23 | def __init__(self): 24 | self._reset() 25 | 26 | def _reset(self): 27 | self._retried = 0 28 | self._context = None 29 | 30 | def clean_context(self): 31 | if self._context is not None: 32 | krb.authGSSClientClean(self._context) 33 | 34 | def http_error_401(self, req, fp, code, msg, headers): 35 | try: 36 | if self._retried > 5: 37 | raise urllib2.HTTPError(req.get_full_url(), 401, 38 | "negotiate auth failed", headers, None) 39 | self._retried += 1 40 | logging.debug('gssapi handler, try %s' % self._retried) 41 | negotiate = get_negociate_value(headers) 42 | if negotiate is None: 43 | logging.debug('no negociate found in a www-authenticate header') 44 | return None 45 | logging.debug('HTTPGssapiAuthHandler: negotiate 1 is %r' % negotiate) 46 | result, self._context = krb.authGSSClientInit("HTTP@%s" % req.get_host()) 47 | if result < 1: 48 | raise GssapiAuthError("HTTPGssapiAuthHandler: init failed with %d" % result) 49 | result = krb.authGSSClientStep(self._context, negotiate) 50 | if result < 0: 51 | raise GssapiAuthError("HTTPGssapiAuthHandler: step 1 failed with %d" % result) 52 | client_response = krb.authGSSClientResponse(self._context) 53 | logging.debug('HTTPGssapiAuthHandler: client response is %s...' % client_response[:10]) 54 | req.add_unredirected_header('Authorization', "Negotiate %s" % client_response) 55 | server_response = self.parent.open(req) 56 | negotiate = get_negociate_value(server_response.info()) 57 | if negotiate is None: 58 | logging.warning('HTTPGssapiAuthHandler: failed to authenticate server') 59 | else: 60 | logging.debug('HTTPGssapiAuthHandler negotiate 2: %s' % negotiate) 61 | result = krb.authGSSClientStep(self._context, negotiate) 62 | if result < 1: 63 | raise GssapiAuthError("HTTPGssapiAuthHandler: step 2 failed with %d" % result) 64 | return server_response 65 | except GssapiAuthError, exc: 66 | logging.error(repr(exc)) 67 | finally: 68 | self.clean_context() 69 | self._reset() 70 | 71 | if __name__ == '__main__': 72 | import sys 73 | # debug 74 | import httplib 75 | httplib.HTTPConnection.debuglevel = 1 76 | httplib.HTTPSConnection.debuglevel = 1 77 | # debug 78 | import logging 79 | logging.basicConfig(level=logging.DEBUG) 80 | # handle cookies 81 | import cookielib 82 | cj = cookielib.CookieJar() 83 | ch = urllib2.HTTPCookieProcessor(cj) 84 | # test with url sys.argv[1] 85 | h = HTTPGssapiAuthHandler() 86 | response = urllib2.build_opener(h, ch).open(sys.argv[1]) 87 | print '\nresponse: %s\n--------------\n' % response.code, response.info() 88 | -------------------------------------------------------------------------------- /pylibs/logilab/common/visitor.py: -------------------------------------------------------------------------------- 1 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 2 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 3 | # 4 | # This file is part of logilab-common. 5 | # 6 | # logilab-common is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Lesser General Public License as published by the Free 8 | # Software Foundation, either version 2.1 of the License, or (at your option) any 9 | # later version. 10 | # 11 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | # details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License along 17 | # with logilab-common. If not, see . 18 | """A generic visitor abstract implementation. 19 | 20 | 21 | 22 | 23 | """ 24 | __docformat__ = "restructuredtext en" 25 | 26 | def no_filter(_): 27 | return 1 28 | 29 | # Iterators ################################################################### 30 | class FilteredIterator(object): 31 | 32 | def __init__(self, node, list_func, filter_func=None): 33 | self._next = [(node, 0)] 34 | if filter_func is None: 35 | filter_func = no_filter 36 | self._list = list_func(node, filter_func) 37 | 38 | def next(self): 39 | try: 40 | return self._list.pop(0) 41 | except : 42 | return None 43 | 44 | # Base Visitor ################################################################ 45 | class Visitor(object): 46 | 47 | def __init__(self, iterator_class, filter_func=None): 48 | self._iter_class = iterator_class 49 | self.filter = filter_func 50 | 51 | def visit(self, node, *args, **kargs): 52 | """ 53 | launch the visit on a given node 54 | 55 | call 'open_visit' before the beginning of the visit, with extra args 56 | given 57 | when all nodes have been visited, call the 'close_visit' method 58 | """ 59 | self.open_visit(node, *args, **kargs) 60 | return self.close_visit(self._visit(node)) 61 | 62 | def _visit(self, node): 63 | iterator = self._get_iterator(node) 64 | n = iterator.next() 65 | while n: 66 | result = n.accept(self) 67 | n = iterator.next() 68 | return result 69 | 70 | def _get_iterator(self, node): 71 | return self._iter_class(node, self.filter) 72 | 73 | def open_visit(self, *args, **kargs): 74 | """ 75 | method called at the beginning of the visit 76 | """ 77 | pass 78 | 79 | def close_visit(self, result): 80 | """ 81 | method called at the end of the visit 82 | """ 83 | return result 84 | 85 | # standard visited mixin ###################################################### 86 | class VisitedMixIn(object): 87 | """ 88 | Visited interface allow node visitors to use the node 89 | """ 90 | def get_visit_name(self): 91 | """ 92 | return the visit name for the mixed class. When calling 'accept', the 93 | method <'visit_' + name returned by this method> will be called on the 94 | visitor 95 | """ 96 | try: 97 | return self.TYPE.replace('-', '_') 98 | except: 99 | return self.__class__.__name__.lower() 100 | 101 | def accept(self, visitor, *args, **kwargs): 102 | func = getattr(visitor, 'visit_%s' % self.get_visit_name()) 103 | return func(self, *args, **kwargs) 104 | 105 | def leave(self, visitor, *args, **kwargs): 106 | func = getattr(visitor, 'leave_%s' % self.get_visit_name()) 107 | return func(self, *args, **kwargs) 108 | -------------------------------------------------------------------------------- /pylibs/logilab/common/xmlutils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 3 | # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 4 | # 5 | # This file is part of logilab-common. 6 | # 7 | # logilab-common is free software: you can redistribute it and/or modify it under 8 | # the terms of the GNU Lesser General Public License as published by the Free 9 | # Software Foundation, either version 2.1 of the License, or (at your option) any 10 | # later version. 11 | # 12 | # logilab-common is distributed in the hope that it will be useful, but WITHOUT 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 15 | # details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License along 18 | # with logilab-common. If not, see . 19 | """XML utilities. 20 | 21 | This module contains useful functions for parsing and using XML data. For the 22 | moment, there is only one function that can parse the data inside a processing 23 | instruction and return a Python dictionary. 24 | 25 | 26 | 27 | 28 | """ 29 | __docformat__ = "restructuredtext en" 30 | 31 | import re 32 | 33 | RE_DOUBLE_QUOTE = re.compile('([\w\-\.]+)="([^"]+)"') 34 | RE_SIMPLE_QUOTE = re.compile("([\w\-\.]+)='([^']+)'") 35 | 36 | def parse_pi_data(pi_data): 37 | """ 38 | Utility function that parses the data contained in an XML 39 | processing instruction and returns a dictionary of keywords and their 40 | associated values (most of the time, the processing instructions contain 41 | data like ``keyword="value"``, if a keyword is not associated to a value, 42 | for example ``keyword``, it will be associated to ``None``). 43 | 44 | :param pi_data: data contained in an XML processing instruction. 45 | :type pi_data: unicode 46 | 47 | :returns: Dictionary of the keywords (Unicode strings) associated to 48 | their values (Unicode strings) as they were defined in the 49 | data. 50 | :rtype: dict 51 | """ 52 | results = {} 53 | for elt in pi_data.split(): 54 | if RE_DOUBLE_QUOTE.match(elt): 55 | kwd, val = RE_DOUBLE_QUOTE.match(elt).groups() 56 | elif RE_SIMPLE_QUOTE.match(elt): 57 | kwd, val = RE_SIMPLE_QUOTE.match(elt).groups() 58 | else: 59 | kwd, val = elt, None 60 | results[kwd] = val 61 | return results 62 | -------------------------------------------------------------------------------- /pylibs/pep8.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pep8.pyc -------------------------------------------------------------------------------- /pylibs/pyflakes/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __version__ = '0.4.0' 3 | -------------------------------------------------------------------------------- /pylibs/pyflakes/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pyflakes/__init__.pyc -------------------------------------------------------------------------------- /pylibs/pyflakes/checker.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pyflakes/checker.pyc -------------------------------------------------------------------------------- /pylibs/pyflakes/messages.py: -------------------------------------------------------------------------------- 1 | # (c) 2005 Divmod, Inc. See LICENSE file for details 2 | 3 | class Message(object): 4 | message = '' 5 | message_args = () 6 | def __init__(self, filename, loc, use_column=True): 7 | self.filename = filename 8 | self.lineno = loc.lineno 9 | self.col = getattr(loc, 'col_offset', None) if use_column else None 10 | 11 | def __str__(self): 12 | return '%s:%s: %s' % (self.filename, self.lineno, self.message % self.message_args) 13 | 14 | 15 | class UnusedImport(Message): 16 | message = 'W402 %r imported but unused' 17 | 18 | def __init__(self, filename, lineno, name): 19 | Message.__init__(self, filename, lineno) 20 | self.message_args = (name,) 21 | 22 | 23 | class RedefinedWhileUnused(Message): 24 | message = 'W801 redefinition of unused %r from line %r' 25 | 26 | def __init__(self, filename, lineno, name, orig_lineno): 27 | Message.__init__(self, filename, lineno) 28 | self.message_args = (name, orig_lineno) 29 | 30 | 31 | class ImportShadowedByLoopVar(Message): 32 | message = 'W403 import %r from line %r shadowed by loop variable' 33 | 34 | def __init__(self, filename, lineno, name, orig_lineno): 35 | Message.__init__(self, filename, lineno) 36 | self.message_args = (name, orig_lineno) 37 | 38 | 39 | class ImportStarUsed(Message): 40 | message = "W404 'from %s import *' used; unable to detect undefined names" 41 | 42 | def __init__(self, filename, lineno, modname): 43 | Message.__init__(self, filename, lineno) 44 | self.message_args = (modname,) 45 | 46 | 47 | class UndefinedName(Message): 48 | message = 'W802 undefined name %r' 49 | 50 | def __init__(self, filename, lineno, name): 51 | Message.__init__(self, filename, lineno) 52 | self.message_args = (name,) 53 | 54 | 55 | class UndefinedExport(Message): 56 | message = 'W803 undefined name %r in __all__' 57 | 58 | def __init__(self, filename, lineno, name): 59 | Message.__init__(self, filename, lineno) 60 | self.message_args = (name,) 61 | 62 | 63 | class UndefinedLocal(Message): 64 | message = "W804 local variable %r (defined in enclosing scope on line " \ 65 | "%r) referenced before assignment" 66 | 67 | def __init__(self, filename, lineno, name, orig_lineno): 68 | Message.__init__(self, filename, lineno) 69 | self.message_args = (name, orig_lineno) 70 | 71 | 72 | class DuplicateArgument(Message): 73 | message = 'W805 duplicate argument %r in function definition' 74 | 75 | def __init__(self, filename, lineno, name): 76 | Message.__init__(self, filename, lineno) 77 | self.message_args = (name,) 78 | 79 | 80 | class RedefinedFunction(Message): 81 | message = 'W806 redefinition of function %r from line %r' 82 | 83 | def __init__(self, filename, lineno, name, orig_lineno): 84 | Message.__init__(self, filename, lineno) 85 | self.message_args = (name, orig_lineno) 86 | 87 | 88 | class LateFutureImport(Message): 89 | message = 'W405 future import(s) %r after other statements' 90 | 91 | def __init__(self, filename, lineno, names): 92 | Message.__init__(self, filename, lineno) 93 | self.message_args = (names,) 94 | 95 | 96 | class UnusedVariable(Message): 97 | """ 98 | Indicates that a variable has been explicity assigned to but not actually 99 | used. 100 | """ 101 | 102 | message = 'W806 local variable %r is assigned to but never used' 103 | 104 | def __init__(self, filename, lineno, names): 105 | Message.__init__(self, filename, lineno) 106 | self.message_args = (names,) 107 | -------------------------------------------------------------------------------- /pylibs/pyflakes/messages.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pyflakes/messages.pyc -------------------------------------------------------------------------------- /pylibs/pylint/README: -------------------------------------------------------------------------------- 1 | README for PyLint 2 | ================= 3 | 4 | Dependencies 5 | ------------ 6 | Pylint requires the logilab-astng (version >= 0.21.0), logilab-common 7 | (version >= 0.53). 8 | 9 | * http://www.logilab.org/projects/astng 10 | * http://www.logilab.org/projects/common 11 | 12 | Install 13 | ------- 14 | From the source distribution, extract the tarball and run :: 15 | 16 | python setup.py install 17 | 18 | You'll have to install dependencies in a similar way. For debian and 19 | rpm packages, use your usual tools according to your Linux distribution. 20 | 21 | More information about installation and available distribution format 22 | may be found in the user manual in the *doc* subdirectory. 23 | 24 | Documentation 25 | ------------- 26 | Look in the doc/ subdirectory or at the project home page 27 | http://www.logilab.org/project/pylint 28 | 29 | Pylint is shipped with following additional commands: 30 | 31 | * pyreverse: an UML diagram generator 32 | * symilar: an independent similarities checker 33 | * epylint: Emacs and Flymake compatible Pylint 34 | * pylint-gui: a graphical interface 35 | 36 | Comments, support, bug reports 37 | ------------------------------ 38 | 39 | Project page and tracker on : 40 | http://www.logilab.org/project/pylint 41 | 42 | Use the python-projects@logilab.org mailing list. 43 | You can subscribe to this mailing list at 44 | http://lists.logilab.org/mailman/listinfo/python-projects 45 | 46 | Archives are available at 47 | http://lists.logilab.org/pipermail/python-projects/ 48 | 49 | Contributors 50 | ------------ 51 | 52 | order doesn't matter... 53 | 54 | * Sylvain Thenault: main author / maintainer 55 | * Alexandre Fayolle: TkInter gui, documentation, debian support 56 | * Emile Anclin: used to maintain, py3k support 57 | * Mads Kiilerich: various patches 58 | * Torsten Marek, various patches 59 | * Boris Feld, various patches 60 | * Brian van den Broek: windows installation documentation 61 | * Amaury Forgeot d'Arc: patch to check names imported from a module 62 | exists in the module 63 | * Benjamin Niemann: patch to allow block level enabling/disabling of messages 64 | * Nathaniel Manista: suspicious lambda checking 65 | * Wolfgang Grafen, Axel Muller, Fabio Zadrozny, Pierre Rouleau, 66 | Maarten ter Huurne, Mirko Friedenhagen (among others): 67 | bug reports, feedback, feature requests... 68 | * All the Logilab's team: daily use, bug reports, feature requests 69 | * Other people have contributed by their feedback, if I've forgotten 70 | you, send me a note ! 71 | -------------------------------------------------------------------------------- /pylibs/pylint/README.Python3: -------------------------------------------------------------------------------- 1 | Python3 2 | ======= 3 | 4 | Compatibility 5 | ------------- 6 | 7 | Please, consider python3 >= 3.2 only. 8 | 9 | 10 | Approach 11 | -------- 12 | 13 | We maintain a Python 2 base and use 2to3 to generate Python 3 code. 14 | 15 | 2to3 is integrated into the distutils installation process and will be run as a 16 | build step when invoked by the python3 interpreter:: 17 | 18 | NO_SETUPTOOLS=1 python3 setup.py install --no-compile 19 | 20 | In order to run pylint locally, you have to install the dependencies:: 21 | 22 | easy_install-3.2 logilab-common 23 | easy_install-3.2 logilab-astng 24 | 25 | 26 | Debian 27 | ------ 28 | 29 | For the Debian packaging, you can use the debian.py3k/ content against 30 | the debian/ folder:: 31 | 32 | cp debian.py3k/* debian/ 33 | 34 | 35 | Resources 36 | --------- 37 | http://wiki.python.org/moin/PortingPythonToPy3k 38 | -------------------------------------------------------------------------------- /pylibs/pylint/__init__.py: -------------------------------------------------------------------------------- 1 | # This program is free software; you can redistribute it and/or modify it under 2 | # the terms of the GNU General Public License as published by the Free Software 3 | # Foundation; either version 2 of the License, or (at your option) any later 4 | # version. 5 | # 6 | # This program is distributed in the hope that it will be useful, but WITHOUT 7 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 9 | # 10 | # You should have received a copy of the GNU General Public License along with 11 | # this program; if not, write to the Free Software Foundation, Inc., 12 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 13 | """ Copyright (c) 2002-2008 LOGILAB S.A. (Paris, FRANCE). 14 | http://www.logilab.fr/ -- mailto:contact@logilab.fr 15 | """ 16 | 17 | -------------------------------------------------------------------------------- /pylibs/pylint/__pkginfo__.py: -------------------------------------------------------------------------------- 1 | # pylint: disable=W0622,C0103 2 | # Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE). 3 | # http://www.logilab.fr/ -- mailto:contact@logilab.fr 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; either version 2 of the License, or (at your option) any later 8 | # version. 9 | # 10 | # This program is distributed in the hope that it will be useful, but WITHOUT 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 13 | # 14 | # You should have received a copy of the GNU General Public License along with 15 | # this program; if not, write to the Free Software Foundation, Inc., 16 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | """pylint packaging information""" 18 | 19 | modname = distname = 'pylint' 20 | 21 | numversion = (0, 25, 2) 22 | version = '.'.join([str(num) for num in numversion]) 23 | 24 | install_requires = ['logilab-common >= 0.53.0', 'logilab-astng >= 0.21.1'] 25 | 26 | license = 'GPL' 27 | copyright = 'Logilab S.A.' 28 | description = "python code static checker" 29 | web = "http://www.logilab.org/project/%s" % distname 30 | ftp = "ftp://ftp.logilab.org/pub/%s" % modname 31 | mailinglist = "mailto://python-projects@lists.logilab.org" 32 | author = 'Logilab' 33 | author_email = 'python-projects@lists.logilab.org' 34 | 35 | classifiers = ['Development Status :: 4 - Beta', 36 | 'Environment :: Console', 37 | 'Intended Audience :: Developers', 38 | 'License :: OSI Approved :: GNU General Public License (GPL)', 39 | 'Operating System :: OS Independent', 40 | 'Programming Language :: Python', 41 | 'Topic :: Software Development :: Debuggers', 42 | 'Topic :: Software Development :: Quality Assurance', 43 | 'Topic :: Software Development :: Testing', 44 | ] 45 | 46 | 47 | long_desc = """\ 48 | Pylint is a Python source code analyzer which looks for programming 49 | errors, helps enforcing a coding standard and sniffs for some code 50 | smells (as defined in Martin Fowler's Refactoring book) 51 | . 52 | Pylint can be seen as another PyChecker since nearly all tests you 53 | can do with PyChecker can also be done with Pylint. However, Pylint 54 | offers some more features, like checking length of lines of code, 55 | checking if variable names are well-formed according to your coding 56 | standard, or checking if declared interfaces are truly implemented, 57 | and much more. 58 | . 59 | Additionally, it is possible to write plugins to add your own checks. 60 | . 61 | Pylint is shipped with "pylint-gui", "pyreverse" (UML diagram generator) 62 | and "symilar" (an independent similarities checker).""" 63 | 64 | from os.path import join 65 | scripts = [join('bin', filename) 66 | for filename in ('pylint', 'pylint-gui', "symilar", "epylint", 67 | "pyreverse")] 68 | 69 | -------------------------------------------------------------------------------- /pylibs/pylint/checkers/misc.py: -------------------------------------------------------------------------------- 1 | # pylint: disable=W0511 2 | # This program is free software; you can redistribute it and/or modify it under 3 | # the terms of the GNU General Public License as published by the Free Software 4 | # Foundation; either version 2 of the License, or (at your option) any later 5 | # version. 6 | # 7 | # This program is distributed in the hope that it will be useful, but WITHOUT 8 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License along with 12 | # this program; if not, write to the Free Software Foundation, Inc., 13 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 | """ Copyright (c) 2000-2010 LOGILAB S.A. (Paris, FRANCE). 15 | http://www.logilab.fr/ -- mailto:contact@logilab.fr 16 | 17 | Check source code is ascii only or has an encoding declaration (PEP 263) 18 | """ 19 | 20 | import re, sys 21 | 22 | from pylint.interfaces import IRawChecker 23 | from pylint.checkers import BaseChecker 24 | 25 | 26 | MSGS = { 27 | 'W0511': ('%s', 28 | 'Used when a warning note as FIXME or XXX is detected.'), 29 | } 30 | 31 | class EncodingChecker(BaseChecker): 32 | """checks for: 33 | * warning notes in the code like FIXME, XXX 34 | * PEP 263: source code with non ascii character but no encoding declaration 35 | """ 36 | __implements__ = IRawChecker 37 | 38 | # configuration section name 39 | name = 'miscellaneous' 40 | msgs = MSGS 41 | 42 | options = (('notes', 43 | {'type' : 'csv', 'metavar' : '', 44 | 'default' : ('FIXME', 'XXX', 'TODO'), 45 | 'help' : 'List of note tags to take in consideration, \ 46 | separated by a comma.' 47 | }), 48 | ) 49 | 50 | def __init__(self, linter=None): 51 | BaseChecker.__init__(self, linter) 52 | 53 | def process_module(self, node): 54 | """inspect the source file to found encoding problem or fixmes like 55 | notes 56 | """ 57 | stream = node.file_stream 58 | stream.seek(0) # XXX may be removed with astng > 0.23 59 | # warning notes in the code 60 | notes = [] 61 | for note in self.config.notes: 62 | notes.append(re.compile(note)) 63 | linenum = 1 64 | for line in stream.readlines(): 65 | for note in notes: 66 | match = note.search(line) 67 | if match: 68 | self.add_message('W0511', args=line[match.start():-1], 69 | line=linenum) 70 | break 71 | linenum += 1 72 | 73 | 74 | 75 | def register(linter): 76 | """required method to auto register this checker""" 77 | linter.register_checker(EncodingChecker(linter)) 78 | -------------------------------------------------------------------------------- /pylibs/pylint/interfaces.py: -------------------------------------------------------------------------------- 1 | # This program is free software; you can redistribute it and/or modify it under 2 | # the terms of the GNU General Public License as published by the Free Software 3 | # Foundation; either version 2 of the License, or (at your option) any later 4 | # version. 5 | # 6 | # This program is distributed in the hope that it will be useful, but WITHOUT 7 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 9 | # 10 | # You should have received a copy of the GNU General Public License along with 11 | # this program; if not, write to the Free Software Foundation, Inc., 12 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 13 | """ Copyright (c) 2002-2003 LOGILAB S.A. (Paris, FRANCE). 14 | http://www.logilab.fr/ -- mailto:contact@logilab.fr 15 | 16 | Interfaces for PyLint objects 17 | """ 18 | 19 | __revision__ = "$Id: interfaces.py,v 1.9 2004-04-24 12:14:53 syt Exp $" 20 | 21 | from logilab.common.interface import Interface 22 | 23 | 24 | class IChecker(Interface): 25 | """This is an base interface, not designed to be used elsewhere than for 26 | sub interfaces definition. 27 | """ 28 | 29 | def open(self): 30 | """called before visiting project (i.e set of modules)""" 31 | 32 | def close(self): 33 | """called after visiting project (i.e set of modules)""" 34 | 35 | ## def open_module(self): 36 | ## """called before visiting a module""" 37 | 38 | ## def close_module(self): 39 | ## """called after visiting a module""" 40 | 41 | 42 | class IRawChecker(IChecker): 43 | """interface for checker which need to parse the raw file 44 | """ 45 | 46 | def process_module(self, astng): 47 | """ process a module 48 | 49 | the module's content is accessible via astng.file_stream 50 | """ 51 | 52 | 53 | class IASTNGChecker(IChecker): 54 | """ interface for checker which prefers receive events according to 55 | statement type 56 | """ 57 | 58 | 59 | class ILinter(Interface): 60 | """interface for the linter class 61 | 62 | the linter class will generate events to its registered checkers. 63 | Each checker may interact with the linter instance using this API 64 | """ 65 | 66 | def register_checker(self, checker): 67 | """register a new checker class 68 | 69 | checker is a class implementing IrawChecker or / and IASTNGChecker 70 | """ 71 | 72 | def add_message(self, msg_id, line=None, node=None, args=None): 73 | """add the message corresponding to the given id. 74 | 75 | If provided, msg is expanded using args 76 | 77 | astng checkers should provide the node argument, 78 | raw checkers should provide the line argument. 79 | """ 80 | 81 | 82 | class IReporter(Interface): 83 | """ reporter collect messages and display results encapsulated in a layout 84 | """ 85 | def add_message(self, msg_id, location, msg): 86 | """add a message of a given type 87 | 88 | msg_id is a message identifier 89 | location is a 3-uple (module, object, line) 90 | msg is the actual message 91 | """ 92 | 93 | def display_results(self, layout): 94 | """display results encapsulated in the layout tree 95 | """ 96 | 97 | 98 | __all__ = ('IRawChecker', 'IStatable', 'ILinter', 'IReporter') 99 | -------------------------------------------------------------------------------- /pylibs/pylint/reporters/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2003-2010 Sylvain Thenault (thenault@gmail.com). 2 | # Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE). 3 | # This program is free software; you can redistribute it and/or modify it under 4 | # the terms of the GNU General Public License as published by the Free Software 5 | # Foundation; either version 2 of the License, or (at your option) any later 6 | # version. 7 | # 8 | # This program is distributed in the hope that it will be useful, but WITHOUT 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License along with 13 | # this program; if not, write to the Free Software Foundation, Inc., 14 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 | """utilities methods and classes for reporters""" 16 | 17 | import sys, locale 18 | 19 | CMPS = ['=', '-', '+'] 20 | 21 | def diff_string(old, new): 22 | """given a old and new int value, return a string representing the 23 | difference 24 | """ 25 | diff = abs(old - new) 26 | diff_str = "%s%s" % (CMPS[cmp(old, new)], diff and ('%.2f' % diff) or '') 27 | return diff_str 28 | 29 | 30 | class EmptyReport(Exception): 31 | """raised when a report is empty and so should not be displayed""" 32 | 33 | class BaseReporter: 34 | """base class for reporters""" 35 | 36 | extension = '' 37 | 38 | def __init__(self, output=None): 39 | self.linter = None 40 | self.include_ids = None 41 | self.section = 0 42 | self.out = None 43 | self.out_encoding = None 44 | self.set_output(output) 45 | 46 | def set_output(self, output=None): 47 | """set output stream""" 48 | self.out = output or sys.stdout 49 | # py3k streams handle their encoding : 50 | if sys.version_info >= (3, 0): 51 | self.encode = lambda x: x 52 | return 53 | 54 | def encode(string): 55 | if not isinstance(string, unicode): 56 | return string 57 | encoding = (getattr(self.out, 'encoding', None) or 58 | locale.getdefaultlocale()[1] or 59 | sys.getdefaultencoding()) 60 | return string.encode(encoding) 61 | self.encode = encode 62 | 63 | def writeln(self, string=''): 64 | """write a line in the output buffer""" 65 | print >> self.out, self.encode(string) 66 | 67 | def display_results(self, layout): 68 | """display results encapsulated in the layout tree""" 69 | self.section = 0 70 | if self.include_ids and hasattr(layout, 'report_id'): 71 | layout.children[0].children[0].data += ' (%s)' % layout.report_id 72 | self._display(layout) 73 | 74 | def _display(self, layout): 75 | """display the layout""" 76 | raise NotImplementedError() 77 | 78 | # Event callbacks 79 | 80 | def on_set_current_module(self, module, filepath): 81 | """starting analyzis of a module""" 82 | pass 83 | 84 | def on_close(self, stats, previous_stats): 85 | """global end of analyzis""" 86 | pass 87 | 88 | 89 | -------------------------------------------------------------------------------- /pylibs/pylint/reporters/guireporter.py: -------------------------------------------------------------------------------- 1 | """ reporter used by gui.py """ 2 | 3 | import sys 4 | 5 | from pylint.interfaces import IReporter 6 | from pylint.reporters import BaseReporter 7 | from logilab.common.ureports import TextWriter 8 | 9 | 10 | class GUIReporter(BaseReporter): 11 | """saves messages""" 12 | 13 | __implements__ = IReporter 14 | extension = '' 15 | 16 | def __init__(self, gui, output=sys.stdout): 17 | """init""" 18 | BaseReporter.__init__(self, output) 19 | self.msgs = [] 20 | self.gui = gui 21 | 22 | def add_message(self, msg_id, location, msg): 23 | """manage message of different type and in the context of path""" 24 | module, obj, line, col_offset = location[1:] 25 | if self.include_ids: 26 | sigle = msg_id 27 | else: 28 | sigle = msg_id[0] 29 | 30 | full_msg = [sigle, module, obj, str(line), msg] 31 | self.msgs += [[sigle, module, obj, str(line)]] 32 | self.gui.msg_queue.put(full_msg) 33 | 34 | def _display(self, layout): 35 | """launch layouts display""" 36 | TextWriter().format(layout, self.out) 37 | -------------------------------------------------------------------------------- /pylibs/pylint/reporters/html.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2003-2006 Sylvain Thenault (thenault@gmail.com). 2 | # Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE). 3 | # This program is free software; you can redistribute it and/or modify it under 4 | # the terms of the GNU General Public License as published by the Free Software 5 | # Foundation; either version 2 of the License, or (at your option) any later 6 | # version. 7 | # 8 | # This program is distributed in the hope that it will be useful, but WITHOUT 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License along with 13 | # this program; if not, write to the Free Software Foundation, Inc., 14 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 | """HTML reporter""" 16 | 17 | import sys 18 | from cgi import escape 19 | 20 | from logilab.common.ureports import HTMLWriter, Section, Table 21 | 22 | from pylint.interfaces import IReporter 23 | from pylint.reporters import BaseReporter 24 | 25 | 26 | class HTMLReporter(BaseReporter): 27 | """report messages and layouts in HTML""" 28 | 29 | __implements__ = IReporter 30 | extension = 'html' 31 | 32 | def __init__(self, output=sys.stdout): 33 | BaseReporter.__init__(self, output) 34 | self.msgs = [] 35 | 36 | def add_message(self, msg_id, location, msg): 37 | """manage message of different type and in the context of path""" 38 | module, obj, line, col_offset = location[1:] 39 | if self.include_ids: 40 | sigle = msg_id 41 | else: 42 | sigle = msg_id[0] 43 | self.msgs += [sigle, module, obj, str(line), str(col_offset), escape(msg)] 44 | 45 | def set_output(self, output=None): 46 | """set output stream 47 | 48 | messages buffered for old output is processed first""" 49 | if self.out and self.msgs: 50 | self._display(Section()) 51 | BaseReporter.set_output(self, output) 52 | 53 | def _display(self, layout): 54 | """launch layouts display 55 | 56 | overridden from BaseReporter to add insert the messages section 57 | (in add_message, message is not displayed, just collected so it 58 | can be displayed in an html table) 59 | """ 60 | if self.msgs: 61 | # add stored messages to the layout 62 | msgs = ['type', 'module', 'object', 'line', 'col_offset', 'message'] 63 | msgs += self.msgs 64 | sect = Section('Messages') 65 | layout.append(sect) 66 | sect.append(Table(cols=6, children=msgs, rheaders=1)) 67 | self.msgs = [] 68 | HTMLWriter().format(layout, self.out) 69 | 70 | -------------------------------------------------------------------------------- /pylibs/pymode/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/__init__.py -------------------------------------------------------------------------------- /pylibs/pymode/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/__init__.pyc -------------------------------------------------------------------------------- /pylibs/pymode/auto.py: -------------------------------------------------------------------------------- 1 | import vim 2 | from pylibs.autopep8 import fix_file, PEP8_PASSES_MAX 3 | 4 | 5 | class Options(): 6 | verbose = False 7 | diff = False 8 | in_place = True 9 | recursive = False 10 | pep8_passes = PEP8_PASSES_MAX 11 | ignore = '' 12 | select = '' 13 | 14 | 15 | def fix_current_file(): 16 | fix_file(vim.current.buffer.name, Options) 17 | -------------------------------------------------------------------------------- /pylibs/pymode/auto.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/auto.pyc -------------------------------------------------------------------------------- /pylibs/pymode/interface.py: -------------------------------------------------------------------------------- 1 | import vim 2 | 3 | 4 | def get_option(name): 5 | return get_bvar(name) or get_var(name) 6 | 7 | 8 | def get_var(name): 9 | return vim.eval("g:pymode_%s" % name) 10 | 11 | 12 | def get_bvar(name): 13 | return (int(vim.eval("exists('b:pymode_%s')" % name)) and vim.eval("b:pymode_%s" % name)) or None 14 | 15 | 16 | def get_current_buffer(): 17 | return vim.current.buffer 18 | 19 | 20 | def show_message(message): 21 | vim.command("call pymode#WideMessage('%s')" % message) 22 | 23 | 24 | def command(cmd): 25 | vim.command(cmd) 26 | -------------------------------------------------------------------------------- /pylibs/pymode/interface.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/interface.pyc -------------------------------------------------------------------------------- /pylibs/pymode/lint.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/lint.pyc -------------------------------------------------------------------------------- /pylibs/pymode/queue.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from .interface import show_message 3 | import time 4 | 5 | 6 | class Task(threading.Thread): 7 | 8 | def __init__(self, buffer, callback=None, title=None, *args, **kwargs): 9 | self.buffer = buffer 10 | self._stop = threading.Event() 11 | self.result = None 12 | self.callback = callback 13 | self.done = 0 14 | self.finished = False 15 | self.title = title 16 | threading.Thread.__init__(self, *args, **kwargs) 17 | 18 | def run(self): 19 | " Run tasks. " 20 | self._Thread__target(task=self, *self._Thread__args, **self._Thread__kwargs) 21 | 22 | # Wait for result parsing 23 | while not self.stopped(): 24 | time.sleep(.2) 25 | 26 | def stop(self): 27 | " Stop task. " 28 | self._stop.set() 29 | 30 | def stopped(self): 31 | return self._stop.isSet() 32 | 33 | 34 | def stop_queue(): 35 | " Stop all tasks. " 36 | for thread in threading.enumerate(): 37 | if isinstance(thread, Task): 38 | thread.stop() 39 | show_message('%s stopped.' % thread.title) 40 | 41 | 42 | def add_task(target, callback=None, buffer=None, title=None, *args, **kwargs): 43 | " Add all tasks. " 44 | 45 | task = Task(buffer, title=title, target=target, callback=callback, args=args, kwargs=kwargs) 46 | task.daemon = True 47 | task.start() 48 | 49 | show_message('%s started.' % task.title) 50 | 51 | 52 | def check_task(): 53 | " Check tasks for result. " 54 | for thread in threading.enumerate(): 55 | if isinstance(thread, Task): 56 | if thread.finished: 57 | thread.stop() 58 | thread.callback(thread.result) 59 | else: 60 | show_message('%s %s%%' % (thread.title, thread.done)) 61 | -------------------------------------------------------------------------------- /pylibs/pymode/queue.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/pymode/queue.pyc -------------------------------------------------------------------------------- /pylibs/rope/__init__.py: -------------------------------------------------------------------------------- 1 | """rope, a python refactoring library""" 2 | 3 | INFO = __doc__ 4 | VERSION = '0.9.4' 5 | COPYRIGHT = """\ 6 | Copyright (C) 2006-2012 Ali Gholami Rudi 7 | Copyright (C) 2009-2012 Anton Gritsay 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of GNU General Public License as published by the 11 | Free Software Foundation; either version 2 of the license, or (at your 12 | opinion) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details.""" 18 | -------------------------------------------------------------------------------- /pylibs/rope/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/__init__.py: -------------------------------------------------------------------------------- 1 | """Base rope package 2 | 3 | This package contains rope core modules that are used by other modules 4 | and packages. 5 | 6 | """ 7 | 8 | __all__ = ['project', 'libutils', 'exceptions'] 9 | -------------------------------------------------------------------------------- /pylibs/rope/base/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/arguments.py: -------------------------------------------------------------------------------- 1 | import rope.base.evaluate 2 | from rope.base import ast 3 | 4 | 5 | class Arguments(object): 6 | """A class for evaluating parameters passed to a function 7 | 8 | You can use the `create_arguments` factory. It handles implicit 9 | first arguments. 10 | 11 | """ 12 | 13 | def __init__(self, args, scope): 14 | self.args = args 15 | self.scope = scope 16 | self.instance = None 17 | 18 | def get_arguments(self, parameters): 19 | result = [] 20 | for pyname in self.get_pynames(parameters): 21 | if pyname is None: 22 | result.append(None) 23 | else: 24 | result.append(pyname.get_object()) 25 | return result 26 | 27 | def get_pynames(self, parameters): 28 | result = [None] * max(len(parameters), len(self.args)) 29 | for index, arg in enumerate(self.args): 30 | if isinstance(arg, ast.keyword) and arg.arg in parameters: 31 | result[parameters.index(arg.arg)] = self._evaluate(arg.value) 32 | else: 33 | result[index] = self._evaluate(arg) 34 | return result 35 | 36 | def get_instance_pyname(self): 37 | if self.args: 38 | return self._evaluate(self.args[0]) 39 | 40 | def _evaluate(self, ast_node): 41 | return rope.base.evaluate.eval_node(self.scope, ast_node) 42 | 43 | 44 | def create_arguments(primary, pyfunction, call_node, scope): 45 | """A factory for creating `Arguments`""" 46 | args = list(call_node.args) 47 | args.extend(call_node.keywords) 48 | called = call_node.func 49 | # XXX: Handle constructors 50 | if _is_method_call(primary, pyfunction) and \ 51 | isinstance(called, ast.Attribute): 52 | args.insert(0, called.value) 53 | return Arguments(args, scope) 54 | 55 | 56 | class ObjectArguments(object): 57 | 58 | def __init__(self, pynames): 59 | self.pynames = pynames 60 | 61 | def get_arguments(self, parameters): 62 | result = [] 63 | for pyname in self.pynames: 64 | if pyname is None: 65 | result.append(None) 66 | else: 67 | result.append(pyname.get_object()) 68 | return result 69 | 70 | def get_pynames(self, parameters): 71 | return self.pynames 72 | 73 | def get_instance_pyname(self): 74 | return self.pynames[0] 75 | class MixedArguments(object): 76 | 77 | def __init__(self, pyname, arguments, scope): 78 | """`argumens` is an instance of `Arguments`""" 79 | self.pyname = pyname 80 | self.args = arguments 81 | 82 | def get_pynames(self, parameters): 83 | return [self.pyname] + self.args.get_pynames(parameters[1:]) 84 | 85 | def get_arguments(self, parameters): 86 | result = [] 87 | for pyname in self.get_pynames(parameters): 88 | if pyname is None: 89 | result.append(None) 90 | else: 91 | result.append(pyname.get_object()) 92 | return result 93 | 94 | def get_instance_pyname(self): 95 | return self.pyname 96 | 97 | 98 | def _is_method_call(primary, pyfunction): 99 | if primary is None: 100 | return False 101 | pyobject = primary.get_object() 102 | if isinstance(pyobject.get_type(), rope.base.pyobjects.PyClass) and \ 103 | isinstance(pyfunction, rope.base.pyobjects.PyFunction) and \ 104 | isinstance(pyfunction.parent, rope.base.pyobjects.PyClass): 105 | return True 106 | if isinstance(pyobject.get_type(), rope.base.pyobjects.AbstractClass) and \ 107 | isinstance(pyfunction, rope.base.builtins.BuiltinFunction): 108 | return True 109 | return False 110 | -------------------------------------------------------------------------------- /pylibs/rope/base/arguments.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/arguments.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/ast.py: -------------------------------------------------------------------------------- 1 | import _ast 2 | from _ast import * 3 | 4 | from rope.base import fscommands 5 | 6 | 7 | def parse(source, filename=''): 8 | # NOTE: the raw string should be given to `compile` function 9 | if isinstance(source, unicode): 10 | source = fscommands.unicode_to_file_data(source) 11 | if '\r' in source: 12 | source = source.replace('\r\n', '\n').replace('\r', '\n') 13 | if not source.endswith('\n'): 14 | source += '\n' 15 | try: 16 | return compile(source, filename, 'exec', _ast.PyCF_ONLY_AST) 17 | except (TypeError, ValueError), e: 18 | error = SyntaxError() 19 | error.lineno = 1 20 | error.filename = filename 21 | error.msg = str(e) 22 | raise error 23 | 24 | 25 | def walk(node, walker): 26 | """Walk the syntax tree""" 27 | method_name = '_' + node.__class__.__name__ 28 | method = getattr(walker, method_name, None) 29 | if method is not None: 30 | if isinstance(node, _ast.ImportFrom) and node.module is None: 31 | # In python < 2.7 ``node.module == ''`` for relative imports 32 | # but for python 2.7 it is None. Generalizing it to ''. 33 | node.module = '' 34 | return method(node) 35 | for child in get_child_nodes(node): 36 | walk(child, walker) 37 | 38 | 39 | def get_child_nodes(node): 40 | if isinstance(node, _ast.Module): 41 | return node.body 42 | result = [] 43 | if node._fields is not None: 44 | for name in node._fields: 45 | child = getattr(node, name) 46 | if isinstance(child, list): 47 | for entry in child: 48 | if isinstance(entry, _ast.AST): 49 | result.append(entry) 50 | if isinstance(child, _ast.AST): 51 | result.append(child) 52 | return result 53 | 54 | 55 | def call_for_nodes(node, callback, recursive=False): 56 | """If callback returns `True` the child nodes are skipped""" 57 | result = callback(node) 58 | if recursive and not result: 59 | for child in get_child_nodes(node): 60 | call_for_nodes(child, callback, recursive) 61 | 62 | 63 | def get_children(node): 64 | result = [] 65 | if node._fields is not None: 66 | for name in node._fields: 67 | if name in ['lineno', 'col_offset']: 68 | continue 69 | child = getattr(node, name) 70 | result.append(child) 71 | return result 72 | -------------------------------------------------------------------------------- /pylibs/rope/base/ast.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/ast.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/astutils.py: -------------------------------------------------------------------------------- 1 | from rope.base import ast 2 | 3 | 4 | def get_name_levels(node): 5 | """Return a list of ``(name, level)`` tuples for assigned names 6 | 7 | The `level` is `None` for simple assignments and is a list of 8 | numbers for tuple assignments for example in:: 9 | 10 | a, (b, c) = x 11 | 12 | The levels for for `a` is ``[0]``, for `b` is ``[1, 0]`` and for 13 | `c` is ``[1, 1]``. 14 | 15 | """ 16 | visitor = _NodeNameCollector() 17 | ast.walk(node, visitor) 18 | return visitor.names 19 | 20 | 21 | class _NodeNameCollector(object): 22 | 23 | def __init__(self, levels=None): 24 | self.names = [] 25 | self.levels = levels 26 | self.index = 0 27 | 28 | def _add_node(self, node): 29 | new_levels = [] 30 | if self.levels is not None: 31 | new_levels = list(self.levels) 32 | new_levels.append(self.index) 33 | self.index += 1 34 | self._added(node, new_levels) 35 | 36 | def _added(self, node, levels): 37 | if hasattr(node, 'id'): 38 | self.names.append((node.id, levels)) 39 | 40 | def _Name(self, node): 41 | self._add_node(node) 42 | 43 | def _Tuple(self, node): 44 | new_levels = [] 45 | if self.levels is not None: 46 | new_levels = list(self.levels) 47 | new_levels.append(self.index) 48 | self.index += 1 49 | visitor = _NodeNameCollector(new_levels) 50 | for child in ast.get_child_nodes(node): 51 | ast.walk(child, visitor) 52 | self.names.extend(visitor.names) 53 | 54 | def _Subscript(self, node): 55 | self._add_node(node) 56 | 57 | def _Attribute(self, node): 58 | self._add_node(node) 59 | 60 | def _Slice(self, node): 61 | self._add_node(node) 62 | -------------------------------------------------------------------------------- /pylibs/rope/base/astutils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/astutils.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/builtins.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/builtins.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/change.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/change.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/codeanalyze.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/codeanalyze.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/default_config.py: -------------------------------------------------------------------------------- 1 | # The default ``config.py`` 2 | 3 | 4 | def set_prefs(prefs): 5 | """This function is called before opening the project""" 6 | 7 | # Specify which files and folders to ignore in the project. 8 | # Changes to ignored resources are not added to the history and 9 | # VCSs. Also they are not returned in `Project.get_files()`. 10 | # Note that ``?`` and ``*`` match all characters but slashes. 11 | # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' 12 | # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' 13 | # '.svn': matches 'pkg/.svn' and all of its children 14 | # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' 15 | # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' 16 | prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', 17 | '.hg', '.svn', '_svn', '.git'] 18 | 19 | # Specifies which files should be considered python files. It is 20 | # useful when you have scripts inside your project. Only files 21 | # ending with ``.py`` are considered to be python files by 22 | # default. 23 | #prefs['python_files'] = ['*.py'] 24 | 25 | # Custom source folders: By default rope searches the project 26 | # for finding source folders (folders that should be searched 27 | # for finding modules). You can add paths to that list. Note 28 | # that rope guesses project source folders correctly most of the 29 | # time; use this if you have any problems. 30 | # The folders should be relative to project root and use '/' for 31 | # separating folders regardless of the platform rope is running on. 32 | # 'src/my_source_folder' for instance. 33 | #prefs.add('source_folders', 'src') 34 | 35 | # You can extend python path for looking up modules 36 | #prefs.add('python_path', '~/python/') 37 | 38 | # Should rope save object information or not. 39 | prefs['save_objectdb'] = True 40 | prefs['compress_objectdb'] = False 41 | 42 | # If `True`, rope analyzes each module when it is being saved. 43 | prefs['automatic_soa'] = True 44 | # The depth of calls to follow in static object analysis 45 | prefs['soa_followed_calls'] = 0 46 | 47 | # If `False` when running modules or unit tests "dynamic object 48 | # analysis" is turned off. This makes them much faster. 49 | prefs['perform_doa'] = True 50 | 51 | # Rope can check the validity of its object DB when running. 52 | prefs['validate_objectdb'] = True 53 | 54 | # How many undos to hold? 55 | prefs['max_history_items'] = 32 56 | 57 | # Shows whether to save history across sessions. 58 | prefs['save_history'] = True 59 | prefs['compress_history'] = False 60 | 61 | # Set the number spaces used for indenting. According to 62 | # :PEP:`8`, it is best to use 4 spaces. Since most of rope's 63 | # unit-tests use 4 spaces it is more reliable, too. 64 | prefs['indent_size'] = 4 65 | 66 | # Builtin and c-extension modules that are allowed to be imported 67 | # and inspected by rope. 68 | prefs['extension_modules'] = [] 69 | 70 | # Add all standard c-extensions to extension_modules list. 71 | prefs['import_dynload_stdmods'] = True 72 | 73 | # If `True` modules with syntax errors are considered to be empty. 74 | # The default value is `False`; When `False` syntax errors raise 75 | # `rope.base.exceptions.ModuleSyntaxError` exception. 76 | prefs['ignore_syntax_errors'] = False 77 | 78 | # If `True`, rope ignores unresolvable imports. Otherwise, they 79 | # appear in the importing namespace. 80 | prefs['ignore_bad_imports'] = False 81 | 82 | 83 | def project_opened(project): 84 | """This function is called after opening the project""" 85 | # Do whatever you like here! 86 | -------------------------------------------------------------------------------- /pylibs/rope/base/evaluate.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/evaluate.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/exceptions.py: -------------------------------------------------------------------------------- 1 | class RopeError(Exception): 2 | """Base exception for rope""" 3 | 4 | 5 | class ResourceNotFoundError(RopeError): 6 | """Resource not found exception""" 7 | 8 | 9 | class RefactoringError(RopeError): 10 | """Errors for performing a refactoring""" 11 | 12 | 13 | class InterruptedTaskError(RopeError): 14 | """The task has been interrupted""" 15 | 16 | 17 | class HistoryError(RopeError): 18 | """Errors for history undo/redo operations""" 19 | 20 | 21 | class ModuleNotFoundError(RopeError): 22 | """Module not found exception""" 23 | 24 | 25 | class AttributeNotFoundError(RopeError): 26 | """Attribute not found exception""" 27 | 28 | 29 | class NameNotFoundError(RopeError): 30 | """Name not found exception""" 31 | 32 | 33 | class BadIdentifierError(RopeError): 34 | """The name cannot be resolved""" 35 | 36 | 37 | class ModuleSyntaxError(RopeError): 38 | """Module has syntax errors 39 | 40 | The `filename` and `lineno` fields indicate where the error has 41 | occurred. 42 | 43 | """ 44 | 45 | def __init__(self, filename, lineno, message): 46 | self.filename = filename 47 | self.lineno = lineno 48 | self.message_ = message 49 | super(ModuleSyntaxError, self).__init__( 50 | 'Syntax error in file <%s> line <%s>: %s' % 51 | (filename, lineno, message)) 52 | 53 | 54 | class ModuleDecodeError(RopeError): 55 | """Cannot decode module""" 56 | 57 | def __init__(self, filename, message): 58 | self.filename = filename 59 | self.message_ = message 60 | super(ModuleDecodeError, self).__init__( 61 | 'Cannot decode file <%s>: %s' % (filename, message)) 62 | -------------------------------------------------------------------------------- /pylibs/rope/base/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/exceptions.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/fscommands.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/fscommands.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/history.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/history.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/libutils.py: -------------------------------------------------------------------------------- 1 | """A few useful functions for using rope as a library""" 2 | import os.path 3 | 4 | import rope.base.project 5 | import rope.base.pycore 6 | from rope.base import taskhandle 7 | 8 | 9 | def path_to_resource(project, path, type=None): 10 | """Get the resource at path 11 | 12 | You only need to specify `type` if `path` does not exist. It can 13 | be either 'file' or 'folder'. If the type is `None` it is assumed 14 | that the resource already exists. 15 | 16 | Note that this function uses `Project.get_resource()`, 17 | `Project.get_file()`, and `Project.get_folder()` methods. 18 | 19 | """ 20 | project_path = relative(project.address, path) 21 | if project_path is None: 22 | project_path = rope.base.project._realpath(path) 23 | project = rope.base.project.get_no_project() 24 | if type is None: 25 | return project.get_resource(project_path) 26 | if type == 'file': 27 | return project.get_file(project_path) 28 | if type == 'folder': 29 | return project.get_folder(project_path) 30 | return None 31 | 32 | def relative(root, path): 33 | root = rope.base.project._realpath(root).replace(os.path.sep, '/') 34 | path = rope.base.project._realpath(path).replace(os.path.sep, '/') 35 | if path == root: 36 | return '' 37 | if path.startswith(root + '/'): 38 | return path[len(root) + 1:] 39 | 40 | def report_change(project, path, old_content): 41 | """Report that the contents of file at `path` was changed 42 | 43 | The new contents of file is retrieved by reading the file. 44 | 45 | """ 46 | resource = path_to_resource(project, path) 47 | if resource is None: 48 | return 49 | for observer in list(project.observers): 50 | observer.resource_changed(resource) 51 | if project.pycore.automatic_soa: 52 | rope.base.pycore.perform_soa_on_changed_scopes(project, resource, 53 | old_content) 54 | 55 | def analyze_modules(project, task_handle=taskhandle.NullTaskHandle()): 56 | """Perform static object analysis on all python files in the project 57 | 58 | Note that this might be really time consuming. 59 | """ 60 | resources = project.pycore.get_python_files() 61 | job_set = task_handle.create_jobset('Analyzing Modules', len(resources)) 62 | for resource in resources: 63 | job_set.started_job(resource.path) 64 | project.pycore.analyze_module(resource) 65 | job_set.finished_job() 66 | -------------------------------------------------------------------------------- /pylibs/rope/base/libutils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/libutils.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/__init__.py: -------------------------------------------------------------------------------- 1 | """Rope object analysis and inference package 2 | 3 | Rope makes some simplifying assumptions about a python program. It 4 | assumes that a program only performs assignments and function calls. 5 | Tracking assignments is simple and `PyName` objects handle that. The 6 | main problem is function calls. Rope uses these two approaches for 7 | obtaining call information: 8 | 9 | * Static object analysis: `rope.base.pycore.PyCore.analyze_module()` 10 | 11 | It can analyze modules to obtain information about functions. This 12 | is done by analyzing function calls in a module or scope. Currently 13 | SOA analyzes the scopes that are changed while saving or when the 14 | user asks to analyze a module. That is mainly because static 15 | analysis is time-consuming. 16 | 17 | * Dynamic object analysis: `rope.base.pycore.PyCore.run_module()` 18 | 19 | When you run a module or your testsuite, when DOA is enabled, it 20 | collects information about parameters passed to and objects returned 21 | from functions. The main problem with this approach is that it is 22 | quite slow; Not when looking up the information but when collecting 23 | them. 24 | 25 | An instance of `rope.base.oi.objectinfo.ObjectInfoManager` can be used 26 | for accessing these information. It saves the data in a 27 | `rope.base.oi.objectdb.ObjectDB` internally. 28 | 29 | Now if our objectdb does not know anything about a function and we 30 | need the value returned by it, static object inference, SOI, comes 31 | into play. It analyzes function body and tries to infer the object 32 | that is returned from it (we usually need the returned value for the 33 | given parameter objects). 34 | 35 | Rope might collect and store information for other `PyName`\s, too. 36 | For instance rope stores the object builtin containers hold. 37 | 38 | """ 39 | -------------------------------------------------------------------------------- /pylibs/rope/base/oi/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/doa.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/doa.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/memorydb.py: -------------------------------------------------------------------------------- 1 | from rope.base.oi import objectdb 2 | 3 | 4 | class MemoryDB(objectdb.FileDict): 5 | 6 | def __init__(self, project, persist=None): 7 | self.project = project 8 | self._persist = persist 9 | self.files = self 10 | self._load_files() 11 | self.project.data_files.add_write_hook(self.write) 12 | 13 | def _load_files(self): 14 | self._files = {} 15 | if self.persist: 16 | result = self.project.data_files.read_data( 17 | 'objectdb', compress=self.compress, import_=True) 18 | if result is not None: 19 | self._files = result 20 | 21 | def keys(self): 22 | return self._files.keys() 23 | 24 | def __contains__(self, key): 25 | return key in self._files 26 | 27 | def __getitem__(self, key): 28 | return FileInfo(self._files[key]) 29 | 30 | def create(self, path): 31 | self._files[path] = {} 32 | 33 | def rename(self, file, newfile): 34 | if file not in self._files: 35 | return 36 | self._files[newfile] = self._files[file] 37 | del self[file] 38 | 39 | def __delitem__(self, file): 40 | del self._files[file] 41 | 42 | def write(self): 43 | if self.persist: 44 | self.project.data_files.write_data('objectdb', self._files, 45 | self.compress) 46 | 47 | @property 48 | def compress(self): 49 | return self.project.prefs.get('compress_objectdb', False) 50 | 51 | @property 52 | def persist(self): 53 | if self._persist is not None: 54 | return self._persist 55 | else: 56 | return self.project.prefs.get('save_objectdb', False) 57 | 58 | 59 | class FileInfo(objectdb.FileInfo): 60 | 61 | def __init__(self, scopes): 62 | self.scopes = scopes 63 | 64 | def create_scope(self, key): 65 | self.scopes[key] = ScopeInfo() 66 | 67 | def keys(self): 68 | return self.scopes.keys() 69 | 70 | def __contains__(self, key): 71 | return key in self.scopes 72 | 73 | def __getitem__(self, key): 74 | return self.scopes[key] 75 | 76 | def __delitem__(self, key): 77 | del self.scopes[key] 78 | 79 | 80 | class ScopeInfo(objectdb.ScopeInfo): 81 | 82 | def __init__(self): 83 | self.call_info = {} 84 | self.per_name = {} 85 | 86 | def get_per_name(self, name): 87 | return self.per_name.get(name, None) 88 | 89 | def save_per_name(self, name, value): 90 | self.per_name[name] = value 91 | 92 | def get_returned(self, parameters): 93 | return self.call_info.get(parameters, None) 94 | 95 | def get_call_infos(self): 96 | for args, returned in self.call_info.items(): 97 | yield objectdb.CallInfo(args, returned) 98 | 99 | def add_call(self, parameters, returned): 100 | self.call_info[parameters] = returned 101 | 102 | def __getstate__(self): 103 | return (self.call_info, self.per_name) 104 | 105 | def __setstate__(self, data): 106 | self.call_info, self.per_name = data 107 | -------------------------------------------------------------------------------- /pylibs/rope/base/oi/memorydb.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/memorydb.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/objectdb.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/objectdb.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/objectinfo.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/objectinfo.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/soa.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/soa.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/soi.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/soi.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/oi/transform.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/oi/transform.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/prefs.py: -------------------------------------------------------------------------------- 1 | class Prefs(object): 2 | 3 | def __init__(self): 4 | self.prefs = {} 5 | self.callbacks = {} 6 | 7 | def set(self, key, value): 8 | """Set the value of `key` preference to `value`.""" 9 | if key in self.callbacks: 10 | self.callbacks[key](value) 11 | else: 12 | self.prefs[key] = value 13 | 14 | def add(self, key, value): 15 | """Add an entry to a list preference 16 | 17 | Add `value` to the list of entries for the `key` preference. 18 | 19 | """ 20 | if not key in self.prefs: 21 | self.prefs[key] = [] 22 | self.prefs[key].append(value) 23 | 24 | def get(self, key, default=None): 25 | """Get the value of the key preference""" 26 | return self.prefs.get(key, default) 27 | 28 | def add_callback(self, key, callback): 29 | """Add `key` preference with `callback` function 30 | 31 | Whenever `key` is set the callback is called with the 32 | given `value` as parameter. 33 | 34 | """ 35 | self.callbacks[key] = callback 36 | 37 | def __setitem__(self, key, value): 38 | self.set(key, value) 39 | 40 | def __getitem__(self, key): 41 | return self.get(key) 42 | -------------------------------------------------------------------------------- /pylibs/rope/base/prefs.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/prefs.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/project.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/project.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pycore.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pycore.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pynames.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pynames.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pynamesdef.py: -------------------------------------------------------------------------------- 1 | import rope.base.oi.soi 2 | from rope.base import pynames 3 | from rope.base.pynames import * 4 | 5 | 6 | class AssignedName(pynames.AssignedName): 7 | 8 | def __init__(self, lineno=None, module=None, pyobject=None): 9 | self.lineno = lineno 10 | self.module = module 11 | self.assignments = [] 12 | self.pyobject = _Inferred(self._get_inferred, 13 | pynames._get_concluded_data(module)) 14 | self.pyobject.set(pyobject) 15 | 16 | @utils.prevent_recursion(lambda: None) 17 | def _get_inferred(self): 18 | if self.module is not None: 19 | return rope.base.oi.soi.infer_assigned_object(self) 20 | 21 | def get_object(self): 22 | return self.pyobject.get() 23 | 24 | def get_definition_location(self): 25 | """Returns a (module, lineno) tuple""" 26 | if self.lineno is None and self.assignments: 27 | self.lineno = self.assignments[0].get_lineno() 28 | return (self.module, self.lineno) 29 | 30 | def invalidate(self): 31 | """Forget the `PyObject` this `PyName` holds""" 32 | self.pyobject.set(None) 33 | 34 | 35 | class ParameterName(pynames.ParameterName): 36 | 37 | def __init__(self, pyfunction, index): 38 | self.pyfunction = pyfunction 39 | self.index = index 40 | 41 | def get_object(self): 42 | result = self.pyfunction.get_parameter(self.index) 43 | if result is None: 44 | result = rope.base.pyobjects.get_unknown() 45 | return result 46 | 47 | def get_objects(self): 48 | """Returns the list of objects passed as this parameter""" 49 | return rope.base.oi.soi.get_passed_objects( 50 | self.pyfunction, self.index) 51 | 52 | def get_definition_location(self): 53 | return (self.pyfunction.get_module(), self.pyfunction.get_ast().lineno) 54 | 55 | _Inferred = pynames._Inferred 56 | -------------------------------------------------------------------------------- /pylibs/rope/base/pynamesdef.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pynamesdef.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pyobjects.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pyobjects.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pyobjectsdef.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pyobjectsdef.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/pyscopes.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/pyscopes.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/resourceobserver.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/resourceobserver.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/resources.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/resources.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/simplify.py: -------------------------------------------------------------------------------- 1 | """A module to ease code analysis 2 | 3 | This module is here to help source code analysis. 4 | """ 5 | import re 6 | 7 | from rope.base import codeanalyze, utils 8 | 9 | 10 | @utils.cached(7) 11 | def real_code(source): 12 | """Simplify `source` for analysis 13 | 14 | It replaces: 15 | 16 | * comments with spaces 17 | * strs with a new str filled with spaces 18 | * implicit and explicit continuations with spaces 19 | * tabs and semicolons with spaces 20 | 21 | The resulting code is a lot easier to analyze if we are interested 22 | only in offsets. 23 | """ 24 | collector = codeanalyze.ChangeCollector(source) 25 | for start, end in ignored_regions(source): 26 | if source[start] == '#': 27 | replacement = ' ' * (end - start) 28 | else: 29 | replacement = '"%s"' % (' ' * (end - start - 2)) 30 | collector.add_change(start, end, replacement) 31 | source = collector.get_changed() or source 32 | collector = codeanalyze.ChangeCollector(source) 33 | parens = 0 34 | for match in _parens.finditer(source): 35 | i = match.start() 36 | c = match.group() 37 | if c in '({[': 38 | parens += 1 39 | if c in ')}]': 40 | parens -= 1 41 | if c == '\n' and parens > 0: 42 | collector.add_change(i, i + 1, ' ') 43 | source = collector.get_changed() or source 44 | return source.replace('\\\n', ' ').replace('\t', ' ').replace(';', '\n') 45 | 46 | 47 | @utils.cached(7) 48 | def ignored_regions(source): 49 | """Return ignored regions like strings and comments in `source` """ 50 | return [(match.start(), match.end()) for match in _str.finditer(source)] 51 | 52 | 53 | _str = re.compile('%s|%s' % (codeanalyze.get_comment_pattern(), 54 | codeanalyze.get_string_pattern())) 55 | _parens = re.compile(r'[\({\[\]}\)\n]') 56 | -------------------------------------------------------------------------------- /pylibs/rope/base/simplify.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/simplify.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/stdmods.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from rope.base import utils 5 | 6 | 7 | def _stdlib_path(): 8 | import distutils.sysconfig 9 | return distutils.sysconfig.get_python_lib(standard_lib=True) 10 | 11 | @utils.cached(1) 12 | def standard_modules(): 13 | return python_modules() | dynload_modules() 14 | 15 | @utils.cached(1) 16 | def python_modules(): 17 | result = set() 18 | lib_path = _stdlib_path() 19 | if os.path.exists(lib_path): 20 | for name in os.listdir(lib_path): 21 | path = os.path.join(lib_path, name) 22 | if os.path.isdir(path): 23 | if '-' not in name: 24 | result.add(name) 25 | else: 26 | if name.endswith('.py'): 27 | result.add(name[:-3]) 28 | return result 29 | 30 | @utils.cached(1) 31 | def dynload_modules(): 32 | result = set(sys.builtin_module_names) 33 | dynload_path = os.path.join(_stdlib_path(), 'lib-dynload') 34 | if os.path.exists(dynload_path): 35 | for name in os.listdir(dynload_path): 36 | path = os.path.join(dynload_path, name) 37 | if os.path.isfile(path): 38 | if name.endswith('.so') or name.endswith('.dll'): 39 | result.add(os.path.splitext(name)[0]) 40 | return result 41 | -------------------------------------------------------------------------------- /pylibs/rope/base/stdmods.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/stdmods.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/taskhandle.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from rope.base import exceptions 4 | 5 | 6 | class TaskHandle(object): 7 | 8 | def __init__(self, name='Task', interrupts=True): 9 | """Construct a TaskHandle 10 | 11 | If `interrupts` is `False` the task won't be interrupted by 12 | calling `TaskHandle.stop()`. 13 | 14 | """ 15 | self.name = name 16 | self.interrupts = interrupts 17 | self.stopped = False 18 | self.job_sets = [] 19 | self.observers = [] 20 | 21 | def stop(self): 22 | """Interrupts the refactoring""" 23 | if self.interrupts: 24 | self.stopped = True 25 | self._inform_observers() 26 | 27 | def current_jobset(self): 28 | """Return the current `JobSet`""" 29 | if self.job_sets: 30 | return self.job_sets[-1] 31 | 32 | def add_observer(self, observer): 33 | """Register an observer for this task handle 34 | 35 | The observer is notified whenever the task is stopped or 36 | a job gets finished. 37 | 38 | """ 39 | self.observers.append(observer) 40 | 41 | def is_stopped(self): 42 | return self.stopped 43 | 44 | def get_jobsets(self): 45 | return self.job_sets 46 | 47 | def create_jobset(self, name='JobSet', count=None): 48 | result = JobSet(self, name=name, count=count) 49 | self.job_sets.append(result) 50 | self._inform_observers() 51 | return result 52 | 53 | def _inform_observers(self): 54 | for observer in list(self.observers): 55 | observer() 56 | 57 | 58 | class JobSet(object): 59 | 60 | def __init__(self, handle, name, count): 61 | self.handle = handle 62 | self.name = name 63 | self.count = count 64 | self.done = 0 65 | self.job_name = None 66 | 67 | def started_job(self, name): 68 | self.check_status() 69 | self.job_name = name 70 | self.handle._inform_observers() 71 | 72 | def finished_job(self): 73 | self.check_status() 74 | self.done += 1 75 | self.handle._inform_observers() 76 | self.job_name = None 77 | 78 | def check_status(self): 79 | if self.handle.is_stopped(): 80 | raise exceptions.InterruptedTaskError() 81 | 82 | def get_active_job_name(self): 83 | return self.job_name 84 | 85 | def get_percent_done(self): 86 | if self.count is not None and self.count > 0: 87 | percent = self.done * 100 // self.count 88 | return min(percent, 100) 89 | 90 | def get_name(self): 91 | return self.name 92 | 93 | 94 | class NullTaskHandle(object): 95 | 96 | def __init__(self): 97 | pass 98 | 99 | def is_stopped(self): 100 | return False 101 | 102 | def stop(self): 103 | pass 104 | 105 | def create_jobset(self, *args, **kwds): 106 | return NullJobSet() 107 | 108 | def get_jobsets(self): 109 | return [] 110 | 111 | def add_observer(self, observer): 112 | pass 113 | 114 | 115 | class NullJobSet(object): 116 | 117 | def started_job(self, name): 118 | pass 119 | 120 | def finished_job(self): 121 | pass 122 | 123 | def check_status(self): 124 | pass 125 | 126 | def get_active_job_name(self): 127 | pass 128 | 129 | def get_percent_done(self): 130 | pass 131 | 132 | def get_name(self): 133 | pass 134 | -------------------------------------------------------------------------------- /pylibs/rope/base/taskhandle.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/taskhandle.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/utils.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | 4 | def saveit(func): 5 | """A decorator that caches the return value of a function""" 6 | 7 | name = '_' + func.__name__ 8 | def _wrapper(self, *args, **kwds): 9 | if not hasattr(self, name): 10 | setattr(self, name, func(self, *args, **kwds)) 11 | return getattr(self, name) 12 | return _wrapper 13 | 14 | cacheit = saveit 15 | 16 | def prevent_recursion(default): 17 | """A decorator that returns the return value of `default` in recursions""" 18 | def decorator(func): 19 | name = '_calling_%s_' % func.__name__ 20 | def newfunc(self, *args, **kwds): 21 | if getattr(self, name, False): 22 | return default() 23 | setattr(self, name, True) 24 | try: 25 | return func(self, *args, **kwds) 26 | finally: 27 | setattr(self, name, False) 28 | return newfunc 29 | return decorator 30 | 31 | 32 | def ignore_exception(exception_class): 33 | """A decorator that ignores `exception_class` exceptions""" 34 | def _decorator(func): 35 | def newfunc(*args, **kwds): 36 | try: 37 | return func(*args, **kwds) 38 | except exception_class: 39 | pass 40 | return newfunc 41 | return _decorator 42 | 43 | 44 | def deprecated(message=None): 45 | """A decorator for deprecated functions""" 46 | def _decorator(func, message=message): 47 | if message is None: 48 | message = '%s is deprecated' % func.__name__ 49 | def newfunc(*args, **kwds): 50 | warnings.warn(message, DeprecationWarning, stacklevel=2) 51 | return func(*args, **kwds) 52 | return newfunc 53 | return _decorator 54 | 55 | 56 | def cached(count): 57 | """A caching decorator based on parameter objects""" 58 | def decorator(func): 59 | return _Cached(func, count) 60 | return decorator 61 | 62 | class _Cached(object): 63 | 64 | def __init__(self, func, count): 65 | self.func = func 66 | self.cache = [] 67 | self.count = count 68 | 69 | def __call__(self, *args, **kwds): 70 | key = (args, kwds) 71 | for cached_key, cached_result in self.cache: 72 | if cached_key == key: 73 | return cached_result 74 | result = self.func(*args, **kwds) 75 | self.cache.append((key, result)) 76 | if len(self.cache) > self.count: 77 | del self.cache[0] 78 | return result 79 | -------------------------------------------------------------------------------- /pylibs/rope/base/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/utils.pyc -------------------------------------------------------------------------------- /pylibs/rope/base/worder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/base/worder.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | """rope IDE tools package 2 | 3 | This package contains modules that can be used in IDEs 4 | but do not depend on the UI. So these modules will be used 5 | by `rope.ui` modules. 6 | 7 | """ 8 | -------------------------------------------------------------------------------- /pylibs/rope/contrib/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/autoimport.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/autoimport.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/changestack.py: -------------------------------------------------------------------------------- 1 | """For performing many refactorings as a single command 2 | 3 | `changestack` module can be used to perform many refactorings on top 4 | of each other as one bigger command. It can be used like:: 5 | 6 | stack = ChangeStack(project, 'my big command') 7 | 8 | #.. 9 | stack.push(refactoring1.get_changes()) 10 | #.. 11 | stack.push(refactoring2.get_changes()) 12 | #.. 13 | stack.push(refactoringX.get_changes()) 14 | 15 | stack.pop_all() 16 | changes = stack.merged() 17 | 18 | Now `changes` can be previewed or performed as before. 19 | """ 20 | 21 | from rope.base import change 22 | 23 | 24 | class ChangeStack(object): 25 | 26 | def __init__(self, project, description='merged changes'): 27 | self.project = project 28 | self.description = description 29 | self.stack = [] 30 | 31 | def push(self, changes): 32 | self.stack.append(changes) 33 | self.project.do(changes) 34 | 35 | def pop_all(self): 36 | for i in range(len(self.stack)): 37 | self.project.history.undo(drop=True) 38 | 39 | def merged(self): 40 | result = change.ChangeSet(self.description) 41 | for changes in self.stack: 42 | for c in self._basic_changes(changes): 43 | result.add_change(c) 44 | return result 45 | 46 | def _basic_changes(self, changes): 47 | if isinstance(changes, change.ChangeSet): 48 | for child in changes.changes: 49 | for atom in self._basic_changes(child): 50 | yield atom 51 | else: 52 | yield changes 53 | -------------------------------------------------------------------------------- /pylibs/rope/contrib/codeassist.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/codeassist.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/finderrors.py: -------------------------------------------------------------------------------- 1 | """Finding bad name and attribute accesses 2 | 3 | `find_errors` function can be used to find possible bad name and 4 | attribute accesses. As an example:: 5 | 6 | errors = find_errors(project, project.get_resource('mod.py')) 7 | for error in errors: 8 | print '%s: %s' % (error.lineno, error.error) 9 | 10 | prints possible errors for ``mod.py`` file. 11 | 12 | TODO: 13 | 14 | * use task handles 15 | * reporting names at most once 16 | * attributes of extension modules that don't appear in 17 | extension_modules project config can be ignored 18 | * not calling `PyScope.get_inner_scope_for_line()` if it is a 19 | bottleneck; needs profiling 20 | * not reporting occurrences where rope cannot infer the object 21 | * rope saves multiple objects for some of the names in its objectdb 22 | use all of them not to give false positives 23 | * ... ;-) 24 | 25 | """ 26 | from rope.base import ast, evaluate, pyobjects 27 | 28 | 29 | def find_errors(project, resource): 30 | """Find possible bad name and attribute accesses 31 | 32 | It returns a list of `Error`\s. 33 | """ 34 | pymodule = project.pycore.resource_to_pyobject(resource) 35 | finder = _BadAccessFinder(pymodule) 36 | ast.walk(pymodule.get_ast(), finder) 37 | return finder.errors 38 | 39 | 40 | class _BadAccessFinder(object): 41 | 42 | def __init__(self, pymodule): 43 | self.pymodule = pymodule 44 | self.scope = pymodule.get_scope() 45 | self.errors = [] 46 | 47 | def _Name(self, node): 48 | if isinstance(node.ctx, (ast.Store, ast.Param)): 49 | return 50 | scope = self.scope.get_inner_scope_for_line(node.lineno) 51 | pyname = scope.lookup(node.id) 52 | if pyname is None: 53 | self._add_error(node, 'Unresolved variable') 54 | elif self._is_defined_after(scope, pyname, node.lineno): 55 | self._add_error(node, 'Defined later') 56 | 57 | def _Attribute(self, node): 58 | if not isinstance(node.ctx, ast.Store): 59 | scope = self.scope.get_inner_scope_for_line(node.lineno) 60 | pyname = evaluate.eval_node(scope, node.value) 61 | if pyname is not None and \ 62 | pyname.get_object() != pyobjects.get_unknown(): 63 | if node.attr not in pyname.get_object(): 64 | self._add_error(node, 'Unresolved attribute') 65 | ast.walk(node.value, self) 66 | 67 | def _add_error(self, node, msg): 68 | if isinstance(node, ast.Attribute): 69 | name = node.attr 70 | else: 71 | name = node.id 72 | if name != 'None': 73 | error = Error(node.lineno, msg + ' ' + name) 74 | self.errors.append(error) 75 | 76 | def _is_defined_after(self, scope, pyname, lineno): 77 | location = pyname.get_definition_location() 78 | if location is not None and location[1] is not None: 79 | if location[0] == self.pymodule and \ 80 | lineno <= location[1] <= scope.get_end(): 81 | return True 82 | 83 | 84 | class Error(object): 85 | 86 | def __init__(self, lineno, error): 87 | self.lineno = lineno 88 | self.error = error 89 | 90 | def __str__(self): 91 | return '%s: %s' % (self.lineno, self.error) 92 | -------------------------------------------------------------------------------- /pylibs/rope/contrib/findit.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/findit.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/fixmodnames.py: -------------------------------------------------------------------------------- 1 | """Fix the name of modules 2 | 3 | This module is useful when you want to rename many of the modules in 4 | your project. That can happen specially when you want to change their 5 | naming style. 6 | 7 | For instance:: 8 | 9 | fixer = FixModuleNames(project) 10 | changes = fixer.get_changes(fixer=str.lower) 11 | project.do(changes) 12 | 13 | Here it renames all modules and packages to use lower-cased chars. 14 | You can tell it to use any other style by using the ``fixer`` 15 | argument. 16 | 17 | """ 18 | from rope.base import change, taskhandle 19 | from rope.contrib import changestack 20 | from rope.refactor import rename 21 | 22 | 23 | class FixModuleNames(object): 24 | 25 | def __init__(self, project): 26 | self.project = project 27 | 28 | def get_changes(self, fixer=str.lower, 29 | task_handle=taskhandle.NullTaskHandle()): 30 | """Fix module names 31 | 32 | `fixer` is a function that takes and returns a `str`. Given 33 | the name of a module, it should return the fixed name. 34 | 35 | """ 36 | stack = changestack.ChangeStack(self.project, 'Fixing module names') 37 | jobset = task_handle.create_jobset('Fixing module names', 38 | self._count_fixes(fixer) + 1) 39 | try: 40 | while True: 41 | for resource in self._tobe_fixed(fixer): 42 | jobset.started_job(resource.path) 43 | renamer = rename.Rename(self.project, resource) 44 | changes = renamer.get_changes(fixer(self._name(resource))) 45 | stack.push(changes) 46 | jobset.finished_job() 47 | break 48 | else: 49 | break 50 | finally: 51 | jobset.started_job('Reverting to original state') 52 | stack.pop_all() 53 | jobset.finished_job() 54 | return stack.merged() 55 | 56 | def _count_fixes(self, fixer): 57 | return len(list(self._tobe_fixed(fixer))) 58 | 59 | def _tobe_fixed(self, fixer): 60 | for resource in self.project.pycore.get_python_files(): 61 | modname = self._name(resource) 62 | if modname != fixer(modname): 63 | yield resource 64 | 65 | def _name(self, resource): 66 | modname = resource.name.rsplit('.', 1)[0] 67 | if modname == '__init__': 68 | modname = resource.parent.name 69 | return modname 70 | -------------------------------------------------------------------------------- /pylibs/rope/contrib/fixsyntax.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/fixsyntax.pyc -------------------------------------------------------------------------------- /pylibs/rope/contrib/generate.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/contrib/generate.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/__init__.py: -------------------------------------------------------------------------------- 1 | """rope refactor package 2 | 3 | This package contains modules that perform python refactorings. 4 | Refactoring classes perform refactorings in 4 steps: 5 | 6 | 1. Collect some data for performing the refactoring and use them 7 | to construct a refactoring class. Like:: 8 | 9 | renamer = Rename(project, resource, offset) 10 | 11 | 2. Some refactorings give you useful information about the 12 | refactoring after their construction. Like:: 13 | 14 | print(renamer.get_old_name()) 15 | 16 | 3. Give the refactoring class more information about how to 17 | perform the refactoring and get the changes this refactoring is 18 | going to make. This is done by calling `get_changes` method of the 19 | refactoring class. Like:: 20 | 21 | changes = renamer.get_changes(new_name) 22 | 23 | 4. You can commit the changes. Like:: 24 | 25 | project.do(changes) 26 | 27 | These steps are like the steps IDEs usually do for performing a 28 | refactoring. These are the things an IDE does in each step: 29 | 30 | 1. Construct a refactoring object by giving it information like 31 | resource, offset and ... . Some of the refactoring problems (like 32 | performing rename refactoring on language keywords) can be reported 33 | here. 34 | 2. Print some information about the refactoring and ask the user 35 | about the information that are necessary for completing the 36 | refactoring (like new name). 37 | 3. Call the `get_changes` by passing it information asked from 38 | the user (if necessary) and get and preview the changes returned by 39 | it. 40 | 4. perform the refactoring. 41 | 42 | From ``0.5m5`` release the `get_changes()` method of some time- 43 | consuming refactorings take an optional `rope.base.taskhandle. 44 | TaskHandle` parameter. You can use this object for stopping or 45 | monitoring the progress of refactorings. 46 | 47 | """ 48 | from rope.refactor.importutils import ImportOrganizer 49 | from rope.refactor.topackage import ModuleToPackage 50 | 51 | 52 | __all__ = ['rename', 'move', 'inline', 'extract', 'restructure', 'topackage', 53 | 'importutils', 'usefunction', 'change_signature', 54 | 'encapsulate_field', 'introduce_factory', 'introduce_parameter', 55 | 'localtofield', 'method_object', 'multiproject'] 56 | -------------------------------------------------------------------------------- /pylibs/rope/refactor/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/change_signature.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/change_signature.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/extract.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/extract.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/functionutils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/functionutils.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/importutils/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/importutils/__init__.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/importutils/actions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/importutils/actions.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/importutils/importinfo.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/importutils/importinfo.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/importutils/module_imports.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/importutils/module_imports.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/inline.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/inline.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/introduce_factory.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/introduce_factory.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/localtofield.py: -------------------------------------------------------------------------------- 1 | from rope.base import pynames, evaluate, exceptions, worder 2 | from rope.refactor.rename import Rename 3 | 4 | 5 | class LocalToField(object): 6 | 7 | def __init__(self, project, resource, offset): 8 | self.project = project 9 | self.pycore = project.pycore 10 | self.resource = resource 11 | self.offset = offset 12 | 13 | def get_changes(self): 14 | name = worder.get_name_at(self.resource, self.offset) 15 | this_pymodule = self.pycore.resource_to_pyobject(self.resource) 16 | pyname = evaluate.eval_location(this_pymodule, self.offset) 17 | if not self._is_a_method_local(pyname): 18 | raise exceptions.RefactoringError( 19 | 'Convert local variable to field should be performed on \n' 20 | 'a local variable of a method.') 21 | 22 | pymodule, lineno = pyname.get_definition_location() 23 | function_scope = pymodule.get_scope().get_inner_scope_for_line(lineno) 24 | # Not checking redefinition 25 | #self._check_redefinition(name, function_scope) 26 | 27 | new_name = self._get_field_name(function_scope.pyobject, name) 28 | changes = Rename(self.project, self.resource, self.offset).\ 29 | get_changes(new_name, resources=[self.resource]) 30 | return changes 31 | 32 | def _check_redefinition(self, name, function_scope): 33 | class_scope = function_scope.parent 34 | if name in class_scope.pyobject: 35 | raise exceptions.RefactoringError( 36 | 'The field %s already exists' % name) 37 | 38 | def _get_field_name(self, pyfunction, name): 39 | self_name = pyfunction.get_param_names()[0] 40 | new_name = self_name + '.' + name 41 | return new_name 42 | 43 | def _is_a_method_local(self, pyname): 44 | pymodule, lineno = pyname.get_definition_location() 45 | holding_scope = pymodule.get_scope().get_inner_scope_for_line(lineno) 46 | parent = holding_scope.parent 47 | return isinstance(pyname, pynames.AssignedName) and \ 48 | pyname in holding_scope.get_names().values() and \ 49 | holding_scope.get_kind() == 'Function' and \ 50 | parent is not None and parent.get_kind() == 'Class' 51 | -------------------------------------------------------------------------------- /pylibs/rope/refactor/method_object.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/method_object.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/move.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/move.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/multiproject.py: -------------------------------------------------------------------------------- 1 | """This module can be used for performing cross-project refactorings 2 | 3 | See the "cross-project refactorings" section of ``docs/library.txt`` 4 | file. 5 | 6 | """ 7 | 8 | from rope.base import resources, project, libutils 9 | 10 | 11 | class MultiProjectRefactoring(object): 12 | 13 | def __init__(self, refactoring, projects, addpath=True): 14 | """Create a multiproject proxy for the main refactoring 15 | 16 | `projects` are other project. 17 | 18 | """ 19 | self.refactoring = refactoring 20 | self.projects = projects 21 | self.addpath = addpath 22 | 23 | def __call__(self, project, *args, **kwds): 24 | """Create the refactoring""" 25 | return _MultiRefactoring(self.refactoring, self.projects, 26 | self.addpath, project, *args, **kwds) 27 | 28 | 29 | class _MultiRefactoring(object): 30 | 31 | def __init__(self, refactoring, other_projects, addpath, 32 | project, *args, **kwds): 33 | self.refactoring = refactoring 34 | self.projects = [project] + other_projects 35 | for other_project in other_projects: 36 | for folder in self.project.pycore.get_source_folders(): 37 | other_project.get_prefs().add('python_path', folder.real_path) 38 | self.refactorings = [] 39 | for other in self.projects: 40 | args, kwds = self._resources_for_args(other, args, kwds) 41 | self.refactorings.append( 42 | self.refactoring(other, *args, **kwds)) 43 | 44 | def get_all_changes(self, *args, **kwds): 45 | """Get a project to changes dict""" 46 | result = [] 47 | for project, refactoring in zip(self.projects, self.refactorings): 48 | args, kwds = self._resources_for_args(project, args, kwds) 49 | result.append((project, refactoring.get_changes(*args, **kwds))) 50 | return result 51 | 52 | def __getattr__(self, name): 53 | return getattr(self.main_refactoring, name) 54 | 55 | def _resources_for_args(self, project, args, kwds): 56 | newargs = [self._change_project_resource(project, arg) for arg in args] 57 | newkwds = dict((name, self._change_project_resource(project, value)) 58 | for name, value in kwds.items()) 59 | return newargs, newkwds 60 | 61 | def _change_project_resource(self, project, obj): 62 | if isinstance(obj, resources.Resource) and \ 63 | obj.project != project: 64 | return libutils.path_to_resource(project, obj.real_path) 65 | return obj 66 | 67 | @property 68 | def project(self): 69 | return self.projects[0] 70 | 71 | @property 72 | def main_refactoring(self): 73 | return self.refactorings[0] 74 | 75 | 76 | def perform(project_changes): 77 | for project, changes in project_changes: 78 | project.do(changes) 79 | -------------------------------------------------------------------------------- /pylibs/rope/refactor/occurrences.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/occurrences.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/patchedast.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/patchedast.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/rename.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/rename.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/restructure.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/restructure.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/similarfinder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/similarfinder.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/sourceutils.py: -------------------------------------------------------------------------------- 1 | from rope.base import ast, codeanalyze 2 | 3 | 4 | def get_indents(lines, lineno): 5 | return codeanalyze.count_line_indents(lines.get_line(lineno)) 6 | 7 | 8 | def find_minimum_indents(source_code): 9 | result = 80 10 | lines = source_code.split('\n') 11 | for line in lines: 12 | if line.strip() == '': 13 | continue 14 | result = min(result, codeanalyze.count_line_indents(line)) 15 | return result 16 | 17 | 18 | def indent_lines(source_code, amount): 19 | if amount == 0: 20 | return source_code 21 | lines = source_code.splitlines(True) 22 | result = [] 23 | for l in lines: 24 | if l.strip() == '': 25 | result.append('\n') 26 | continue 27 | if amount < 0: 28 | indents = codeanalyze.count_line_indents(l) 29 | result.append(max(0, indents + amount) * ' ' + l.lstrip()) 30 | else: 31 | result.append(' ' * amount + l) 32 | return ''.join(result) 33 | 34 | 35 | def fix_indentation(code, new_indents): 36 | """Change the indentation of `code` to `new_indents`""" 37 | min_indents = find_minimum_indents(code) 38 | return indent_lines(code, new_indents - min_indents) 39 | 40 | 41 | def add_methods(pymodule, class_scope, methods_sources): 42 | source_code = pymodule.source_code 43 | lines = pymodule.lines 44 | insertion_line = class_scope.get_end() 45 | if class_scope.get_scopes(): 46 | insertion_line = class_scope.get_scopes()[-1].get_end() 47 | insertion_offset = lines.get_line_end(insertion_line) 48 | methods = '\n\n' + '\n\n'.join(methods_sources) 49 | indented_methods = fix_indentation( 50 | methods, get_indents(lines, class_scope.get_start()) + 51 | get_indent(pymodule.pycore)) 52 | result = [] 53 | result.append(source_code[:insertion_offset]) 54 | result.append(indented_methods) 55 | result.append(source_code[insertion_offset:]) 56 | return ''.join(result) 57 | 58 | 59 | def get_body(pyfunction): 60 | """Return unindented function body""" 61 | scope = pyfunction.get_scope() 62 | pymodule = pyfunction.get_module() 63 | start, end = get_body_region(pyfunction) 64 | return fix_indentation(pymodule.source_code[start:end], 0) 65 | 66 | 67 | def get_body_region(defined): 68 | """Return the start and end offsets of function body""" 69 | scope = defined.get_scope() 70 | pymodule = defined.get_module() 71 | lines = pymodule.lines 72 | node = defined.get_ast() 73 | start_line = node.lineno 74 | if defined.get_doc() is None: 75 | start_line = node.body[0].lineno 76 | elif len(node.body) > 1: 77 | start_line = node.body[1].lineno 78 | start = lines.get_line_start(start_line) 79 | scope_start = pymodule.logical_lines.logical_line_in(scope.start) 80 | if scope_start[1] >= start_line: 81 | # a one-liner! 82 | # XXX: what if colon appears in a string 83 | start = pymodule.source_code.index(':', start) + 1 84 | while pymodule.source_code[start].isspace(): 85 | start += 1 86 | end = min(lines.get_line_end(scope.end) + 1, len(pymodule.source_code)) 87 | return start, end 88 | 89 | 90 | def get_indent(pycore): 91 | project = pycore.project 92 | return project.prefs.get('indent_size', 4) 93 | -------------------------------------------------------------------------------- /pylibs/rope/refactor/sourceutils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/sourceutils.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/suites.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/suites.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/topackage.py: -------------------------------------------------------------------------------- 1 | import rope.refactor.importutils 2 | from rope.base.change import ChangeSet, ChangeContents, MoveResource, CreateFolder 3 | 4 | 5 | class ModuleToPackage(object): 6 | 7 | def __init__(self, project, resource): 8 | self.project = project 9 | self.pycore = project.pycore 10 | self.resource = resource 11 | 12 | def get_changes(self): 13 | changes = ChangeSet('Transform <%s> module to package' % 14 | self.resource.path) 15 | new_content = self._transform_relatives_to_absolute(self.resource) 16 | if new_content is not None: 17 | changes.add_change(ChangeContents(self.resource, new_content)) 18 | parent = self.resource.parent 19 | name = self.resource.name[:-3] 20 | changes.add_change(CreateFolder(parent, name)) 21 | parent_path = parent.path + '/' 22 | if not parent.path: 23 | parent_path = '' 24 | new_path = parent_path + '%s/__init__.py' % name 25 | if self.resource.project == self.project: 26 | changes.add_change(MoveResource(self.resource, new_path)) 27 | return changes 28 | 29 | def _transform_relatives_to_absolute(self, resource): 30 | pymodule = self.pycore.resource_to_pyobject(resource) 31 | import_tools = rope.refactor.importutils.ImportTools(self.pycore) 32 | return import_tools.relatives_to_absolutes(pymodule) 33 | -------------------------------------------------------------------------------- /pylibs/rope/refactor/topackage.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/topackage.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/usefunction.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/usefunction.pyc -------------------------------------------------------------------------------- /pylibs/rope/refactor/wildcards.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/rope/refactor/wildcards.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/__init__.py: -------------------------------------------------------------------------------- 1 | """ropemode, a helper for using rope refactoring library in IDEs""" 2 | 3 | INFO = __doc__ 4 | VERSION = '0.2' 5 | COPYRIGHT = """\ 6 | Copyright (C) 2007-2012 Ali Gholami Rudi 7 | 8 | This program is free software; you can redistribute it and/or modify it 9 | under the terms of GNU General Public License as published by the 10 | Free Software Foundation; either version 2 of the license, or (at your 11 | opinion) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details.""" 17 | -------------------------------------------------------------------------------- /pylibs/ropemode/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/__init__.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/decorators.py: -------------------------------------------------------------------------------- 1 | import traceback 2 | 3 | from rope.base import exceptions 4 | 5 | 6 | class Logger(object): 7 | 8 | message = None 9 | only_short = False 10 | 11 | def __call__(self, message, short=None): 12 | if short is None or not self.only_short: 13 | self._show(message) 14 | if short is not None: 15 | self._show(short) 16 | 17 | def _show(self, message): 18 | if message is None: 19 | print message 20 | else: 21 | self.message(message) 22 | 23 | logger = Logger() 24 | 25 | 26 | def lisphook(func): 27 | def newfunc(*args, **kwds): 28 | try: 29 | func(*args, **kwds) 30 | except Exception, e: 31 | trace = str(traceback.format_exc()) 32 | short = 'Ignored an exception in ropemode hook: %s' % \ 33 | _exception_message(e) 34 | logger(trace, short) 35 | newfunc.lisp = None 36 | newfunc.__name__ = func.__name__ 37 | newfunc.__doc__ = func.__doc__ 38 | return newfunc 39 | 40 | 41 | def lispfunction(func): 42 | func.lisp = None 43 | return func 44 | 45 | 46 | input_exceptions = (exceptions.RefactoringError, 47 | exceptions.ModuleSyntaxError, 48 | exceptions.BadIdentifierError) 49 | 50 | def _exception_handler(func): 51 | def newfunc(*args, **kwds): 52 | try: 53 | return func(*args, **kwds) 54 | except exceptions.RopeError, e: 55 | short = None 56 | if isinstance(e, input_exceptions): 57 | short = _exception_message(e) 58 | logger(str(traceback.format_exc()), short) 59 | newfunc.__name__ = func.__name__ 60 | newfunc.__doc__ = func.__doc__ 61 | return newfunc 62 | 63 | def _exception_message(e): 64 | return '%s: %s' % (e.__class__.__name__, str(e)) 65 | 66 | def rope_hook(hook): 67 | def decorator(func): 68 | func = lisphook(func) 69 | func.name = func.__name__ 70 | func.kind = 'hook' 71 | func.hook = hook 72 | return func 73 | return decorator 74 | 75 | 76 | def local_command(key=None, prefix=False, shortcut=None, name=None): 77 | def decorator(func, name=name): 78 | func = _exception_handler(func) 79 | func.kind = 'local' 80 | func.prefix = prefix 81 | func.local_key = key 82 | func.shortcut_key = shortcut 83 | if name is None: 84 | name = func.__name__ 85 | func.name = name 86 | return func 87 | return decorator 88 | 89 | 90 | def global_command(key=None, prefix=False): 91 | def decorator(func): 92 | func = _exception_handler(func) 93 | func.kind = 'global' 94 | func.prefix = prefix 95 | func.global_key = key 96 | func.name = func.__name__ 97 | return func 98 | return decorator 99 | -------------------------------------------------------------------------------- /pylibs/ropemode/decorators.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/decorators.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/dialog.py: -------------------------------------------------------------------------------- 1 | class Data(object): 2 | 3 | def __init__(self, prompt=None, default=None, values=None, 4 | kind=None, decode=None): 5 | self.prompt = prompt 6 | self.default = default 7 | self.values = values 8 | self.kind = kind 9 | self._decode = decode 10 | 11 | def decode(self, value): 12 | if self._decode: 13 | return self._decode(value) 14 | return value 15 | 16 | 17 | class Boolean(Data): 18 | 19 | def __init__(self, prompt=None, default=False): 20 | Data.__init__(self, prompt, self._encode(default), 21 | [self._encode(True), self._encode(False)]) 22 | 23 | def _encode(self, value): 24 | if value: 25 | return 'yes' 26 | return 'no' 27 | 28 | def decode(self, value): 29 | if value.lower() in ('yes', '1', 'true'): 30 | return True 31 | return False 32 | 33 | 34 | def show_dialog(askdata, actions, confs={}, optionals={}, initial_asking=True): 35 | result = {} 36 | if initial_asking: 37 | for name, conf in confs.items(): 38 | result[name] = askdata(conf) 39 | actions.append('batchset') 40 | names = list(actions) 41 | names.extend(optionals.keys()) 42 | names.extend(confs.keys()) 43 | base_question = Data('Choose what to do: ', 44 | default=actions[0], values=names) 45 | batchset_question = Data('Batch sets: ') 46 | while True: 47 | response = askdata(base_question) 48 | if response == '': 49 | response = base_question.default 50 | elif response == 'batchset': 51 | sets = askdata(batchset_question) 52 | for key, value in _parse_batchset(sets).items(): 53 | if key.endswith(':'): 54 | key = key[:-1] 55 | if key in names: 56 | conf = confs.get(key, optionals.get(key)) 57 | result[key] = value 58 | elif response in actions: 59 | break 60 | else: 61 | if response in confs: 62 | conf = confs[response] 63 | else: 64 | conf = optionals[response] 65 | oldvalue = result.get(response, None) 66 | result[response] = askdata(conf, starting=oldvalue) 67 | decoded = {} 68 | all_confs = dict(confs) 69 | all_confs.update(optionals) 70 | for key in all_confs: 71 | conf = all_confs.get(key) 72 | if key in result: 73 | decoded[key] = conf.decode(result[key]) 74 | else: 75 | decoded[key] = conf.decode(conf.default) 76 | return response, decoded 77 | 78 | 79 | def _parse_batchset(sets): 80 | result = [] 81 | multiline = False 82 | for line in sets.splitlines(True): 83 | if line[0].isspace(): 84 | if multiline: 85 | result[-1][1] += line[1:] 86 | else: 87 | if not line.strip(): 88 | continue 89 | multiline= False 90 | tokens = line.split(None, 1) 91 | value = '' 92 | if len(tokens) > 1: 93 | result.append([tokens[0], tokens[1].rstrip('\r\n')]) 94 | else: 95 | multiline = True 96 | result.append([tokens[0], '']) 97 | return dict(result) 98 | -------------------------------------------------------------------------------- /pylibs/ropemode/dialog.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/dialog.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/environment.py: -------------------------------------------------------------------------------- 1 | class Environment(object): 2 | 3 | def ask(self, prompt, default=None, starting=None): 4 | pass 5 | 6 | def ask_values(self, prompt, values, default=None, starting=None): 7 | pass 8 | 9 | def ask_directory(self, prompt, default=None, starting=None): 10 | pass 11 | 12 | def ask_completion(self, prompt, values, starting=None): 13 | pass 14 | 15 | def message(self, message): 16 | pass 17 | 18 | def yes_or_no(self, prompt): 19 | pass 20 | 21 | def y_or_n(self, prompt): 22 | pass 23 | 24 | def get(self, name, default=None): 25 | pass 26 | 27 | def get_offset(self): 28 | pass 29 | 30 | def get_text(self): 31 | pass 32 | 33 | def get_region(self): 34 | pass 35 | 36 | def filename(self): 37 | pass 38 | 39 | def is_modified(self): 40 | pass 41 | 42 | def goto_line(self, lineno): 43 | pass 44 | 45 | def insert_line(self, line, lineno): 46 | pass 47 | 48 | def insert(self, text): 49 | pass 50 | 51 | def delete(self, start, end): 52 | pass 53 | 54 | def filenames(self): 55 | pass 56 | 57 | def save_files(self, filenames): 58 | pass 59 | 60 | def reload_files(self, filenames, moves={}): 61 | pass 62 | 63 | def find_file(self, filename, readonly=False, other=False): 64 | pass 65 | 66 | def create_progress(self, name): 67 | pass 68 | 69 | def current_word(self): 70 | pass 71 | 72 | def push_mark(self): 73 | pass 74 | 75 | def pop_mark(self): 76 | pass 77 | 78 | def prefix_value(self, prefix): 79 | pass 80 | 81 | def show_occurrences(self, locations): 82 | pass 83 | 84 | def show_doc(self, docs, altview=False): 85 | pass 86 | 87 | def preview_changes(self, diffs): 88 | pass 89 | 90 | def local_command(self, name, callback, key=None, prefix=False): 91 | pass 92 | 93 | def global_command(self, name, callback, key=None, prefix=False): 94 | pass 95 | 96 | def add_hook(self, name, callback, hook): 97 | pass 98 | 99 | def _completion_text(self, proposal): 100 | return proposal.name 101 | 102 | def _completion_data(self, proposal): 103 | return self._completion_text(proposal) 104 | 105 | -------------------------------------------------------------------------------- /pylibs/ropemode/environment.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/environment.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/filter.py: -------------------------------------------------------------------------------- 1 | from rope.base import exceptions 2 | 3 | 4 | def resources(project, rules): 5 | """Find python files in the `project` matching `rules` 6 | 7 | `rules` is a multi-line `str`; each line starts with either a '+' 8 | or '-'. Each '+' means include the file (or its children if it's 9 | a folder) that comes after it. '-' has the same meaning for 10 | exclusion. 11 | 12 | """ 13 | all = set(project.pycore.get_python_files()) 14 | files = None 15 | for line in rules.splitlines(): 16 | if not line.strip(): 17 | continue 18 | first, path = (line[0], line[1:]) 19 | if first not in '+-': 20 | continue 21 | try: 22 | resource = project.get_resource(path.strip()) 23 | except exceptions.ResourceNotFoundError: 24 | continue 25 | if resource.is_folder(): 26 | matches = set(filter(lambda item: resource.contains(item), all)) 27 | else: 28 | matches = set([resource]) 29 | if first == '+': 30 | if files is None: 31 | files = set() 32 | files.update(matches) 33 | if first == '-': 34 | if files is None: 35 | files = set(all) 36 | files -= matches 37 | if files is None: 38 | return all 39 | return files 40 | -------------------------------------------------------------------------------- /pylibs/ropemode/filter.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/filter.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/interface.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/interface.pyc -------------------------------------------------------------------------------- /pylibs/ropemode/refactor.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropemode/refactor.pyc -------------------------------------------------------------------------------- /pylibs/ropevim.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/pylibs/ropevim.pyc -------------------------------------------------------------------------------- /pylint.ini: -------------------------------------------------------------------------------- 1 | [MESSAGES CONTROL] 2 | # Disable the message(s) with the given id(s). 3 | # http://pylint-messages.wikidot.com/all-codes 4 | # 5 | # C0103: Invalid name "%s" (should match %s) 6 | # C0111: Missing docstring 7 | # C0301: Line too long (%s/%s) 8 | # E1002: Use super on an old style class 9 | # E1101: %s %r has no %r member 10 | # R0901: Too many ancestors (%s/%s) 11 | # R0902: Too many instance attributes (%s/%s) 12 | # R0903: Too few public methods (%s/%s) 13 | # R0904: Too many public methods (%s/%s) 14 | # R0913: Too many arguments (%s/%s) 15 | # R0915: Too many statements (%s/%s) 16 | # W0141: Used builtin function %r 17 | # W0142: Used * or ** magic 18 | # W0212: Access to a protected member %s of a client class 19 | # W0221: Arguments number differs from %s method 20 | # W0223: Method %r is abstract in class %r but is not overridden 21 | # W0232: Class has no __init__ method 22 | # W0401: Wildcard import %s 23 | # W0613: Unused argument %r 24 | # W0631: Using possibly undefined loop variable %r 25 | # 26 | disable = C0103,C0111,C0301,E1002,E1101,R0901,R0902,R0903,R0904,R0913,R0915,W0141,W0142,W0212,W0221,W0223,W0232,W0401,W0613,W0631 27 | 28 | [TYPECHECK] 29 | generated-members = REQUEST,acl_users,aq_parent,objects,DoesNotExist,_meta,status_code,content,context 30 | -------------------------------------------------------------------------------- /screenshots/vim-2012-03-27-macvim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funningboy/vim/3c85c8a93a3d4c66f3f036151c9a66b261345ebf/screenshots/vim-2012-03-27-macvim.png -------------------------------------------------------------------------------- /snippets/_.snippets: -------------------------------------------------------------------------------- 1 | snippet line 2 | ------------------------------------------------------- 3 | snippet lorem Lorem Ipsum - short 4 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede. 5 | 6 | Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis. 7 | 8 | Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat. 9 | 10 | Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus. 11 | 12 | Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi. 13 | 14 | Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc. 15 | 16 | Sed adipiscing ornare risus. Morbi est est, blandit sit amet, sagittis vel, euismod vel, velit. Pellentesque egestas sem. Suspendisse commodo ullamcorper magna. 17 | snippet lorem Lorem Ipsum - long 18 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. 19 | 20 | Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna. 21 | 22 | Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl. 23 | 24 | Suspendisse mauris. Fusce accumsan mollis eros. Pellentesque a diam sit amet mi ullamcorper vehicula. Integer adipiscing risus a sem. Nullam quis massa sit amet nibh viverra malesuada. Nunc sem lacus, accumsan quis, faucibus non, congue vel, arcu. Ut scelerisque hendrerit tellus. Integer sagittis. Vivamus a mauris eget arcu gravida tristique. Nunc iaculis mi in ante. Vivamus imperdiet nibh feugiat est. 25 | 26 | Ut convallis, sem sit amet interdum consectetuer, odio augue aliquam leo, nec dapibus tortor nibh sed augue. Integer eu magna sit amet metus fermentum posuere. Morbi sit amet nulla sed dolor elementum imperdiet. Quisque fermentum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque adipiscing eros ut libero. Ut condimentum mi vel tellus. Suspendisse laoreet. Fusce ut est sed dolor gravida convallis. Morbi vitae ante. Vivamus ultrices luctus nunc. Suspendisse et dolor. Etiam dignissim. Proin malesuada adipiscing lacus. Donec metus. Curabitur gravida. 27 | -------------------------------------------------------------------------------- /snippets/coffee.snippets: -------------------------------------------------------------------------------- 1 | # port from Textmate Coffeescript bundle (https://github.com/jashkenas/coffee-script-tmbundle) 2 | # and add some snippets I used while developing Backbone app. 3 | # by Eddie Kao (eddie@digik.com.tw) 4 | 5 | # Class 6 | snippet cla Class... 7 | class ${1:ClassName} 8 | constructor: (${2:args}) -> 9 | ${3: #body...} 10 | snippet cla Class...Extends 11 | class ${1:ClassName} extends ${2:Ancestor} 12 | constructor: (${3:args}) -> 13 | ${4: # body...} 14 | snippet init 15 | constructor: (${1:args}) -> 16 | ${2: # body...} 17 | # Function 18 | snippet fun 19 | ${1:name} = (${2:args}) -> 20 | ${3: # body...} 21 | snippet func 22 | ${1:name} = (${2:args}) -> 23 | ${3: # body...} 24 | # Flow control 25 | snippet if 26 | if ${1:condition} 27 | ${0:# body...} 28 | snippet ife 29 | if ${1:condition} 30 | ${2:# body...} 31 | else 32 | ${3:# body...} 33 | snippet elif 34 | else if ${1:condition} 35 | ${2:# body...} 36 | snippet unless 37 | ${1:action} unless ${2:condition} 38 | snippet switch 39 | switch ${1:object} 40 | when ${2:value} 41 | ${3:# body...} 42 | # Bound 43 | snippet bfun 44 | (${1:args}) => ${0:# body...} 45 | # Utils 46 | snippet log 47 | console.log "${1}" 48 | snippet jq 49 | $ -> 50 | ${1:# body} 51 | # Array 52 | snippet for 53 | for ${1:name} in ${2:array} 54 | ${3: # body...} 55 | # Try 56 | snippet try 57 | try 58 | ${1:#try something} 59 | catch ${2:error} 60 | ${3:#catching something..} 61 | finally 62 | ${4:#finally..} 63 | # --------- 64 | # Backbone 65 | # --------- 66 | snippet root 67 | root = exports ? this 68 | snippet winapp 69 | @app = window.app ? {} 70 | # Backbone - Collection 71 | snippet BB create a Backbone Collection class 72 | class ${1:CollectionClassName} extends Backbone.Collection 73 | 74 | model: ${2:ModelName} 75 | 76 | url: '${3:URL}' 77 | ${4} 78 | 79 | # Backbone - Model 80 | snippet BB create a Backbone Model class 81 | class ${1:ModelName} extends Backbone.Model 82 | urlRoot: '${2}url' 83 | ${3} 84 | 85 | # Backbone - View 86 | snippet BB create a Backbone View class 87 | class ${1:ViewClassName} extends Backbone.View 88 | 89 | # element settings 90 | tagName: "${2}" 91 | className: "${3}" 92 | id: "${4}" 93 | 94 | # initializer, you might register model or 95 | # collection's event listener here. 96 | # example: @model.on 'change', @render, @ 97 | initialize: -> 98 | ${5} 99 | 100 | # view events 101 | events: 102 | "click": "open" 103 | 104 | # template method 105 | template: _.template($('#${6}').html()) 106 | 107 | # render method, usually return self conventionally for chaining 108 | render: -> 109 | $(@el).html(@template()) 110 | @ 111 | 112 | # Backbone - Route 113 | snippet BB create a Backbone Router class 114 | class ${1:RouterClassName} extends Backbone.Router 115 | # urls mapping 116 | routes: 117 | # map the root path to index action 118 | "": "index" 119 | 120 | index: -> 121 | alert "hello" 122 | ${2} 123 | 124 | -------------------------------------------------------------------------------- /snippets/eruby.snippets: -------------------------------------------------------------------------------- 1 | snippet lt 2 | <%= link_to "${1:caption}", ${2:path} %>${3} 3 | snippet cf 4 | <%= content_for :${1:yield_label_name} do %> 5 | ${2} 6 | <% end %> 7 | snippet ff 8 | <% form_for @${1:model} do |f| %> 9 | <%= f.error_messages %> 10 | <%= f.submit "${2:button}" %> 11 | <% end %> 12 | snippet ffff 13 | <%= f.file_field :${1:attribute} %> 14 | snippet ffhf 15 | <%= f.hidden_field :${1:attribute} %> 16 | snippet ffl 17 | <%= f.label :${1:attribute}, '${2:label}' %> 18 | snippet ffpf 19 | <%= f.password_field :${1:attribute} %> 20 | snippet ffrb 21 | <%= f.radio_button :${1:attribute}, :${2:tag_value} %> 22 | snippet ffs 23 | <%= f.submit "${1:Submit}" %> 24 | snippet ffta 25 | <%= f.text_area :${1:attribute} %> 26 | snippet fftf 27 | <%= f.text_field :${1:attribute} %> 28 | snippet jit 29 | <%= javascript_include_tag "${1:javascript_filename}" %> 30 | snippet slt 31 | <%= stylesheet_link_tag "${1:stylesheet_filename}", :media => "${2:all}" %> 32 | snippet each 33 | <% ${1:collection}.each do |${2:member}| %> 34 | ${3} 35 | <% end %> 36 | snippet if 37 | <% if ${1:condition} %> 38 | ${2} 39 | <% end %> 40 | snippet unless 41 | <% unless ${1:cond} %> 42 | ${2} 43 | <% end %> 44 | snippet ife 45 | <% if ${1:cond} %> 46 | ${2} 47 | <% else %> 48 | ${3} 49 | <% end %> 50 | snippet yield 51 | <%= yield :${1:partial} %> 52 | -------------------------------------------------------------------------------- /snippets/gitignore.snippets: -------------------------------------------------------------------------------- 1 | snippet ignore ActionScript 2 | # Build and Release Folders 3 | bin-debug/ 4 | bin-release/ 5 | 6 | # Project property files 7 | .actionScriptProperties 8 | .flexProperties 9 | .settings/ 10 | .project 11 | snippet ignore Compass 12 | .sass-cache 13 | snippet ignore Django 14 | *.log 15 | *.pot 16 | *.pyc 17 | local_settings.py 18 | snippet ignore Node 19 | lib-cov 20 | *.seed 21 | *.log 22 | *.csv 23 | *.dat 24 | *.out 25 | *.pid 26 | *.gz 27 | pids 28 | logs 29 | results 30 | node_modules 31 | npm-debug.log 32 | snippet ignore Rails 33 | *.rbc 34 | *.sassc 35 | .sass-cache 36 | capybara-*.html 37 | .rspec 38 | /.bundle 39 | /vendor/bundle 40 | /log/* 41 | /tmp/* 42 | /db/*.sqlite3 43 | /public/system/* 44 | /coverage/ 45 | /spec/tmp/* 46 | **.orig 47 | rerun.txt 48 | pickle-email-*.html 49 | snippet ignore Ruby 50 | *.gem 51 | *.rbc 52 | .bundle 53 | .config 54 | coverage 55 | InstalledFiles 56 | lib/bundler/man 57 | pkg 58 | rdoc 59 | spec/reports 60 | test/tmp 61 | test/version_tmp 62 | tmp 63 | 64 | # YARD artifacts 65 | .yardoc 66 | _yardoc 67 | doc/ 68 | -------------------------------------------------------------------------------- /snippets/html.snippets: -------------------------------------------------------------------------------- 1 | snippet jstemplate 2 | ${3} 5 | snippet js 6 | ${2} 9 | snippet jssrc 10 | ${2} 11 | snippet css 12 | ${3} 15 | snippet br 16 |
${1} 17 | snippet html5 18 | 19 | 20 | 21 | 22 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} 23 | 24 | 25 | ${2:} 26 | 27 | 28 | snippet bootstrap create a Twitter Bootstrap page 29 | 30 | 31 | 32 | 33 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 64 | 65 |
66 |

${3:Page Title}

67 |

${4:Page Subtitle}

68 |
69 |
70 |
71 | ${5:Content here!} 72 |
73 |
74 |
75 |
76 | 77 | 78 | 79 | snippet bootstrap create a Twitter Bootstrap table 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |
${1}column 1column 2
content 1content 2
content 1content 2
content 1content 2
102 | -------------------------------------------------------------------------------- /snippets/javascript.snippets: -------------------------------------------------------------------------------- 1 | snippet log 2 | console.log("${1}")${2} 3 | -------------------------------------------------------------------------------- /snippets/mkd.snippets: -------------------------------------------------------------------------------- 1 | snippet link 2 | [${1:description}](${2:url})${3} 3 | snippet image 4 | ![image](${1:image path})${2} 5 | # ----------------------------------------- 6 | # personal usage in Octopress blog plugin 7 | # ----------------------------------------- 8 | snippet blog Header 9 | --- 10 | layout: post 11 | title: ${1:Blog Title} 12 | date: `strftime("%Y-%m-%d %H:%M")` 13 | comments: true 14 | categories: 15 | --- 16 | ${2} 17 | snippet video Youtube 18 | {% youtube ${1:video code} %}${2} 19 | snippet video Vimeo 20 | {% vimeo ${1:video code} %}${2} 21 | snippet code Ruby 22 | {% codeblock lang:rb %} 23 | ${1} 24 | {% endcodeblock %} 25 | snippet code Python 26 | {% codeblock lang:py %} 27 | ${1} 28 | {% endcodeblock %} 29 | -------------------------------------------------------------------------------- /snippets/ruby.snippets: -------------------------------------------------------------------------------- 1 | snippet rt 2 | render text: ${1} 3 | snippet lt 4 | <%= link_to "${1}", ${2} %>${3} 5 | snippet bf 6 | before_filter :${1} 7 | snippet hm 8 | has_many :${1}s 9 | snippet bt 10 | belongs_to :${1} 11 | snippet habtm 12 | has_and_belongs_to_many :${1} 13 | snippet aa 14 | attr_accessible :${1} 15 | snippet flash 16 | flash[:${1:notice}] = "${2}" 17 | snippet crud 18 | def index${1} 19 | end 20 | 21 | def show 22 | end 23 | 24 | def new 25 | end 26 | 27 | def create 28 | end 29 | 30 | def edit 31 | end 32 | 33 | def update 34 | end 35 | 36 | def destroy 37 | end 38 | -------------------------------------------------------------------------------- /snippets/scala.snippets: -------------------------------------------------------------------------------- 1 | snippet class 2 | class ${1:ClassName} { 3 | ${2} 4 | }${3} 5 | ## case class 6 | snippet cclass 7 | case class ${1:ClassName} { 8 | ${2} 9 | }${3} 10 | snippet trait 11 | trait ${1:TraitName} { 12 | ${2} 13 | }${3} 14 | ## singleton object 15 | snippet object 16 | object ${1:ObjectName} { 17 | ${2} 18 | }${3} 19 | ## application trait 20 | snippet application 21 | object ${1:ObjectName} extends Application { 22 | ${2} 23 | }${3} 24 | ## defines a type (e.g. structural) 25 | snippet type 26 | type ${1} = {${2}}${3} 27 | ## method definition 28 | snippet def 29 | def ${1:method}(${2})${3: : ${4:Unit}} = { 30 | ${5} 31 | }${6} 32 | ## if conditional 33 | snippet if 34 | if (${1:condition}) { 35 | ${2:// expression} 36 | }${3} 37 | snippet ifelse 38 | if (${1:condition}) { 39 | ${2:// expression} 40 | } else { 41 | ${3} 42 | }${4} 43 | snippet while 44 | while (${1:condition}) { 45 | ${2:// expression} 46 | }${3} 47 | snippet try 48 | try { 49 | ${2:// expression} 50 | } 51 | catch { 52 | case e : ${1:Exception} => ${3:// expression} 53 | }${4} 54 | ## try..catch..finally 55 | snippet tfc 56 | try { 57 | ${2:// expression} 58 | } 59 | catch { 60 | case e : ${1:Exception} => ${3:// expression} 61 | } 62 | finally { 63 | ${4:// expression} 64 | }${5} 65 | ## private 66 | snippet pr 67 | private 68 | ## scoped private 69 | snippet pri 70 | private[${1:this}]${2} 71 | ## protected 72 | snippet pro 73 | protected 74 | ## scoped protected 75 | snippet prop 76 | protected[${1:this}]${2} 77 | snippet for 78 | for (${1} <- ${2}) { 79 | ${3} 80 | }${4} 81 | snippet foreach 82 | foreach {${1} => 83 | ${2} 84 | }${3} 85 | snippet match 86 | match { 87 | case ${1} => ${2} 88 | }${3} 89 | snippet case 90 | case ${1} => ${2}${3} 91 | ## println 92 | snippet p 93 | println(${1})${2} 94 | snippet main 95 | def main(args: Array[String]) = { 96 | ${1} 97 | }${2} 98 | ## specifies arguments - x1 99 | snippet 1 100 | (${1:first}: ${2:Type})${3} 101 | ## specifies arguments - x2 102 | snippet 2 103 | (${1:first}: ${2:Type}, ${3:second}: ${4:Type})${5} 104 | ## specifies arguments - x3 105 | snippet 3 106 | (${1:first}: ${2:Type}, ${3:second}: ${4:Type}, ${5:third}: ${6:Type})${7} 107 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git pull origin master 3 | git submodule init 4 | git submodule update 5 | git submodule foreach git submodule init 6 | git submodule foreach git submodule update 7 | git submodule foreach git pull 8 | #git submodule foreach git pull origin master 9 | 10 | # special case 11 | # vim-powerline : develop 12 | git submodule foreach '[ "$path" = "bundle/vim-powerline" ] && branch=develop \ 13 | || branch=master; git checkout $branch' 14 | --------------------------------------------------------------------------------