Publish some Sublime Text snippets.
This commit is contained in:
parent
007b4a6e62
commit
0dbc0728c0
7 changed files with 146 additions and 0 deletions
30
SublimeSnippets/argparse.sublime-snippet
Normal file
30
SublimeSnippets/argparse.sublime-snippet
Normal file
|
@ -0,0 +1,30 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
def $1_argparse(args):
|
||||
print(args)
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
|
||||
parser.add_argument('required_positional')
|
||||
parser.add_argument('optional_positional', nargs='?', default=None)
|
||||
parser.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
||||
parser.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
||||
parser.set_defaults(func=$1_argparse)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args.func(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
||||
]]></content>
|
||||
<tabTrigger>argparse</tabTrigger>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
32
SublimeSnippets/argparse_multi.sublime-snippet
Normal file
32
SublimeSnippets/argparse_multi.sublime-snippet
Normal file
|
@ -0,0 +1,32 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
def $1_argparse(args):
|
||||
print(args)
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
p_example = subparsers.add_parser('example1')
|
||||
p_example.add_argument('required_positional')
|
||||
p_example.add_argument('optional_positional', nargs='?', default=None)
|
||||
p_example.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
||||
p_example.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
||||
p_example.set_defaults(func=$1_argparse)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args.func(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
||||
]]></content>
|
||||
<tabTrigger>argparse_multi</tabTrigger>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
15
SublimeSnippets/defmain.sublime-snippet
Normal file
15
SublimeSnippets/defmain.sublime-snippet
Normal file
|
@ -0,0 +1,15 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
def main(argv):
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
||||
]]></content>
|
||||
<tabTrigger>defmain</tabTrigger>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
12
SublimeSnippets/ifmain.sublime-snippet
Normal file
12
SublimeSnippets/ifmain.sublime-snippet
Normal file
|
@ -0,0 +1,12 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
||||
]]></content>
|
||||
<tabTrigger>ifmain</tabTrigger>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
14
SublimeSnippets/listget.sublime-snippet
Normal file
14
SublimeSnippets/listget.sublime-snippet
Normal file
|
@ -0,0 +1,14 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
def listget(l, index, default=None):
|
||||
try:
|
||||
return l[index]
|
||||
except IndexError:
|
||||
return default
|
||||
]]></content>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
<tabTrigger>listget</tabTrigger>
|
||||
</snippet>
|
11
SublimeSnippets/ni=raise_notimplemented.sublime-snippet
Normal file
11
SublimeSnippets/ni=raise_notimplemented.sublime-snippet
Normal file
|
@ -0,0 +1,11 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
raise NotImplementedError
|
||||
]]></content>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
<tabTrigger>ni</tabTrigger>
|
||||
<description>raise NotImplementedError</description>
|
||||
</snippet>
|
32
SublimeSnippets/webpage.sublime-snippet
Normal file
32
SublimeSnippets/webpage.sublime-snippet
Normal file
|
@ -0,0 +1,32 @@
|
|||
<snippet>
|
||||
<content><![CDATA[
|
||||
<!DOCTYPE html5>
|
||||
<html>
|
||||
<head>
|
||||
{% import "header.html" as header %}
|
||||
<title>Title</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link rel="stylesheet" href="/static/common.css">
|
||||
<script src="/static/common.js"></script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
</body>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
</html>
|
||||
|
||||
]]></content>
|
||||
<tabTrigger>webpage</tabTrigger>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<!-- <tabTrigger>hello</tabTrigger> -->
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
Loading…
Reference in a new issue