|
1 | 1 | { |
2 | | -"#!/usr/bin/env python": { |
3 | | -"prefix":"env", |
4 | | -"body":"#!/usr/bin/env python\n$0", |
5 | | -"description" :"Adds shebang line for default python interpreter." |
6 | | - }, |
7 | | -"#!/usr/bin/env python3": { |
8 | | -"prefix":"env3", |
9 | | -"body":"#!/usr/bin/env python3\n$0", |
10 | | -"description" :"Adds shebang line for default python 3 interpreter." |
11 | | - }, |
12 | | -"# -*- coding=utf-8 -*-": { |
13 | | -"prefix":"enc", |
14 | | -"body":"# -*- coding=utf-8 -*-\n$0", |
15 | | -"description" :"set default python2.x encoding specification to utf-8 as it is mentioned in pep-0263." |
16 | | - }, |
17 | | -"# coding=utf-8": { |
18 | | -"prefix":"enco", |
19 | | -"body":"# coding=utf-8\n$0", |
20 | | -"description" :"Set default python3 encoding specification to utf-8, by default this is the encoding for python3.x as it is mentioned in pep-3120." |
21 | | - }, |
22 | | -"from future import ...": { |
23 | | -"prefix":"fenc", |
24 | | -"body": [ |
25 | | -"# -*- coding: utf-8 -*-", |
26 | | -"from __future__ import absolute_import, division, print_function, unicode_literals" |
27 | | - ], |
28 | | -"description" :"Import future statement definitions for python2.x scripts using utf-8 as encoding." |
29 | | - }, |
30 | | -"from future import ... v1": { |
31 | | -"prefix":"fenco", |
32 | | -"body": [ |
33 | | -"# coding: utf-8", |
34 | | -"from __future__ import absolute_import, division, print_function, unicode_literals" |
35 | | - ], |
36 | | -"description" :"Import future statement definitions for python3.x scripts using utf-8 as encoding." |
37 | | - }, |
38 | | -"import": { |
39 | | -"prefix":"im", |
40 | | -"body":"import ${1:package/module}$0", |
41 | | -"description" :"Import a package or module" |
42 | | - }, |
43 | | -"from ... import ...": { |
44 | | -"prefix":"fim", |
45 | | -"body":"from ${1:package/module} import ${2:names}$0", |
46 | | -"description" :"Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table." |
47 | | - }, |
48 | | -"New class": { |
49 | | -"prefix":"class", |
50 | | -"body": [ |
51 | | -"class ${1:ClassName}(${2:object}):", |
52 | | -"\t\"\"\"${3:docstring for $1.}\"\"\"", |
53 | | -"\tdef __init__(self, ${4:arg}):", |
54 | | -"\t\t${5:super($1, self).__init__()}", |
55 | | -"\t${4/([^,=]+)(?:=[^,]+)?(,\\s*|)/\tself.$1 = $1${2:+\n\t}/g}", |
56 | | -"\n\t$0" |
57 | | - ], |
58 | | -"description" :"Code snippet for a class definition." |
59 | | - }, |
60 | | -"New dataclass": { |
61 | | -"prefix":"classd", |
62 | | -"body": [ |
63 | | -"from dataclasses import dataclass\n\n", |
64 | | -"@dataclass", |
65 | | -"class ${1:ClassName}(${2:object}):", |
66 | | -"\t\"\"\"${3:Docstring for $1.}\"\"\"", |
67 | | -"\t${4:property}: ${type}", |
68 | | -"\t$0" |
69 | | - ], |
70 | | -"description":"Code snippet for a dataclass definition." |
71 | | - }, |
72 | | -"New method": { |
73 | | -"prefix":"defs", |
74 | | -"body":"def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0", |
75 | | -"description" :"Code snippet for a class method definition." |
76 | | - }, |
77 | | -"New function": { |
78 | | -"prefix":"def", |
79 | | -"body":"def ${1:fname}(${2:arg}):\n\t${3:pass}$0", |
80 | | -"description" :"Code snippet for function definition." |
81 | | - }, |
82 | | -"New async function": { |
83 | | -"prefix":"adef", |
84 | | -"body":"async def ${1:fname}(${2:arg}):\n\t${3:pass}$0", |
85 | | -"description" :"Code snippet for async function definition." |
86 | | - }, |
87 | | -"New property": { |
88 | | -"prefix":"property", |
89 | | -"body":"@property\ndef ${1:foo}(self):\n\"\"\"${2:The $1 property.}\"\"\"\n ${3:return self._$1}\n@${4:$1}.setter\ndef ${5:$1}(self, value):\n ${6:self._$1} = value", |
90 | | -"description":"New property: get and set via decorator" |
91 | | - }, |
92 | | -"New froperty": { |
93 | | -"prefix":"property", |
94 | | -"body":"def ${1:foo}():\n doc =\"${2:The $1 property.}\"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n def fdel(self):\n ${5:del self._$1}\n return locals()\n$1 = property(**$1())$0", |
95 | | -"description" :"" |
96 | | - }, |
97 | | -"New enum": { |
98 | | -"prefix":"enum", |
99 | | -"body": [ |
100 | | -"from enum import Enum\n\n", |
101 | | -"class ${1:MyEnum}(Enum):", |
102 | | -"\t\"\"\"${2:Docstring for $1.}\"\"\"", |
103 | | -"\t${3:FIRST_ENUM} =\"some_value\"", |
104 | | -"\t${4:SECOND_ENUM} =\"some_other_value\"", |
105 | | -"\t$0" |
106 | | - ], |
107 | | -"description":"Code snippet for enum definition." |
108 | | - }, |
109 | | -"if": { |
110 | | -"prefix":"if", |
111 | | -"body":"if ${1:condition}:\n\t${2:pass}$0", |
112 | | -"description" :"Code snippet for the if statement." |
113 | | - }, |
114 | | -"for": { |
115 | | -"prefix":"for", |
116 | | -"body":"for ${1:value} in ${2:iterable}:\n\t${3:pass}$0", |
117 | | -"description" :"Code snippet to create a for loop structure." |
118 | | - }, |
119 | | -"while": { |
120 | | -"prefix":"while", |
121 | | -"body":"while ${1:condition}:\n\t${2:pass}$0", |
122 | | -"description" :"Code snippet to create a while loop structure." |
123 | | - }, |
124 | | -"dowhile": { |
125 | | -"prefix":"dowhile", |
126 | | -"body":"do = True\nwhile do or ${2:condition}:\n\tdo = False\n\t${1:body}$0", |
127 | | -"description" :"Code snippet to create a do-while loop structure." |
128 | | - }, |
129 | | -"try:except:": { |
130 | | -"prefix":"try", |
131 | | -"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0", |
132 | | -"description" :"Code Snippet for a try and except blocks." |
133 | | - }, |
134 | | -"try:except:else:finally": { |
135 | | -"prefix":"tryef", |
136 | | -"body":"try:\n\t${1:pass}\nexcept${2: ${3:Exception} as ${4:e}}:\n\t${5:raise}\nelse:\n\t${6:pass}\nfinally:\n\t${7:pass}$0", |
137 | | -"description" :"Code Snippet for a try/except/finally with else statement." |
138 | | - }, |
139 | | -"try:except:else": { |
140 | | -"prefix":"trye", |
141 | | -"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0", |
142 | | -"description" :"Code Snippet for a try/except with else statement." |
143 | | - }, |
144 | | -"try:except:finally": { |
145 | | -"prefix":"tryf", |
146 | | -"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0", |
147 | | -"description" :"Code Snippet for a try/except/finally." |
148 | | - }, |
149 | | -"self": { |
150 | | -"prefix":"s", |
151 | | -"body":"self.$0", |
152 | | -"description" :"Shortend snippet to reference the self property in an object." |
153 | | - }, |
154 | | -"__magic__": { |
155 | | -"prefix":"__", |
156 | | -"body":"__${1:init}__$0", |
157 | | -"description" :"Code snippet to create magic methods." |
158 | | - }, |
159 | | -"if __name__ ==\"__main__\"": { |
160 | | -"prefix":"ifmain", |
161 | | -"body":"if __name__ ==\"__main__\":\n\t${1:main()}$0", |
162 | | -"description" :"Create implicitly all the code at the top level using the __name__ special variable." |
163 | | - }, |
164 | | -"lambda": { |
165 | | -"prefix":"lam", |
166 | | -"body":"lambda ${1:args}: ${2:expr}", |
167 | | -"description":"Create template for lambda function" |
168 | | - } |
| 2 | +"#!/usr/bin/env python": { |
| 3 | +"prefix":"env", |
| 4 | +"body":"#!/usr/bin/env python\n$0", |
| 5 | +"description":"Adds shebang line for default python interpreter." |
| 6 | + }, |
| 7 | +"#!/usr/bin/env python3": { |
| 8 | +"prefix":"env3", |
| 9 | +"body":"#!/usr/bin/env python3\n$0", |
| 10 | +"description":"Adds shebang line for default python 3 interpreter." |
| 11 | + }, |
| 12 | +"# -*- coding=utf-8 -*-": { |
| 13 | +"prefix":"enc", |
| 14 | +"body":"# -*- coding=utf-8 -*-\n$0", |
| 15 | +"description":"set default python2.x encoding specification to utf-8 as it is mentioned in pep-0263." |
| 16 | + }, |
| 17 | +"# coding=utf-8": { |
| 18 | +"prefix":"enco", |
| 19 | +"body":"# coding=utf-8\n$0", |
| 20 | +"description":"Set default python3 encoding specification to utf-8, by default this is the encoding for python3.x as it is mentioned in pep-3120." |
| 21 | + }, |
| 22 | +"from future import ...": { |
| 23 | +"prefix":"fenc", |
| 24 | +"body": [ |
| 25 | +"# -*- coding: utf-8 -*-", |
| 26 | +"from __future__ import absolute_import, division, print_function, unicode_literals" |
| 27 | + ], |
| 28 | +"description":"Import future statement definitions for python2.x scripts using utf-8 as encoding." |
| 29 | + }, |
| 30 | +"from future import ... v1": { |
| 31 | +"prefix":"fenco", |
| 32 | +"body": [ |
| 33 | +"# coding: utf-8", |
| 34 | +"from __future__ import absolute_import, division, print_function, unicode_literals" |
| 35 | + ], |
| 36 | +"description":"Import future statement definitions for python3.x scripts using utf-8 as encoding." |
| 37 | + }, |
| 38 | +"import": { |
| 39 | +"prefix":"im", |
| 40 | +"body":"import ${1:package/module}$0", |
| 41 | +"description":"Import a package or module" |
| 42 | + }, |
| 43 | +"import as": { |
| 44 | +"prefix":"ima", |
| 45 | +"body":"import ${1:package/module} as ${2:name}$0", |
| 46 | +"description":"Import a renamable package or module" |
| 47 | + }, |
| 48 | +"from ... import ...": { |
| 49 | +"prefix":"fim", |
| 50 | +"body":"from ${1:package/module} import ${2:names}$0", |
| 51 | +"description":"Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table." |
| 52 | + }, |
| 53 | +"fima": { |
| 54 | +"prefix":"fima", |
| 55 | +"body":"from ${1:package/module} import ${2:names} as ${3:name}$0", |
| 56 | +"description":"Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table and be renamed." |
| 57 | + }, |
| 58 | +"New class": { |
| 59 | +"prefix":"class", |
| 60 | +"body": [ |
| 61 | +"class ${1:ClassName}(${2:object}):", |
| 62 | +"\t\"\"\"${3:docstring for $1.}\"\"\"", |
| 63 | +"\tdef __init__(self, ${4:arg}):", |
| 64 | +"\t\t${5:super($1, self).__init__()}", |
| 65 | +"\t${4/([^,=]+)(?:=[^,]+)?(,\\s*|)/\tself.$1 = $1${2:+\n\t}/g}", |
| 66 | +"\n\t$0" |
| 67 | + ], |
| 68 | +"description":"Code snippet for a class definition." |
| 69 | + }, |
| 70 | +"New dataclass": { |
| 71 | +"prefix":"classd", |
| 72 | +"body": [ |
| 73 | +"from dataclasses import dataclass\n\n", |
| 74 | +"@dataclass", |
| 75 | +"class ${1:ClassName}(${2:object}):", |
| 76 | +"\t\"\"\"${3:Docstring for $1.}\"\"\"", |
| 77 | +"\t${4:property}: ${type}", |
| 78 | +"\t$0" |
| 79 | + ], |
| 80 | +"description":"Code snippet for a dataclass definition." |
| 81 | + }, |
| 82 | +"New method": { |
| 83 | +"prefix":"defs", |
| 84 | +"body":"def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0", |
| 85 | +"description":"Code snippet for a class method definition." |
| 86 | + }, |
| 87 | +"New function": { |
| 88 | +"prefix":"def", |
| 89 | +"body":"def ${1:fname}(${2:arg}):\n\t${3:pass}$0", |
| 90 | +"description":"Code snippet for function definition." |
| 91 | + }, |
| 92 | +"New async function": { |
| 93 | +"prefix":"adef", |
| 94 | +"body":"async def ${1:fname}(${2:arg}):\n\t${3:pass}$0", |
| 95 | +"description":"Code snippet for async function definition." |
| 96 | + }, |
| 97 | +"New property": { |
| 98 | +"prefix":"property", |
| 99 | +"body":"@property\ndef ${1:foo}(self):\n\"\"\"${2:The $1 property.}\"\"\"\n ${3:return self._$1}\n@${4:$1}.setter\ndef ${5:$1}(self, value):\n ${6:self._$1} = value", |
| 100 | +"description":"New property: get and set via decorator" |
| 101 | + }, |
| 102 | +"New froperty": { |
| 103 | +"prefix":"property", |
| 104 | +"body":"def ${1:foo}():\n doc =\"${2:The $1 property.}\"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n def fdel(self):\n ${5:del self._$1}\n return locals()\n$1 = property(**$1())$0", |
| 105 | +"description":"" |
| 106 | + }, |
| 107 | +"New enum": { |
| 108 | +"prefix":"enum", |
| 109 | +"body": [ |
| 110 | +"from enum import Enum\n\n", |
| 111 | +"class ${1:MyEnum}(Enum):", |
| 112 | +"\t\"\"\"${2:Docstring for $1.}\"\"\"", |
| 113 | +"\t${3:FIRST_ENUM} =\"some_value\"", |
| 114 | +"\t${4:SECOND_ENUM} =\"some_other_value\"", |
| 115 | +"\t$0" |
| 116 | + ], |
| 117 | +"description":"Code snippet for enum definition." |
| 118 | + }, |
| 119 | +"if": { |
| 120 | +"prefix":"if", |
| 121 | +"body":"if ${1:condition}:\n\t${2:pass}$0", |
| 122 | +"description":"Code snippet for the if statement." |
| 123 | + }, |
| 124 | +"for": { |
| 125 | +"prefix":"for", |
| 126 | +"body":"for ${1:value} in ${2:iterable}:\n\t${3:pass}$0", |
| 127 | +"description":"Code snippet to create a for loop structure." |
| 128 | + }, |
| 129 | +"while": { |
| 130 | +"prefix":"while", |
| 131 | +"body":"while ${1:condition}:\n\t${2:pass}$0", |
| 132 | +"description":"Code snippet to create a while loop structure." |
| 133 | + }, |
| 134 | +"dowhile": { |
| 135 | +"prefix":"dowhile", |
| 136 | +"body":"do = True\nwhile do or ${2:condition}:\n\tdo = False\n\t${1:body}$0", |
| 137 | +"description":"Code snippet to create a do-while loop structure." |
| 138 | + }, |
| 139 | +"try:except:": { |
| 140 | +"prefix":"try", |
| 141 | +"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0", |
| 142 | +"description":"Code Snippet for a try and except blocks." |
| 143 | + }, |
| 144 | +"try:except:else:finally": { |
| 145 | +"prefix":"tryef", |
| 146 | +"body":"try:\n\t${1:pass}\nexcept${2: ${3:Exception} as ${4:e}}:\n\t${5:raise}\nelse:\n\t${6:pass}\nfinally:\n\t${7:pass}$0", |
| 147 | +"description":"Code Snippet for a try/except/finally with else statement." |
| 148 | + }, |
| 149 | +"try:except:else": { |
| 150 | +"prefix":"trye", |
| 151 | +"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0", |
| 152 | +"description":"Code Snippet for a try/except with else statement." |
| 153 | + }, |
| 154 | +"try:except:finally": { |
| 155 | +"prefix":"tryf", |
| 156 | +"body":"try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0", |
| 157 | +"description":"Code Snippet for a try/except/finally." |
| 158 | + }, |
| 159 | +"self": { |
| 160 | +"prefix":"s", |
| 161 | +"body":"self.$0", |
| 162 | +"description":"Shortend snippet to reference the self property in an object." |
| 163 | + }, |
| 164 | +"__magic__": { |
| 165 | +"prefix":"__", |
| 166 | +"body":"__${1:init}__$0", |
| 167 | +"description":"Code snippet to create magic methods." |
| 168 | + }, |
| 169 | +"if __name__ ==\"__main__\"": { |
| 170 | +"prefix":"ifmain", |
| 171 | +"body":"if __name__ ==\"__main__\":\n\t${1:main()}$0", |
| 172 | +"description":"Create implicitly all the code at the top level using the __name__ special variable." |
| 173 | + }, |
| 174 | +"lambda": { |
| 175 | +"prefix":"lam", |
| 176 | +"body":"lambda ${1:args}: ${2:expr}", |
| 177 | +"description":"Create template for lambda function" |
| 178 | + } |
169 | 179 | } |