112 lines
2.2 KiB
Plaintext
112 lines
2.2 KiB
Plaintext
###########################################################################
|
|
# TEXTMATE SNIPPETS #
|
|
###########################################################################
|
|
snippet ifmain "ifmain"
|
|
if __name__ == '__main__':
|
|
${1:main()}$0
|
|
endsnippet
|
|
|
|
##########
|
|
# COMMON #
|
|
##########
|
|
snippet class
|
|
class ${1:MyClass}(${2:object}):
|
|
"""${3:Docstring for $1}"""
|
|
|
|
def __init__( self${4/([^,])?(.*)/(?1:, )/}${4:arg} ):
|
|
"""
|
|
TODO: Fill me in
|
|
${4/.+/(?0:\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2: $2 - describe me here\n)/g} """
|
|
${2/object$|(.+)/(?1: $0.__init__\(self\)\n\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2: self._$2 = $2\n)/g}
|
|
endsnippet
|
|
|
|
snippet .
|
|
self.
|
|
endsnippet
|
|
|
|
snippet from
|
|
from ${1:module} import ${2:Stuff}
|
|
endsnippet
|
|
|
|
##############
|
|
# PROPERTIES #
|
|
##############
|
|
snippet roprop
|
|
@property
|
|
def ${1:property}(self):
|
|
${2:return self._$1}$0
|
|
endsnippet
|
|
|
|
snippet rwprop
|
|
def ${1:property}(self):
|
|
${2/.+/(?0:""")/}${2:The RW property $1}${2/.+/(?0:"""\n )/}def fget(self):
|
|
return self._$1$0
|
|
def fset(self, value):
|
|
self._$1 = value
|
|
return locals()
|
|
$1 = property($1)
|
|
endsnippet
|
|
|
|
##########################
|
|
# Try / Except / Finally #
|
|
##########################
|
|
snippet try "Try / Except"
|
|
try:
|
|
${1:pass}
|
|
except ${2:Exception}, ${3:e}:
|
|
${4:raise $3}
|
|
endsnippet
|
|
|
|
snippet try "Try / Except / Else"
|
|
try:
|
|
${1:pass}
|
|
except ${2:Exception}, ${3:e}:
|
|
${4:raise $3}
|
|
else:
|
|
${5:pass}
|
|
endsnippet
|
|
|
|
snippet try "Try / Except / Finally"
|
|
try:
|
|
${1:pass}
|
|
except ${2:Exception}, ${3:e}:
|
|
${4:raise $3}
|
|
else:
|
|
${5:pass}
|
|
endsnippet
|
|
|
|
snippet try "Try / Except / Else / Finally"
|
|
try:
|
|
${1:pass}
|
|
except${2: ${3:Exception}, ${4:e}}:
|
|
${5:raise}
|
|
else:
|
|
${6:pass}
|
|
finally:
|
|
${7:pass}
|
|
endsnippet
|
|
|
|
##############
|
|
# Assertions #
|
|
##############
|
|
snippet ae
|
|
self.assertEqual(${1:first},${2:second})
|
|
endsnippet
|
|
|
|
snippet at
|
|
self.assertTrue(${0:exp})
|
|
endsnippet
|
|
|
|
snippet af
|
|
self.assertFalse(${1:expression})
|
|
endsnippet
|
|
|
|
snippet aae
|
|
self.assertAlmostEqual(${1:first},${2:second})
|
|
endsnippet
|
|
|
|
snippet ar
|
|
self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments})
|
|
endsnippet
|
|
|