k now... emacs>vim

This commit is contained in:
TuDatTr
2017-12-19 22:52:42 +01:00
parent d701704955
commit df3a90ee6b
1500 changed files with 44508 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
(defun elpy-snippet-split-args (arg-string)
"Split a python argument string into ((name, default)..) tuples"
(mapcar (lambda (x)
(split-string x "[[:blank:]]*=[[:blank:]]*" t))
(split-string arg-string "[[:blank:]]*,[[:blank:]]*" t)))
(defun elpy-snippet-current-method-and-args ()
"Return information on the current definition."
(let ((current-defun (python-info-current-defun))
(current-arglist
(save-excursion
(python-nav-beginning-of-defun)
(when (re-search-forward "(" nil t)
(let* ((start (point))
(end (progn
(forward-char -1)
(forward-sexp)
(- (point) 1))))
(elpy-snippet-split-args
(buffer-substring-no-properties start end))))))
class method args)
(when (not current-arglist)
(setq current-arglist '(("self"))))
(if (and current-defun
(string-match "^\\(.*\\)\\.\\(.*\\)$" current-defun))
(setq class (match-string 1 current-defun)
method (match-string 2 current-defun))
(setq class "Class"
method "method"))
(setq args (mapcar #'car current-arglist))
(list class method args)))
(defun elpy-snippet-init-assignments (arg-string)
"Return the typical __init__ assignments for arguments."
(let ((indentation (make-string (save-excursion
(goto-char start-point)
(current-indentation))
?\s)))
(mapconcat (lambda (arg)
(if (string-match "^\\*" (car arg))
""
(format "self.%s = %s\n%s"
(car arg)
(car arg)
indentation)))
(elpy-snippet-split-args arg-string)
"")))
(defun elpy-snippet-super-form ()
"Return (Class, first-arg).method if Py2.
Else return ().method for Py3."
(let* ((defun-info (elpy-snippet-current-method-and-args))
(class (nth 0 defun-info))
(method (nth 1 defun-info))
(args (nth 2 defun-info))
(first-arg (nth 0 args))
(py-version-command " -c 'import sys ; print(sys.version_info.major)'")
;; Get the python version. Either 2 or 3
(py-version-num (substring (shell-command-to-string (concat elpy-rpc-python-command py-version-command))0 1)))
(if (string-match py-version-num "2")
(format "(%s, %s).%s" class first-arg method)
(format "().%s" method))))
(defun elpy-snippet-super-arguments ()
"Return the argument list for the current method."
(mapconcat (lambda (x) x)
(cdr (nth 2 (elpy-snippet-current-method-and-args)))
", "))

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __abs__
# key: __abs__
# group: Special methods
# --
def __abs__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __add__
# key: __add__
# group: Special methods
# --
def __add__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __and__
# key: __and__
# group: Special methods
# --
def __and__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __bool__
# key: __bool__
# group: Special methods
# --
def __bool__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __call__
# key: __call__
# group: Special methods
# --
def __call__(self, ${1:*args}):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __cmp__
# key: __cmp__
# group: Special methods
# --
def __cmp__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __coerce__
# key: __coerce__
# group: Special methods
# --
def __coerce__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __complex__
# key: __complex__
# group: Special methods
# --
def __complex__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __contains__
# key: __contains__
# group: Special methods
# --
def __contains__(self, item):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __del__
# key: __del__
# group: Special methods
# --
def __del__(self):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __delattr__
# key: __delattr__
# group: Special methods
# --
def __delattr__(self, name):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __delete__
# key: __delete__
# group: Special methods
# --
def __delete__(self, instance):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __delitem__
# key: __delitem__
# group: Special methods
# --
def __delitem__(self, key):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __div__
# key: __div__
# group: Special methods
# --
def __div__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __divmod__
# key: __divmod__
# group: Special methods
# --
def __divmod__(self, other):
return $0

View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: __enter__
# key: __enter__
# group: Special methods
# --
def __enter__(self):
$0
return self

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __eq__
# key: __eq__
# group: Special methods
# --
def __eq__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __exit__
# key: __exit__
# group: Special methods
# --
def __exit__(self, exc_type, exc_value, traceback):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __float__
# key: __float__
# group: Special methods
# --
def __float__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __floordiv__
# key: __floordiv__
# group: Special methods
# --
def __floordiv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ge__
# key: __ge__
# group: Special methods
# --
def __ge__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __get__
# key: __get__
# group: Special methods
# --
def __get__(self, instance, owner):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __getattr__
# key: __getattr__
# group: Special methods
# --
def __getattr__(self, name):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __getattribute__
# key: __getattribute__
# group: Special methods
# --
def __getattribute__(self, name):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __getitem__
# key: __getitem__
# group: Special methods
# --
def __getitem__(self, key):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __gt__
# key: __gt__
# group: Special methods
# --
def __gt__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __hash__
# key: __hash__
# group: Special methods
# --
def __hash__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __hex__
# key: __hex__
# group: Special methods
# --
def __hex__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __iadd__
# key: __iadd__
# group: Special methods
# --
def __iadd__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __iand__
# key: __iand__
# group: Special methods
# --
def __iand__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __idiv__
# key: __idiv__
# group: Special methods
# --
def __idiv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ifloordiv__
# key: __ifloordiv__
# group: Special methods
# --
def __ifloordiv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ilshift__
# key: __ilshift__
# group: Special methods
# --
def __ilshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __imod__
# key: __imod__
# group: Special methods
# --
def __imod__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __imul__
# key: __imul__
# group: Special methods
# --
def __imul__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __index__
# key: __index__
# group: Special methods
# --
def __index__(self):
return $0

View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: __init__ with assignment
# key: __init__
# group: Special methods
# --
def __init__(self${1:, args}):
"""$2
"""
${1:$(elpy-snippet-init-assignments yas-text)}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __instancecheck__
# key: __instancecheck__
# group: Special methods
# --
def __instancecheck__(self, instance):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __int__
# key: __int__
# group: Special methods
# --
def __int__(self):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __invert__
# key: __invert__
# group: Special methods
# --
def __invert__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ior__
# key: __ior__
# group: Special methods
# --
def __ior__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ipow__
# key: __ipow__
# group: Special methods
# --
def __ipow__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __irshift__
# key: __irshift__
# group: Special methods
# --
def __irshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __isub__
# key: __isub__
# group: Special methods
# --
def __isub__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __iter__
# key: __iter__
# group: Special methods
# --
def __iter__(self):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __itruediv__
# key: __itruediv__
# group: Special methods
# --
def __itruediv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ixor__
# key: __ixor__
# group: Special methods
# --
def __ixor__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __le__
# key: __le__
# group: Special methods
# --
def __le__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __len__
# key: __len__
# group: Special methods
# --
def __len__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __long__
# key: __long__
# group: Special methods
# --
def __long__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __lshift__
# key: __lshift__
# group: Special methods
# --
def __lshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __lt__
# key: __lt__
# group: Special methods
# --
def __lt__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __mod__
# key: __mod__
# group: Special methods
# --
def __mod__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __mul__
# key: __mul__
# group: Special methods
# --
def __mul__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ne__
# key: __ne__
# group: Special methods
# --
def __ne__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __neg__
# key: __neg__
# group: Special methods
# --
def __neg__(self):
return $0

View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: __new__
# key: __new__
# group: Special methods
# --
def __new__(cls${1:, args}):
"""$2
"""
${1:$(elpy-snippet-init-assignments yas-text)}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __nonzero__
# key: __nonzero__
# group: Special methods
# --
def __nonzero__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __oct__
# key: __oct__
# group: Special methods
# --
def __oct__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __or__
# key: __or__
# group: Special methods
# --
def __or__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __pos__
# key: __pos__
# group: Special methods
# --
def __pos__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __pow__
# key: __pow__
# group: Special methods
# --
def __pow__(self, other, modulo=None):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __radd__
# key: __radd__
# group: Special methods
# --
def __radd__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rand__
# key: __rand__
# group: Special methods
# --
def __rand__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rdivmod__
# key: __rdivmod__
# group: Special methods
# --
def __rdivmod__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __repr__
# key: __repr__
# group: Special methods
# --
def __repr__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __reversed__
# key: __reversed__
# group: Special methods
# --
def __reversed__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rfloordiv__
# key: __rfloordiv__
# group: Special methods
# --
def __rfloordiv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rlshift__
# key: __rlshift__
# group: Special methods
# --
def __rlshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rmod__
# key: __rmod__
# group: Special methods
# --
def __rmod__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rmul__
# key: __rmul__
# group: Special methods
# --
def __rmul__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __ror__
# key: __ror__
# group: Special methods
# --
def __ror__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rpow__
# key: __rpow__
# group: Special methods
# --
def __rpow__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rrshift__
# key: __rrshift__
# group: Special methods
# --
def __rrshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rshift__
# key: __rshift__
# group: Special methods
# --
def __rshift__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rsub__
# key: __rsub__
# group: Special methods
# --
def __rsub__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rtruediv__
# key: __rtruediv__
# group: Special methods
# --
def __rtruediv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __rxor__
# key: __rxor__
# group: Special methods
# --
def __rxor__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __set__
# key: __set__
# group: Special methods
# --
def __set__(self, instance, value):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __setattr__
# key: __setattr__
# group: Special methods
# --
def __setattr__(self, name, value):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __setitem__
# key: __setitem__
# group: Special methods
# --
def __setitem__(self, key, value):
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __slots__
# key: __slots__
# group: Class attributes
# --
__slots__ = ($1)
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __str__
# key: __str__
# group: Special methods
# --
def __str__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __sub__
# key: __sub__
# group: Special methods
# --
def __sub__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __subclasscheck__
# key: __subclasscheck__
# group: Special methods
# --
def __subclasscheck__(self, instance):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __truediv__
# key: __truediv__
# group: Special methods
# --
def __truediv__(self, other):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __unicode__
# key: __unicode__
# group: Special methods
# --
def __unicode__(self):
return $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: __xor__
# key: __xor__
# group: Special methods
# --
def __xor__(self, other):
return $0

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: Assert Equal
# key: ase
# group: Testing
# --
self.assertEqual(${1:expected}, ${2:actual})

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: Assert Not Equal
# key: asne
# group: Testing
# --
self.assertNotEqual(${1:expected}, ${2:actual})

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: Assert Raises
# key: asr
# group: Testing
# --
with self.assertRaises(${1:Exception}):
$0

View File

@@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# name: class(parent): ...
# key: class
# group: Definitions
# --
class ${1:ClassName}(${2:object}):
"""${3:Documentation for $1}
"""
def __init__(self${4:, args}):
super($1, self).__init__($5)
${4:$(elpy-snippet-init-assignments yas-text)}
$0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: def method(self, ...):
# key: defs
# group: Definitions
# --
def ${1:methodname}(self, ${2:arg}):
${3:pass}

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: # coding: utf-8
# key: enc
# group: Header
# --
# coding: utf-8

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: #!/usr/bin/env python
# key: env
# group: Header
# --
#!/usr/bin/env python

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: from MOD import SYM
# key: from
# group: Header
# --
from ${1:module} import ${2:symbol}
$0

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: pdb.set_trace()
# key: pdb
# group: Debug
# --
import pdb; pdb.set_trace()

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: from __future__ import ...
# key: py3
# group: Python 3
# --
from __future__ import division, absolute_import
from __future__ import print_function, unicode_literals

Some files were not shown because too many files have changed in this diff Show More