2009-07-04 10:13:51 -04:00
|
|
|
###########################################################################
|
|
|
|
# MY OWN SNIPPETS #
|
|
|
|
###########################################################################
|
2009-07-04 10:08:14 -04:00
|
|
|
snippet db
|
|
|
|
debug("${1/(\w+)(, *)?/$1: %s(?2:, )/g}" % (${1:args}))
|
|
|
|
$0
|
2009-07-04 06:15:12 -04:00
|
|
|
endsnippet
|
2009-07-04 10:08:14 -04:00
|
|
|
|
2009-07-04 11:36:06 -04:00
|
|
|
snippet print
|
|
|
|
debug("$1")
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
2009-07-04 10:13:51 -04:00
|
|
|
###########################################################################
|
|
|
|
# TEXTMATE SNIPPETS #
|
|
|
|
###########################################################################
|
|
|
|
snippet ifmain "ifmain"
|
|
|
|
if __name__ == '__main__':
|
2009-07-04 11:36:06 -04:00
|
|
|
${1:main()}$0
|
2009-07-04 10:13:51 -04:00
|
|
|
endsnippet
|
|
|
|
|
2009-07-04 17:32:37 -04:00
|
|
|
##########
|
|
|
|
# COMMON #
|
|
|
|
##########
|
|
|
|
snippet class
|
|
|
|
class ${1:MyClass}(${2:object}):
|
|
|
|
"""${3:Docstring for $1}"""
|
|
|
|
|
|
|
|
def __init__( self${4/([^,])?(.*)/(?1:, )/}${4:arg} ):
|
|
|
|
"""
|
|
|
|
TODO: Fill me in
|
|
|
|
"""
|
|
|
|
${2/object$|(.+)/(?1:\t\t$0.__init__\(self\))/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2:\t\tself._$2 = $2\n)/g} $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet .
|
|
|
|
self.
|
|
|
|
endsnippet
|
2009-07-04 17:01:23 -04:00
|
|
|
|
2009-07-04 10:13:51 -04:00
|
|
|
##########################
|
|
|
|
# Try / Except / Finally #
|
|
|
|
##########################
|
|
|
|
snippet try "Try / Except"
|
|
|
|
try:
|
2009-07-04 11:36:06 -04:00
|
|
|
${1:pass}
|
2009-07-04 10:13:51 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
2009-07-04 11:36:06 -04:00
|
|
|
${4:raise $3}
|
2009-07-04 10:13:51 -04:00
|
|
|
endsnippet
|
|
|
|
|
2009-07-04 15:58:13 -04:00
|
|
|
snippet try "Try / Except / Else"
|
|
|
|
try:
|
2009-07-04 17:32:37 -04:00
|
|
|
${1:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
2009-07-04 17:32:37 -04:00
|
|
|
${4:raise $3}
|
2009-07-04 15:58:13 -04:00
|
|
|
else:
|
2009-07-04 17:32:37 -04:00
|
|
|
${5:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet try "Try / Except / Finally"
|
|
|
|
try:
|
2009-07-04 17:32:37 -04:00
|
|
|
${1:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
2009-07-04 17:32:37 -04:00
|
|
|
${4:raise $3}
|
2009-07-04 15:58:13 -04:00
|
|
|
else:
|
2009-07-04 17:32:37 -04:00
|
|
|
${5:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet try "Try / Except / Else / Finally"
|
|
|
|
try:
|
2009-07-04 17:32:37 -04:00
|
|
|
${1:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
except${2: ${3:Exception}, ${4:e}}:
|
2009-07-04 17:32:37 -04:00
|
|
|
${5:raise}
|
2009-07-04 15:58:13 -04:00
|
|
|
else:
|
2009-07-04 17:32:37 -04:00
|
|
|
${6:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
finally:
|
2009-07-04 17:32:37 -04:00
|
|
|
${7:pass}
|
2009-07-04 15:58:13 -04:00
|
|
|
endsnippet
|
|
|
|
|
2009-07-04 17:01:23 -04:00
|
|
|
##############
|
|
|
|
# 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
|
|
|
|
|