python.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ace.define("ace/snippets/python",["require","exports","module"], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "snippet #!\n\
  4. #!/usr/bin/env python\n\
  5. snippet imp\n\
  6. import ${1:module}\n\
  7. snippet from\n\
  8. from ${1:package} import ${2:module}\n\
  9. # Module Docstring\n\
  10. snippet docs\n\
  11. '''\n\
  12. File: ${1:FILENAME:file_name}\n\
  13. Author: ${2:author}\n\
  14. Description: ${3}\n\
  15. '''\n\
  16. snippet wh\n\
  17. while ${1:condition}:\n\
  18. ${2:# TODO: write code...}\n\
  19. # dowh - does the same as do...while in other languages\n\
  20. snippet dowh\n\
  21. while True:\n\
  22. ${1:# TODO: write code...}\n\
  23. if ${2:condition}:\n\
  24. break\n\
  25. snippet with\n\
  26. with ${1:expr} as ${2:var}:\n\
  27. ${3:# TODO: write code...}\n\
  28. # New Class\n\
  29. snippet cl\n\
  30. class ${1:ClassName}(${2:object}):\n\
  31. \"\"\"${3:docstring for $1}\"\"\"\n\
  32. def __init__(self, ${4:arg}):\n\
  33. ${5:super($1, self).__init__()}\n\
  34. self.$4 = $4\n\
  35. ${6}\n\
  36. # New Function\n\
  37. snippet def\n\
  38. def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\
  39. \"\"\"${3:docstring for $1}\"\"\"\n\
  40. ${4:# TODO: write code...}\n\
  41. snippet deff\n\
  42. def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\
  43. ${3:# TODO: write code...}\n\
  44. # New Method\n\
  45. snippet defs\n\
  46. def ${1:mname}(self, ${2:arg}):\n\
  47. ${3:# TODO: write code...}\n\
  48. # New Property\n\
  49. snippet property\n\
  50. def ${1:foo}():\n\
  51. doc = \"${2:The $1 property.}\"\n\
  52. def fget(self):\n\
  53. ${3:return self._$1}\n\
  54. def fset(self, value):\n\
  55. ${4:self._$1 = value}\n\
  56. # Ifs\n\
  57. snippet if\n\
  58. if ${1:condition}:\n\
  59. ${2:# TODO: write code...}\n\
  60. snippet el\n\
  61. else:\n\
  62. ${1:# TODO: write code...}\n\
  63. snippet ei\n\
  64. elif ${1:condition}:\n\
  65. ${2:# TODO: write code...}\n\
  66. # For\n\
  67. snippet for\n\
  68. for ${1:item} in ${2:items}:\n\
  69. ${3:# TODO: write code...}\n\
  70. # Encodes\n\
  71. snippet cutf8\n\
  72. # -*- coding: utf-8 -*-\n\
  73. snippet clatin1\n\
  74. # -*- coding: latin-1 -*-\n\
  75. snippet cascii\n\
  76. # -*- coding: ascii -*-\n\
  77. # Lambda\n\
  78. snippet ld\n\
  79. ${1:var} = lambda ${2:vars} : ${3:action}\n\
  80. snippet .\n\
  81. self.\n\
  82. snippet try Try/Except\n\
  83. try:\n\
  84. ${1:# TODO: write code...}\n\
  85. except ${2:Exception}, ${3:e}:\n\
  86. ${4:raise $3}\n\
  87. snippet try Try/Except/Else\n\
  88. try:\n\
  89. ${1:# TODO: write code...}\n\
  90. except ${2:Exception}, ${3:e}:\n\
  91. ${4:raise $3}\n\
  92. else:\n\
  93. ${5:# TODO: write code...}\n\
  94. snippet try Try/Except/Finally\n\
  95. try:\n\
  96. ${1:# TODO: write code...}\n\
  97. except ${2:Exception}, ${3:e}:\n\
  98. ${4:raise $3}\n\
  99. finally:\n\
  100. ${5:# TODO: write code...}\n\
  101. snippet try Try/Except/Else/Finally\n\
  102. try:\n\
  103. ${1:# TODO: write code...}\n\
  104. except ${2:Exception}, ${3:e}:\n\
  105. ${4:raise $3}\n\
  106. else:\n\
  107. ${5:# TODO: write code...}\n\
  108. finally:\n\
  109. ${6:# TODO: write code...}\n\
  110. # if __name__ == '__main__':\n\
  111. snippet ifmain\n\
  112. if __name__ == '__main__':\n\
  113. ${1:main()}\n\
  114. # __magic__\n\
  115. snippet _\n\
  116. __${1:init}__${2}\n\
  117. # python debugger (pdb)\n\
  118. snippet pdb\n\
  119. import pdb; pdb.set_trace()\n\
  120. # ipython debugger (ipdb)\n\
  121. snippet ipdb\n\
  122. import ipdb; ipdb.set_trace()\n\
  123. # ipython debugger (pdbbb)\n\
  124. snippet pdbbb\n\
  125. import pdbpp; pdbpp.set_trace()\n\
  126. snippet pprint\n\
  127. import pprint; pprint.pprint(${1})${2}\n\
  128. snippet \"\n\
  129. \"\"\"\n\
  130. ${1:doc}\n\
  131. \"\"\"\n\
  132. # test function/method\n\
  133. snippet test\n\
  134. def test_${1:description}(${2:self}):\n\
  135. ${3:# TODO: write code...}\n\
  136. # test case\n\
  137. snippet testcase\n\
  138. class ${1:ExampleCase}(unittest.TestCase):\n\
  139. \n\
  140. def test_${2:description}(self):\n\
  141. ${3:# TODO: write code...}\n\
  142. snippet fut\n\
  143. from __future__ import ${1}\n\
  144. #getopt\n\
  145. snippet getopt\n\
  146. try:\n\
  147. # Short option syntax: \"hv:\"\n\
  148. # Long option syntax: \"help\" or \"verbose=\"\n\
  149. opts, args = getopt.getopt(sys.argv[1:], \"${1:short_options}\", [${2:long_options}])\n\
  150. \n\
  151. except getopt.GetoptError, err:\n\
  152. # Print debug info\n\
  153. print str(err)\n\
  154. ${3:error_action}\n\
  155. \n\
  156. for option, argument in opts:\n\
  157. if option in (\"-h\", \"--help\"):\n\
  158. ${4}\n\
  159. elif option in (\"-v\", \"--verbose\"):\n\
  160. verbose = argument\n\
  161. ";
  162. exports.scope = "python";
  163. });