Commits

Alain Leufroy committed e8aa832

[snippets,python] add snippets for python-mode

Comments (0)

Files changed (37)

snippets/python-mode/class

+# -*- coding: utf-8 -*-
+# name: class
+# contributor: Orestis Markou
+# contributor: Nishio Hirokazu
+# contributor: Yasser González Fernández <yglez@uh.cu>
+# key: class
+# --
+class ${1:ClassName}(${2:object}):
+    """$3
+    """
+
+    def __init__(self, $4):
+        """$5
+        ${4:$
+        (let* ((indent
+                (concat "\n" (make-string (current-column) 32)))
+               (args
+                (mapconcat
+                 '(lambda (x)
+                    (if (not (string= (nth 0 x) ""))
+                        (concat "- " (char-to-string 96) (nth 0 x)
+                                (char-to-string 96) ":")))
+                 (mapcar
+                  '(lambda (x)
+                     (mapcar
+                      (lambda (x)
+                        (replace-regexp-in-string "[[:blank:]]*$" ""
+                         (replace-regexp-in-string "^[[:blank:]]*" "" x))) x))
+                  (mapcar '(lambda (x) (split-string x "="))
+                          (split-string text ",")))
+                 indent)))
+          (if (string= args "")
+              (make-string 3 34)
+            (mapconcat
+             'identity
+             (list "" "Arguments:" args (make-string 3 34))
+             indent)))
+        }
+        ${4:$
+        (mapconcat
+         '(lambda (x)
+            (if (not (string= (nth 0 x) ""))
+                (concat "self._" (nth 0 x) " = " (nth 0 x))))
+         (mapcar
+          '(lambda (x)
+             (mapcar
+              '(lambda (x)
+                 (replace-regexp-in-string "[[:blank:]]*$" ""
+                  (replace-regexp-in-string "^[[:blank:]]*" "" x)))
+              x))
+          (mapcar '(lambda (x) (split-string x "="))
+                  (split-string text ",")))
+         (concat "\n" (make-string (current-column) 32)))
+        }
+        $0

snippets/python-mode/coding

+# -*- coding: utf-8 -*-
+# name: coding
+# contributor: jr
+# key: coding
+# --
+# -*- coding: utf-8 -*-
+

snippets/python-mode/def

+# -*- coding: utf-8 -*-
+# name: def
+# contributor: Orestis Markou
+# contributor: Yasser González Fernández <yglez@uh.cu>
+# key: def
+# --
+def ${1:name}($2):
+    """$3
+    ${2:$
+      (let*
+        ((indent
+            (concat "\n" (make-string (current-column) 32)))
+           (args
+            (mapconcat
+             '(lambda (x)
+                (if (not (string= (nth 0 x) ""))
+                    (concat "   " (char-to-string 96) (nth 0 x)
+                            (char-to-string 96) ":")))
+             (mapcar
+              '(lambda (x)
+                 (mapcar
+                  '(lambda (x)
+                     (replace-regexp-in-string "[[:blank:]]*$" ""
+                      (replace-regexp-in-string "^[[:blank:]]*" "" x)))
+                  x))
+              (mapcar '(lambda (x) (split-string x "="))
+                      (split-string text ",")))
+             indent)))
+      (if (string= args "")
+          (make-string 3 34)
+        (mapconcat
+         'identity
+         (list "" ":Arguments:" args (make-string 3 34))
+         indent)))
+    }
+    $0

snippets/python-mode/def.bak

+# -*- coding: utf-8 -*-
+# name: def
+# contributor: Orestis Markou
+# contributor: Yasser González Fernández <yglez@uh.cu>
+# key: def
+# --
+def ${1:name}($2):
+    """$3
+    ${2:$
+      (let* 
+        ((indent
+            (concat "\n" (make-string (current-column) 32)))
+           (args
+            (mapconcat
+             '(lambda (x)
+                (if (not (string= (nth 0 x) ""))
+                    (concat "- " (char-to-string 96) (nth 0 x)
+                            (char-to-string 96) ":")))
+             (mapcar
+              '(lambda (x)
+                 (mapcar
+                  '(lambda (x)
+                     (replace-regexp-in-string "[[:blank:]]*$" ""
+                      (replace-regexp-in-string "^[[:blank:]]*" "" x)))
+                  x))
+              (mapcar '(lambda (x) (split-string x "="))
+                      (split-string text ",")))
+             indent)))
+      (if (string= args "")
+          (make-string 3 34)
+        (mapconcat
+         'identity
+         (list "" "Arguments:" args (make-string 3 34))
+         indent)))
+    }
+    $0

snippets/python-mode/defm

+# -*- coding: utf-8 -*-
+# name: defm
+# contributor: Yasser Gonz¨¢lez Fern¨¢ndez <yglez@uh.cu>
+# key: defm
+# --
+def ${1:name}(self, $2):
+    """$3
+    ${2:$
+    (let* ((indent
+            (concat "\n" (make-string (current-column) 32)))
+           (args
+            (mapconcat
+             '(lambda (x)
+                (if (not (string= (nth 0 x) ""))
+                    (concat "- " (char-to-string 96) (nth 0 x)
+                            (char-to-string 96) ":")))
+             (mapcar
+              '(lambda (x)
+                 (mapcar
+                  '(lambda (x)
+                     (replace-regexp-in-string "[[:blank:]]*$" ""
+                      (replace-regexp-in-string "^[[:blank:]]*" "" x)))
+                  x))
+              (mapcar '(lambda (x) (split-string x "="))
+                      (split-string text ",")))
+             indent)))
+      (if (string= args "")
+          (make-string 3 34)
+        (mapconcat
+         'identity
+         (list "" "Arguments:" args (make-string 3 34))
+         indent)))
+    }
+    $0

snippets/python-mode/defm.test

+# -*- coding: utf-8 -*-
+# name: defm
+# contributor: Yasser Gonz¨¢lez Fern¨¢ndez <yglez@uh.cu>
+# key: defm
+# --
+def ${1:name}(self, $2):
+    """$3
+    ${2:$
+    (let* ((indent
+            (concat "\n" (make-string (current-column) 32)))
+           (args
+            (mapconcat
+             '(lambda (x)
+                (if (not (string= (nth 0 x) ""))
+                    (concat "   " (char-to-string 96) (nth 0 x)
+                            (char-to-string 96) ":")))
+             (mapcar
+              '(lambda (x)
+                 (mapcar
+                  '(lambda (x)
+                     (replace-regexp-in-string "[[:blank:]]*$" ""
+                      (replace-regexp-in-string "^[[:blank:]]*" "" x)))
+                  x))
+              (mapcar '(lambda (x) (split-string x "="))
+                      (split-string text ",")))
+             indent)))
+      (if (string= args "")
+          (make-string 3 34)
+        (mapconcat
+         'identity
+         (list "" ":Arguments:" args (make-string 3 34))
+         indent)))
+    }
+    $0

snippets/python-mode/doc

+# -*- coding: utf-8 -*-
+# name: doc
+# contributor: Gabriele Lanaro <gabriele.lanaro@gmail.com>
+# expand-env ((yas/indent-line 'fixed)
+# --
+"""$0
+"""

snippets/python-mode/feature-mode/feature

+# -*- mode: snippet -*-
+# name: feature
+# key: ft
+# --
+Feature: $1
+
+  sc$0

snippets/python-mode/feature-mode/scenario

+# -*- mode: snippet -*-
+# name: scenario
+# key: sc
+# --
+Scenario: $1
+  Given $0
+  When
+  Then

snippets/python-mode/for

+# name: for ... in ... : ...
+# key: for
+# --
+for ${var} in ${collection}:
+    $0

snippets/python-mode/from

+#name : from ... import ...
+# --
+from $1 import $2
+$0

snippets/python-mode/gpl

+# -*- coding: utf-8 -*-
+# name: gpl
+# contributor: jr
+# key: gpl
+# --
+# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+

snippets/python-mode/hashbang

+# -*- coding: utf-8 -*-
+# name: #!
+# contributor: jr
+# key: !!
+# --
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+

snippets/python-mode/hdr

+# -*- coding: utf-8 -*-
+# name: hdr
+# contributor: jr
+# key: hdr
+# --
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os.path as osp
+import sys
+import numpy as np
+
+
+
+
+if __name__ == '__main__':
+    pass
+
+# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
+# vim: set ft=python sts=4 ts=4 sw=4 textwidth=79 et:

snippets/python-mode/ifmain

+# name: if __name__ == '__main__': ...
+# key: ifmain
+# --
+if __name__ == '__main__':
+    $0

snippets/python-mode/init

+# -*- coding: utf-8 -*-
+# name: init
+# contributor: Gabriele Lanaro <gabriele.lanaro@gmail.com>
+# --
+def __init__(self$1):
+    $0

snippets/python-mode/ipdb

+#contributor : matt harrison 
+#pdb : import pdb; pdb.set_trace()
+# --
+import ipdb; ipdb.set_trace()

snippets/python-mode/param

+# -*- mode: snippet -*-
+# name: param
+# key: param
+# condition: 'force-in-comment
+# --
+:param $1: $0

snippets/python-mode/pdb

+#contributor : matt harrison 
+#pdb : import pdb; pdb.set_trace()
+# --
+import pdb; pdb.set_trace()

snippets/python-mode/php-mode/fun

+# -*- mode: snippet -*-
+# name: fun
+# key: fun
+# --
+public function ${1:name}($2) {
+  $0
+}

snippets/python-mode/php-mode/funs

+# -*- mode: snippet -*-
+# name: funs
+# key: funs
+# --
+public static function ${1:name}($2) {
+  $0
+}

snippets/python-mode/php-mode/private-function

+# -*- mode: snippet -*-
+# name: private-function
+# key: pri
+# --
+private function ${1:name}($2) {
+        $0
+}

snippets/python-mode/php-mode/public-function

+# -*- mode: snippet -*-
+# name: public function
+# key: f
+# --
+public function ${1:name}($2) {
+       $0
+}

snippets/python-mode/php-mode/req

+# -*- mode: snippet -*-
+# name: req
+# key: req
+# --
+require_once(dirname(__FILE__) . "/$1.php");$0

snippets/python-mode/prop

+# contributor: Mads D. Kristensen <madsdk@gmail.com>
+# name: prop
+# key: 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

snippets/python-mode/prop.fun

+# contributor: Mads D. Kristensen <madsdk@gmail.com>
+# name: prop
+# desc: property with fget/fset/fdel
+# expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil))
+# --
+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

snippets/python-mode/propg

+# contributor: Julio Carlos Menendez <godinblack@gmail.com>
+# name: _get_foo ... foo=property(...)
+# key: propg
+# --
+def _get_${1:foo}(self):
+    return self._$1
+
+$1 = property(_get_$1)
+
+$0

snippets/python-mode/propsg

+# contributor: Julio Carlos Menendez <godinblack@gmail.com>
+# name: _get_foo ... _set_foo ... foo=property(...)
+# key: propsg
+# --
+def _set_${1:foo}(self, value):
+    self._$1 = value
+
+def _get_$1(self):
+    return self._$1
+
+$1 = property(_get_$1, _set_$1)
+
+$0

snippets/python-mode/rev

+# -*- coding: utf-8 -*-
+# name: rev
+# contributor: jr
+# key: rev
+# --
+__revision__ = "$Revision: JR $`(current-time-string)`"
+

snippets/python-mode/super

+# -*- coding: utf-8 -*-
+# name: super
+# contributor: Gabriele Lanaro <gabriele.lanaro@gmail.com>
+# --
+super(${1:`(prev-class-name)`},self).${2:`(prev-def-name)`}(${3:`(prev-def-args)`})
+    $0

snippets/python-mode/testcase

+# -*- coding: utf-8 -*-
+# name: unittest.TestCase normal
+# contributor: Gabriele Lanaro
+# --
+class ${1:TestCase}(${2:unittest.TestCase}):
+    $0

snippets/python-mode/try.except

+# This was cloned from a TextMate bundle for yasnippet.
+# --
+try:
+	${1:pass}
+except ${2:Exception}, ${3:e}:
+	${4:raise $3}

snippets/python-mode/try.exceptelse

+# This was cloned from a TextMate bundle for yasnippet.
+# --
+try:
+	${1:pass}
+except ${2:Exception}, ${3:e}:
+	${4:raise $3}
+else:
+	${5:pass}

snippets/python-mode/try.exceptelsefinally

+# This was cloned from a TextMate bundle for yasnippet.
+# --
+try:
+	${1:pass}
+except ${2:Exception}, ${3:e}}:
+	${4:raise}
+else:
+	${5:pass}
+finally:
+	${6:pass}

snippets/python-mode/try.exceptfinally

+# This was cloned from a TextMate bundle for yasnippet.
+# --
+try:
+	${1:pass}
+except ${2:Exception}, ${3:e}:
+	${4:raise $3}
+finally:
+	${5:pass}

snippets/python-mode/utf8

+# contributor: Fidel Ramos (haplo)
+# --
+# -*- coding: utf-8 -*-

snippets/python-mode/while

+# name: while ... : ...
+# key: while
+# --
+while ${condition}:
+    $0