init
This commit is contained in:
1
snippets/python-mode/.yas-parents
Normal file
1
snippets/python-mode/.yas-parents
Normal file
@@ -0,0 +1 @@
|
||||
prog-mode
|
||||
38
snippets/python-mode/.yas-setup.el
Normal file
38
snippets/python-mode/.yas-setup.el
Normal file
@@ -0,0 +1,38 @@
|
||||
(require 'yasnippet)
|
||||
(defvar yas-text)
|
||||
|
||||
(defun python-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 python-args-to-docstring ()
|
||||
"return docstring format for the python arguments in yas-text"
|
||||
(let* ((indent (concat "\n" (make-string (current-column) 32)))
|
||||
(args (python-split-args yas-text))
|
||||
(max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0))
|
||||
(formatted-args (mapconcat
|
||||
(lambda (x)
|
||||
(concat (nth 0 x) (make-string (- max-len (length (nth 0 x))) ? ) " -- "
|
||||
(if (nth 1 x) (concat "\(default " (nth 1 x) "\)"))))
|
||||
args
|
||||
indent)))
|
||||
(unless (string= formatted-args "")
|
||||
(mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent))))
|
||||
|
||||
(defun python-args-to-docstring-numpy ()
|
||||
"return docstring format for the python arguments in yas-text"
|
||||
(let* ((args (python-split-args yas-text))
|
||||
(format-arg (lambda(arg)
|
||||
(concat (nth 0 arg) " : " (if (nth 1 arg) ", optional") "\n")))
|
||||
(formatted-params (mapconcat format-arg args "\n"))
|
||||
(formatted-ret (mapconcat format-arg (list (list "out")) "\n")))
|
||||
(unless (string= formatted-params "")
|
||||
(mapconcat 'identity
|
||||
(list "\nParameters\n----------" formatted-params
|
||||
"\nReturns\n-------" formatted-ret)
|
||||
"\n"))))
|
||||
|
||||
|
||||
(add-hook 'python-mode-hook #'yasnippet-snippets--fixed-indent)
|
||||
7
snippets/python-mode/__contains__
Normal file
7
snippets/python-mode/__contains__
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __contains__
|
||||
# key: cont
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __contains__(self, el):
|
||||
$0
|
||||
9
snippets/python-mode/__enter__
Normal file
9
snippets/python-mode/__enter__
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __enter__
|
||||
# key: ent
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __enter__(self):
|
||||
$0
|
||||
|
||||
return self
|
||||
7
snippets/python-mode/__exit__
Normal file
7
snippets/python-mode/__exit__
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __exit__
|
||||
# key: ex
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __exit__(self, type, value, traceback):
|
||||
$0
|
||||
7
snippets/python-mode/__getitem__
Normal file
7
snippets/python-mode/__getitem__
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __getitem__
|
||||
# key: getit
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __getitem__(self, ${1:key}):
|
||||
$0
|
||||
7
snippets/python-mode/__len__
Normal file
7
snippets/python-mode/__len__
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __len__
|
||||
# key: len
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __len__(self):
|
||||
$0
|
||||
8
snippets/python-mode/__new__
Normal file
8
snippets/python-mode/__new__
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __new__
|
||||
# key: new
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __new__(mcs, name, bases, dct):
|
||||
$0
|
||||
return type.__new__(mcs, name, bases, dct)
|
||||
7
snippets/python-mode/__setitem__
Normal file
7
snippets/python-mode/__setitem__
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __setitem__
|
||||
# key: setit
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __setitem__(self, ${1:key}, ${2:val}):
|
||||
$0
|
||||
7
snippets/python-mode/all
Normal file
7
snippets/python-mode/all
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: all
|
||||
# key: all
|
||||
# --
|
||||
__all__ = [
|
||||
$0
|
||||
]
|
||||
7
snippets/python-mode/arg
Normal file
7
snippets/python-mode/arg
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: arg
|
||||
# key: arg
|
||||
# group: argparser
|
||||
# --
|
||||
parser.add_argument('-$1', '--$2',
|
||||
$0)
|
||||
6
snippets/python-mode/arg_positional
Normal file
6
snippets/python-mode/arg_positional
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: arg_positional
|
||||
# key: arg
|
||||
# group: argparser
|
||||
# --
|
||||
parser.add_argument('${1:varname}', $0)
|
||||
6
snippets/python-mode/assert
Normal file
6
snippets/python-mode/assert
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assert
|
||||
# key: ass
|
||||
# group: testing
|
||||
# --
|
||||
assert $0
|
||||
6
snippets/python-mode/assertEqual
Normal file
6
snippets/python-mode/assertEqual
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertEqual
|
||||
# key: ae
|
||||
# group: testing
|
||||
# --
|
||||
self.assertEqual($1, $2)
|
||||
6
snippets/python-mode/assertFalse
Normal file
6
snippets/python-mode/assertFalse
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertFalse
|
||||
# key: af
|
||||
# group: testing
|
||||
# --
|
||||
self.assertFalse($0)
|
||||
6
snippets/python-mode/assertIn
Normal file
6
snippets/python-mode/assertIn
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertIn
|
||||
# key: ai
|
||||
# group: testing
|
||||
# --
|
||||
self.assertIn(${1:member}, ${2:container})
|
||||
6
snippets/python-mode/assertNotEqual
Normal file
6
snippets/python-mode/assertNotEqual
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertNotEqual
|
||||
# key: ane
|
||||
# group: testing
|
||||
# --
|
||||
self.assertNotEqual($1, $2)
|
||||
6
snippets/python-mode/assertNotIn
Normal file
6
snippets/python-mode/assertNotIn
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assetNotIn
|
||||
# key: an
|
||||
# group: testing
|
||||
# --
|
||||
self.assertNotIn(${1:member}, ${2:container})
|
||||
6
snippets/python-mode/assertRaises
Normal file
6
snippets/python-mode/assertRaises
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertRaises
|
||||
# key: ar
|
||||
# group: testing
|
||||
# --
|
||||
self.assertRaises(${1:Exception}, ${2:fun})
|
||||
6
snippets/python-mode/assertRaises.with
Normal file
6
snippets/python-mode/assertRaises.with
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertRaisesWith
|
||||
# key: arw
|
||||
# --
|
||||
with self.assertRaises(${1:Exception}):
|
||||
$0
|
||||
6
snippets/python-mode/assertTrue
Normal file
6
snippets/python-mode/assertTrue
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: assertTrue
|
||||
# key: at
|
||||
# group: testing
|
||||
# --
|
||||
self.assertTrue($0)
|
||||
6
snippets/python-mode/bang
Normal file
6
snippets/python-mode/bang
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: #!
|
||||
# key: #!
|
||||
# contributor : @avelino
|
||||
# --
|
||||
#!/usr/bin/env python
|
||||
6
snippets/python-mode/celery_pdb
Normal file
6
snippets/python-mode/celery_pdb
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: celery pdb
|
||||
# key: cdb
|
||||
# group: debug
|
||||
# --
|
||||
from celery.contrib import rdb; rdb.set_trace()
|
||||
11
snippets/python-mode/class_doxygen_doc
Normal file
11
snippets/python-mode/class_doxygen_doc
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Dan Pitic <dpitic@gmail.com>
|
||||
# name: Class Doxygen Doc
|
||||
# key: doxy_class
|
||||
# group: doxygen
|
||||
# --
|
||||
"""
|
||||
@brief ${1:class description}
|
||||
|
||||
@details ${2:detailed description}
|
||||
"""
|
||||
8
snippets/python-mode/classmethod
Normal file
8
snippets/python-mode/classmethod
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: classmethod
|
||||
# key: cm
|
||||
# group: object oriented
|
||||
# --
|
||||
@classmethod
|
||||
def ${1:meth}(cls, $2):
|
||||
$0
|
||||
7
snippets/python-mode/cls
Normal file
7
snippets/python-mode/cls
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: class
|
||||
# key: cls
|
||||
# group: object oriented
|
||||
# --
|
||||
class ${1:class}:
|
||||
$0
|
||||
8
snippets/python-mode/dataclass
Normal file
8
snippets/python-mode/dataclass
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: dataclass
|
||||
# key: dc
|
||||
# group: object oriented
|
||||
# --
|
||||
@dataclass
|
||||
class ${1:class}:
|
||||
$0
|
||||
14
snippets/python-mode/dec
Normal file
14
snippets/python-mode/dec
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: dec
|
||||
# key: dec
|
||||
# group : definitions
|
||||
# --
|
||||
def ${1:decorator}(func):
|
||||
$2
|
||||
def _$1(*args, **kwargs):
|
||||
$3
|
||||
ret = func(*args, **kwargs)
|
||||
$4
|
||||
return ret
|
||||
|
||||
return _$1
|
||||
7
snippets/python-mode/deftest
Normal file
7
snippets/python-mode/deftest
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: deftest
|
||||
# key: dt
|
||||
# group: testing
|
||||
# --
|
||||
def test_${1:long_name}(self):
|
||||
$0
|
||||
7
snippets/python-mode/django_test_class
Normal file
7
snippets/python-mode/django_test_class
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet; require-final-newline: nil -*-
|
||||
# name: django_test_class
|
||||
# key: tcs
|
||||
# group: testing
|
||||
# --
|
||||
class ${1:Model}Test(TestCase):
|
||||
$0
|
||||
6
snippets/python-mode/doc
Normal file
6
snippets/python-mode/doc
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: doc
|
||||
# key: d
|
||||
# --
|
||||
"""$0
|
||||
"""
|
||||
8
snippets/python-mode/doctest
Normal file
8
snippets/python-mode/doctest
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: doctest
|
||||
# key: doc
|
||||
# group: testing
|
||||
# --
|
||||
>>> ${1:function calls}
|
||||
${2:desired output}
|
||||
$0
|
||||
5
snippets/python-mode/embed
Normal file
5
snippets/python-mode/embed
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: embed
|
||||
# key: embed
|
||||
# --
|
||||
from IPython import embed; embed()
|
||||
7
snippets/python-mode/enum
Normal file
7
snippets/python-mode/enum
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: enum
|
||||
# key: en
|
||||
# group: object oriented
|
||||
# --
|
||||
class ${1:class}(Enum):
|
||||
$0
|
||||
7
snippets/python-mode/eq
Normal file
7
snippets/python-mode/eq
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __eq__
|
||||
# key: eq
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __eq__(self, other):
|
||||
return self.$1 == other.$1
|
||||
7
snippets/python-mode/for
Normal file
7
snippets/python-mode/for
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: for ... in ... : ...
|
||||
# key: for
|
||||
# group : control structure
|
||||
# --
|
||||
for ${var} in ${collection}:
|
||||
$0
|
||||
6
snippets/python-mode/from
Normal file
6
snippets/python-mode/from
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: from
|
||||
# key: from
|
||||
# group : general
|
||||
# --
|
||||
from ${1:lib} import ${2:funs}
|
||||
7
snippets/python-mode/function
Normal file
7
snippets/python-mode/function
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: function
|
||||
# key: f
|
||||
# group: definitions
|
||||
# --
|
||||
def ${1:fun}(${2:args}):
|
||||
$0
|
||||
11
snippets/python-mode/function_docstring
Normal file
11
snippets/python-mode/function_docstring
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: function_docstring
|
||||
# key: fd
|
||||
# group: definitions
|
||||
# NOTE: Use minimum indentation, because Emacs 25+ doesn't dedent docstrings.
|
||||
# --
|
||||
def ${1:name}($2):
|
||||
\"\"\"$3
|
||||
${2:$(python-args-to-docstring)}
|
||||
\"\"\"
|
||||
$0
|
||||
12
snippets/python-mode/function_docstring_numpy
Normal file
12
snippets/python-mode/function_docstring_numpy
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Egor Panfilov <egor.v.panfilov[at]gmail[dot]com>
|
||||
# name: function_docstring_numpy
|
||||
# key: fdn
|
||||
# group: definitions
|
||||
# --
|
||||
def ${1:name}($2):
|
||||
\"\"\"$3
|
||||
|
||||
${2:$(python-args-to-docstring-numpy)}
|
||||
\"\"\"
|
||||
$0
|
||||
15
snippets/python-mode/function_doxygen_doc
Normal file
15
snippets/python-mode/function_doxygen_doc
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Dan Pitic <dpitic@gmail.com>
|
||||
# name: Function Doxygen Doc
|
||||
# key: doxy_func
|
||||
# group: doxygen
|
||||
# --
|
||||
"""
|
||||
@brief ${1:function description}
|
||||
|
||||
@details ${2:detailed description}
|
||||
|
||||
@param ${3:param}
|
||||
|
||||
@return ${4:return type}
|
||||
"""
|
||||
6
snippets/python-mode/ic.py
Normal file
6
snippets/python-mode/ic.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: ic
|
||||
# key: ic
|
||||
# --
|
||||
from icecream import ic
|
||||
ic($1)
|
||||
7
snippets/python-mode/if
Normal file
7
snippets/python-mode/if
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: if
|
||||
# key: if
|
||||
# group : control structure
|
||||
# --
|
||||
if ${1:cond}:
|
||||
$0
|
||||
9
snippets/python-mode/ife
Normal file
9
snippets/python-mode/ife
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: ife
|
||||
# key: ife
|
||||
# group : control structure
|
||||
# --
|
||||
if $1:
|
||||
$2
|
||||
else:
|
||||
$0
|
||||
6
snippets/python-mode/ifmain
Normal file
6
snippets/python-mode/ifmain
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: ifmain
|
||||
# key: ifm
|
||||
# --
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
7
snippets/python-mode/import
Normal file
7
snippets/python-mode/import
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: import
|
||||
# key: imp
|
||||
# group : general
|
||||
# --
|
||||
import ${1:lib}${2: as ${3:alias}}
|
||||
$0
|
||||
8
snippets/python-mode/init
Normal file
8
snippets/python-mode/init
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: init
|
||||
# key: init
|
||||
# group : definitions
|
||||
# --
|
||||
def __init__(self${1:, args}):
|
||||
${2:"${3:docstring}"
|
||||
}$0
|
||||
10
snippets/python-mode/init_docstring
Normal file
10
snippets/python-mode/init_docstring
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: init_docstring
|
||||
# key: id
|
||||
# group : definitions
|
||||
# --
|
||||
def __init__(self$1):
|
||||
\"\"\"$2
|
||||
${1:$(python-args-to-docstring)}
|
||||
\"\"\"
|
||||
$0
|
||||
11
snippets/python-mode/init_docstring_numpy
Normal file
11
snippets/python-mode/init_docstring_numpy
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: quazgar
|
||||
# name: init_docstring_numpy
|
||||
# key: idn
|
||||
# group : definitions
|
||||
# --
|
||||
def __init__(self$1):
|
||||
\"\"\"$2
|
||||
${1:$(python-args-to-docstring-numpy)}
|
||||
\"\"\"
|
||||
$0
|
||||
5
snippets/python-mode/interact
Normal file
5
snippets/python-mode/interact
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: interact
|
||||
# key: int
|
||||
# --
|
||||
import code; code.interact(local=locals())
|
||||
6
snippets/python-mode/ipdb
Normal file
6
snippets/python-mode/ipdb
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet; require-final-newline: nil -*-
|
||||
# name: ipdb trace
|
||||
# key: ipdb
|
||||
# group: debug
|
||||
# --
|
||||
import ipdb; ipdb.set_trace()
|
||||
7
snippets/python-mode/iter
Normal file
7
snippets/python-mode/iter
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __iter__
|
||||
# key: iter
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __iter__(self):
|
||||
return ${1:iter($2)}
|
||||
5
snippets/python-mode/lambda
Normal file
5
snippets/python-mode/lambda
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: lambda
|
||||
# key: lam
|
||||
# --
|
||||
lambda ${1:x}: $0
|
||||
7
snippets/python-mode/list
Normal file
7
snippets/python-mode/list
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: list
|
||||
# key: li
|
||||
# group : definitions
|
||||
# --
|
||||
[${1:el} for $1 in ${2:list}]
|
||||
$0
|
||||
5
snippets/python-mode/logger_name
Normal file
5
snippets/python-mode/logger_name
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: logger_name
|
||||
# key: ln
|
||||
# --
|
||||
logger = logging.getLogger(${1:__name__})
|
||||
6
snippets/python-mode/logging
Normal file
6
snippets/python-mode/logging
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: logging
|
||||
# key: log
|
||||
# --
|
||||
logger = logging.getLogger("${1:name}")
|
||||
logger.setLevel(logging.${2:level})
|
||||
6
snippets/python-mode/main
Normal file
6
snippets/python-mode/main
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: main
|
||||
# key: main
|
||||
# --
|
||||
def main():
|
||||
$0
|
||||
6
snippets/python-mode/metaclass
Normal file
6
snippets/python-mode/metaclass
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: metaclass
|
||||
# key: mt
|
||||
# group: object oriented
|
||||
# --
|
||||
__metaclass__ = ${1:type}
|
||||
7
snippets/python-mode/method
Normal file
7
snippets/python-mode/method
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: method
|
||||
# key: m
|
||||
# group: object oriented
|
||||
# --
|
||||
def ${1:method}(self${2:, $3}):
|
||||
$0
|
||||
10
snippets/python-mode/method_docstring
Normal file
10
snippets/python-mode/method_docstring
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: method_docstring
|
||||
# key: md
|
||||
# group: object oriented
|
||||
# --
|
||||
def ${1:name}(self$2):
|
||||
\"\"\"$3
|
||||
${2:$(python-args-to-docstring)}
|
||||
\"\"\"
|
||||
$0
|
||||
11
snippets/python-mode/method_docstring_numpy
Normal file
11
snippets/python-mode/method_docstring_numpy
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: quazgar
|
||||
# name: method_docstring_numpy
|
||||
# key: mdn
|
||||
# group: object oriented
|
||||
# --
|
||||
def ${1:name}(self$2):
|
||||
\"\"\"$3
|
||||
${2:$(python-args-to-docstring-numpy)}
|
||||
\"\"\"
|
||||
$0
|
||||
5
snippets/python-mode/not_impl
Normal file
5
snippets/python-mode/not_impl
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: not_impl
|
||||
# key: not_impl
|
||||
# --
|
||||
raise NotImplementedError
|
||||
7
snippets/python-mode/np
Normal file
7
snippets/python-mode/np
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: np
|
||||
# key: np
|
||||
# group : general
|
||||
# --
|
||||
import numpy as np
|
||||
$0
|
||||
9
snippets/python-mode/parse_args
Normal file
9
snippets/python-mode/parse_args
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: parse_args
|
||||
# key: pargs
|
||||
# group: argparser
|
||||
# --
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(description='$1')
|
||||
$0
|
||||
return parser.parse_args()
|
||||
7
snippets/python-mode/parser
Normal file
7
snippets/python-mode/parser
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: parser
|
||||
# key: pars
|
||||
# group: argparser
|
||||
# --
|
||||
parser = argparse.ArgumentParser(description='$1')
|
||||
$0
|
||||
5
snippets/python-mode/pass
Normal file
5
snippets/python-mode/pass
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: pass
|
||||
# key: ps
|
||||
# --
|
||||
pass
|
||||
6
snippets/python-mode/pdb
Normal file
6
snippets/python-mode/pdb
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet; require-final-newline: nil -*-
|
||||
# name: pdb trace
|
||||
# key: pdb
|
||||
# group: debug
|
||||
# --
|
||||
import pdb; pdb.set_trace()
|
||||
7
snippets/python-mode/pl
Normal file
7
snippets/python-mode/pl
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Import pyplot
|
||||
# key: plt
|
||||
# group : general
|
||||
# --
|
||||
import matplotlib.pyplot as plt
|
||||
$0
|
||||
5
snippets/python-mode/print
Normal file
5
snippets/python-mode/print
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: print
|
||||
# key: p
|
||||
# --
|
||||
print($0)
|
||||
18
snippets/python-mode/prop
Normal file
18
snippets/python-mode/prop
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Mads D. Kristensen <madsdk@gmail.com>
|
||||
# name: prop
|
||||
# --
|
||||
def ${1:foo}():
|
||||
doc = """${2:Doc string}"""
|
||||
def fget(self):
|
||||
return self._$1
|
||||
|
||||
def fset(self, value):
|
||||
self._$1 = value
|
||||
|
||||
def fdel(self):
|
||||
del self._$1
|
||||
return locals()
|
||||
$1 = property(**$1())
|
||||
|
||||
$0
|
||||
6
snippets/python-mode/pudb
Normal file
6
snippets/python-mode/pudb
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet; require-final-newline: nil -*-
|
||||
# name: pudb trace
|
||||
# key: pudb
|
||||
# group: debug
|
||||
# --
|
||||
import pudb; pudb.set_trace()
|
||||
7
snippets/python-mode/reg
Normal file
7
snippets/python-mode/reg
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: reg
|
||||
# key: reg
|
||||
# group : general
|
||||
# --
|
||||
${1:regexp} = re.compile(r"${2:expr}")
|
||||
$0
|
||||
7
snippets/python-mode/repr
Normal file
7
snippets/python-mode/repr
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __repr__
|
||||
# key: repr
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __repr__(self):
|
||||
$0
|
||||
5
snippets/python-mode/return
Normal file
5
snippets/python-mode/return
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: return
|
||||
# key: r
|
||||
# --
|
||||
return $0
|
||||
7
snippets/python-mode/scls
Normal file
7
snippets/python-mode/scls
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: subclass
|
||||
# key: scls
|
||||
# group: object oriented
|
||||
# --
|
||||
class ${1:class}(${2:super-class}):
|
||||
$0
|
||||
11
snippets/python-mode/script
Normal file
11
snippets/python-mode/script
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: script
|
||||
# key: script
|
||||
# --
|
||||
#!/usr/bin/env python
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
6
snippets/python-mode/self
Normal file
6
snippets/python-mode/self
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: self
|
||||
# key: .
|
||||
# group: object oriented
|
||||
# --
|
||||
self.$0
|
||||
6
snippets/python-mode/self_without_dot
Normal file
6
snippets/python-mode/self_without_dot
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: self_without_dot
|
||||
# key: s
|
||||
# group: object oriented
|
||||
# --
|
||||
self
|
||||
6
snippets/python-mode/selfassign
Normal file
6
snippets/python-mode/selfassign
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: selfassign
|
||||
# key: sn
|
||||
# group: object oriented
|
||||
# --
|
||||
self.$1 = $1
|
||||
5
snippets/python-mode/setdef
Normal file
5
snippets/python-mode/setdef
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: setdef
|
||||
# key: setdef
|
||||
# --
|
||||
${1:var}.setdefault(${2:key}, []).append(${3:value})
|
||||
14
snippets/python-mode/setup
Normal file
14
snippets/python-mode/setup
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: setup
|
||||
# key: setup
|
||||
# group: distribute
|
||||
# --
|
||||
from setuptools import setup
|
||||
|
||||
package = '${1:name}'
|
||||
version = '${2:0.1}'
|
||||
|
||||
setup(name=package,
|
||||
version=version,
|
||||
description="${3:description}",
|
||||
url='${4:url}'$0)
|
||||
5
snippets/python-mode/size
Normal file
5
snippets/python-mode/size
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: size
|
||||
# key: size
|
||||
# --
|
||||
sys.getsizeof($0)
|
||||
6
snippets/python-mode/static
Normal file
6
snippets/python-mode/static
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: static
|
||||
# key: sm
|
||||
# --
|
||||
@staticmethod
|
||||
def ${1:func}($0):
|
||||
7
snippets/python-mode/str
Normal file
7
snippets/python-mode/str
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __str__
|
||||
# key: str
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __str__(self):
|
||||
$0
|
||||
7
snippets/python-mode/super
Normal file
7
snippets/python-mode/super
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: super
|
||||
# key: super
|
||||
# group: object oriented
|
||||
# --
|
||||
super(`(replace-regexp-in-string "\\([.]\\)[^.]+$" ", self)." (python-info-current-defun) nil nil 1)`($1)
|
||||
$0
|
||||
7
snippets/python-mode/test_class
Normal file
7
snippets/python-mode/test_class
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: test_class
|
||||
# key: tcs
|
||||
# group : testing
|
||||
# --
|
||||
class Test${1:toTest}(${2:unittest.TestCase}):
|
||||
$0
|
||||
12
snippets/python-mode/test_file
Normal file
12
snippets/python-mode/test_file
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: test_file
|
||||
# key: tf
|
||||
# group : testing
|
||||
# --
|
||||
import unittest
|
||||
${1:from ${2:test_file} import *}
|
||||
|
||||
$0
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
8
snippets/python-mode/try
Normal file
8
snippets/python-mode/try
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: try
|
||||
# key: try
|
||||
# --
|
||||
try:
|
||||
$0
|
||||
except ${1:Exception}:
|
||||
$2
|
||||
10
snippets/python-mode/tryelse
Normal file
10
snippets/python-mode/tryelse
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: tryelse
|
||||
# key: try
|
||||
# --
|
||||
try:
|
||||
$0
|
||||
except $1:
|
||||
$2
|
||||
else:
|
||||
$3
|
||||
7
snippets/python-mode/unicode
Normal file
7
snippets/python-mode/unicode
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: __unicode__
|
||||
# key: un
|
||||
# group: dunder methods
|
||||
# --
|
||||
def __unicode__(self):
|
||||
$0
|
||||
6
snippets/python-mode/unicode_literals
Normal file
6
snippets/python-mode/unicode_literals
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: unicode_literals
|
||||
# key: fu
|
||||
# group: future
|
||||
# --
|
||||
from __future__ import unicode_literals
|
||||
5
snippets/python-mode/utf8
Normal file
5
snippets/python-mode/utf8
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: utf-8 encoding
|
||||
# key: utf8
|
||||
# --
|
||||
# -*- coding: utf-8 -*-
|
||||
7
snippets/python-mode/while
Normal file
7
snippets/python-mode/while
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: while
|
||||
# key: wh
|
||||
# group: control structure
|
||||
# --
|
||||
while ${1:True}:
|
||||
$0
|
||||
7
snippets/python-mode/with
Normal file
7
snippets/python-mode/with
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: with
|
||||
# key: with
|
||||
# group : control structure
|
||||
# --
|
||||
with ${1:expr}${2: as ${3:alias}}:
|
||||
$0
|
||||
6
snippets/python-mode/with_statement
Normal file
6
snippets/python-mode/with_statement
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: with_statement
|
||||
# key: fw
|
||||
# group: future
|
||||
# --
|
||||
from __future__ import with_statement
|
||||
Reference in New Issue
Block a user