From f2009bd7245739447ada07581edf7dd8e01c1969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= Date: Wed, 3 Jul 2013 18:45:28 +0200 Subject: [PATCH] fix property and slotted class python snippets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • `rwprop` did not work at all for me (messed up expansion) and did not honor `ultisnips_python_quoting_style`. • slotclass assigns to variables beginning with an underscore in its init function and thus the slots have to begin with an underscore too. --- UltiSnips/python.snippets | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 1d3b767..cf2302f 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -102,7 +102,7 @@ def write_init_body(args, parents, snip): def write_slots_args(args, snip): - args = ['"%s"' % arg for arg in args] + args = ['"_%s"' % arg for arg in args] snip += '__slots__ = (%s,)' % ', '.join(args) endglobal @@ -376,23 +376,25 @@ endsnippet ############## snippet roprop "Read Only Property" b @property -def ${1:property}(self): +def ${1:name}(self): ${2:return self._$1}$0 endsnippet snippet rwprop "Read write property" b -def ${1:property}(): - ${2/.+/(?0:`!p snip.rv = tripple_quotes(snip)`)/}${2:The RW property $1}`!p if t[2]: - snip.rv += '"""' - snip >> 1 - snip += "" +def ${1:name}(): + `!p snip.rv = tripple_quotes(snip) if t[2] else '' +`${2:@todo: Docstring for $1}`!p +if t[2]: + snip.rv = tripple_quotes(snip) + snip >> 1 + snip += "" else: - snip.rv = ""`def fget(self): + snip.rv = ""`def fget(self): return self._$1$0 def fset(self, value): self._$1 = value return locals() -$1 = property(**$1()) +$1 = property(**$1(), doc=$1.__doc__) endsnippet