bee_python 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. data/LICENSE +202 -0
  2. data/build/README +23 -0
  3. data/egg/egg/build.yml +70 -0
  4. data/egg/egg/ez_setup.py +280 -0
  5. data/egg/egg/script.py +12 -0
  6. data/egg/egg/setup.erb +11 -0
  7. data/egg/egg/suite.py +37 -0
  8. data/egg/egg/test.py +31 -0
  9. data/egg/egg.yml +69 -0
  10. data/egg/http/build.erb +53 -0
  11. data/egg/http/server.py +34 -0
  12. data/egg/http.yml +50 -0
  13. data/egg/mysql/mysql.py +43 -0
  14. data/egg/mysql.yml +44 -0
  15. data/egg/project/build.erb +77 -0
  16. data/egg/project/script.py +42 -0
  17. data/egg/project/test.py +31 -0
  18. data/egg/project.yml +59 -0
  19. data/egg/script/build.erb +35 -0
  20. data/egg/script/script.py +42 -0
  21. data/egg/script.yml +50 -0
  22. data/egg/soap/build.erb +52 -0
  23. data/egg/soap/client.py +18 -0
  24. data/egg/soap/server.py +30 -0
  25. data/egg/soap.yml +58 -0
  26. data/egg/source/source.py +42 -0
  27. data/egg/source.yml +47 -0
  28. data/egg/test/test.py +28 -0
  29. data/egg/test.yml +44 -0
  30. data/egg/xmlrpc/build.erb +52 -0
  31. data/egg/xmlrpc/client.py +22 -0
  32. data/egg/xmlrpc/server.py +24 -0
  33. data/egg/xmlrpc.yml +51 -0
  34. data/lib/bee_task_python.rb +390 -0
  35. data/test/build.yml +16 -0
  36. data/test/tc_bee_task_python.rb +27 -0
  37. data/test/test_build.rb +26 -0
  38. data/test/test_build_listener.rb +62 -0
  39. data/test/ts_bee_python.rb +26 -0
  40. data/tools/common/__init__.py +5 -0
  41. data/tools/common/common/__init__.py +140 -0
  42. data/tools/common/common/__pkginfo__.py +43 -0
  43. data/tools/common/common/adbh.py +35 -0
  44. data/tools/common/common/cache.py +114 -0
  45. data/tools/common/common/changelog.py +234 -0
  46. data/tools/common/common/clcommands.py +181 -0
  47. data/tools/common/common/cli.py +212 -0
  48. data/tools/common/common/compat.py +328 -0
  49. data/tools/common/common/configuration.py +1087 -0
  50. data/tools/common/common/contexts.py +58 -0
  51. data/tools/common/common/corbautils.py +117 -0
  52. data/tools/common/common/daemon.py +171 -0
  53. data/tools/common/common/date.py +279 -0
  54. data/tools/common/common/db.py +49 -0
  55. data/tools/common/common/dbf.py +229 -0
  56. data/tools/common/common/debugger.py +208 -0
  57. data/tools/common/common/decorators.py +190 -0
  58. data/tools/common/common/deprecation.py +118 -0
  59. data/tools/common/common/fileutils.py +409 -0
  60. data/tools/common/common/graph.py +259 -0
  61. data/tools/common/common/html.py +142 -0
  62. data/tools/common/common/interface.py +76 -0
  63. data/tools/common/common/logging_ext.py +166 -0
  64. data/tools/common/common/modutils.py +670 -0
  65. data/tools/common/common/optik_ext.py +383 -0
  66. data/tools/common/common/optparser.py +92 -0
  67. data/tools/common/common/pdf_ext.py +111 -0
  68. data/tools/common/common/proc.py +276 -0
  69. data/tools/common/common/pyro_ext.py +146 -0
  70. data/tools/common/common/pytest.py +754 -0
  71. data/tools/common/common/shellutils.py +383 -0
  72. data/tools/common/common/sphinx_ext.py +87 -0
  73. data/tools/common/common/sphinxutils.py +122 -0
  74. data/tools/common/common/sqlgen.py +31 -0
  75. data/tools/common/common/table.py +930 -0
  76. data/tools/common/common/tasksqueue.py +97 -0
  77. data/tools/common/common/test/__init__.py +1 -0
  78. data/tools/common/common/test/data/ChangeLog +184 -0
  79. data/tools/common/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  80. data/tools/common/common/test/data/__init__.py +1 -0
  81. data/tools/common/common/test/data/content_differ_dir/NOTHING +0 -0
  82. data/tools/common/common/test/data/content_differ_dir/README +1 -0
  83. data/tools/common/common/test/data/content_differ_dir/subdir/coin +1 -0
  84. data/tools/common/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
  85. data/tools/common/common/test/data/file_differ_dir/NOTHING +0 -0
  86. data/tools/common/common/test/data/file_differ_dir/README +1 -0
  87. data/tools/common/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
  88. data/tools/common/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
  89. data/tools/common/common/test/data/find_test/__init__.py +0 -0
  90. data/tools/common/common/test/data/find_test/foo.txt +0 -0
  91. data/tools/common/common/test/data/find_test/module.py +0 -0
  92. data/tools/common/common/test/data/find_test/module2.py +0 -0
  93. data/tools/common/common/test/data/find_test/newlines.txt +0 -0
  94. data/tools/common/common/test/data/find_test/noendingnewline.py +0 -0
  95. data/tools/common/common/test/data/find_test/nonregr.py +0 -0
  96. data/tools/common/common/test/data/find_test/normal_file.txt +0 -0
  97. data/tools/common/common/test/data/find_test/spam.txt +0 -0
  98. data/tools/common/common/test/data/find_test/sub/doc.txt +0 -0
  99. data/tools/common/common/test/data/find_test/sub/momo.py +0 -0
  100. data/tools/common/common/test/data/find_test/test.ini +0 -0
  101. data/tools/common/common/test/data/find_test/test1.msg +0 -0
  102. data/tools/common/common/test/data/find_test/test2.msg +0 -0
  103. data/tools/common/common/test/data/find_test/write_protected_file.txt +0 -0
  104. data/tools/common/common/test/data/foo.txt +9 -0
  105. data/tools/common/common/test/data/module.py +88 -0
  106. data/tools/common/common/test/data/module2.py +77 -0
  107. data/tools/common/common/test/data/newlines.txt +3 -0
  108. data/tools/common/common/test/data/noendingnewline.py +36 -0
  109. data/tools/common/common/test/data/nonregr.py +14 -0
  110. data/tools/common/common/test/data/normal_file.txt +0 -0
  111. data/tools/common/common/test/data/reference_dir/NOTHING +0 -0
  112. data/tools/common/common/test/data/reference_dir/README +1 -0
  113. data/tools/common/common/test/data/reference_dir/subdir/coin +1 -0
  114. data/tools/common/common/test/data/reference_dir/subdir/toto.txt +53 -0
  115. data/tools/common/common/test/data/same_dir/NOTHING +0 -0
  116. data/tools/common/common/test/data/same_dir/README +1 -0
  117. data/tools/common/common/test/data/same_dir/subdir/coin +1 -0
  118. data/tools/common/common/test/data/same_dir/subdir/toto.txt +53 -0
  119. data/tools/common/common/test/data/spam.txt +9 -0
  120. data/tools/common/common/test/data/sub/doc.txt +1 -0
  121. data/tools/common/common/test/data/sub/momo.py +1 -0
  122. data/tools/common/common/test/data/subdir_differ_dir/NOTHING +0 -0
  123. data/tools/common/common/test/data/subdir_differ_dir/README +1 -0
  124. data/tools/common/common/test/data/subdir_differ_dir/subdir/coin +1 -0
  125. data/tools/common/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
  126. data/tools/common/common/test/data/test.ini +20 -0
  127. data/tools/common/common/test/data/test1.msg +30 -0
  128. data/tools/common/common/test/data/test2.msg +42 -0
  129. data/tools/common/common/test/data/write_protected_file.txt +0 -0
  130. data/tools/common/common/test/foomod.py +17 -0
  131. data/tools/common/common/test/unittest_cache.py +129 -0
  132. data/tools/common/common/test/unittest_changelog.py +37 -0
  133. data/tools/common/common/test/unittest_compat.py +239 -0
  134. data/tools/common/common/test/unittest_configuration.py +348 -0
  135. data/tools/common/common/test/unittest_date.py +154 -0
  136. data/tools/common/common/test/unittest_decorators.py +62 -0
  137. data/tools/common/common/test/unittest_deprecation.py +76 -0
  138. data/tools/common/common/test/unittest_fileutils.py +133 -0
  139. data/tools/common/common/test/unittest_graph.py +50 -0
  140. data/tools/common/common/test/unittest_html.py +76 -0
  141. data/tools/common/common/test/unittest_interface.py +87 -0
  142. data/tools/common/common/test/unittest_modutils.py +244 -0
  143. data/tools/common/common/test/unittest_pytest.py +50 -0
  144. data/tools/common/common/test/unittest_shellutils.py +248 -0
  145. data/tools/common/common/test/unittest_table.py +448 -0
  146. data/tools/common/common/test/unittest_taskqueue.py +71 -0
  147. data/tools/common/common/test/unittest_testlib.py +956 -0
  148. data/tools/common/common/test/unittest_textutils.py +247 -0
  149. data/tools/common/common/test/unittest_tree.py +248 -0
  150. data/tools/common/common/test/unittest_umessage.py +55 -0
  151. data/tools/common/common/test/unittest_ureports_html.py +64 -0
  152. data/tools/common/common/test/unittest_ureports_text.py +105 -0
  153. data/tools/common/common/test/unittest_xmlutils.py +75 -0
  154. data/tools/common/common/test/utils.py +87 -0
  155. data/tools/common/common/testlib.py +1927 -0
  156. data/tools/common/common/textutils.py +476 -0
  157. data/tools/common/common/tree.py +372 -0
  158. data/tools/common/common/umessage.py +161 -0
  159. data/tools/common/common/ureports/__init__.py +174 -0
  160. data/tools/common/common/ureports/docbook_writer.py +139 -0
  161. data/tools/common/common/ureports/html_writer.py +131 -0
  162. data/tools/common/common/ureports/nodes.py +201 -0
  163. data/tools/common/common/ureports/text_writer.py +140 -0
  164. data/tools/common/common/vcgutils.py +216 -0
  165. data/tools/common/common/visitor.py +107 -0
  166. data/tools/common/common/xmlrpcutils.py +136 -0
  167. data/tools/common/common/xmlutils.py +61 -0
  168. data/tools/compile/compile.py +16 -0
  169. data/tools/coverage/coverage.py +602 -0
  170. data/tools/epydoc/__init__.py +227 -0
  171. data/tools/epydoc/__init__.pyc +0 -0
  172. data/tools/epydoc/apidoc.py +2203 -0
  173. data/tools/epydoc/apidoc.pyc +0 -0
  174. data/tools/epydoc/checker.py +349 -0
  175. data/tools/epydoc/checker.pyc +0 -0
  176. data/tools/epydoc/cli.py +1470 -0
  177. data/tools/epydoc/cli.pyc +0 -0
  178. data/tools/epydoc/compat.py +250 -0
  179. data/tools/epydoc/compat.pyc +0 -0
  180. data/tools/epydoc/docbuilder.py +1358 -0
  181. data/tools/epydoc/docbuilder.pyc +0 -0
  182. data/tools/epydoc/docintrospecter.py +1056 -0
  183. data/tools/epydoc/docintrospecter.pyc +0 -0
  184. data/tools/epydoc/docparser.py +2113 -0
  185. data/tools/epydoc/docparser.pyc +0 -0
  186. data/tools/epydoc/docstringparser.py +1111 -0
  187. data/tools/epydoc/docstringparser.pyc +0 -0
  188. data/tools/epydoc/docwriter/__init__.py +12 -0
  189. data/tools/epydoc/docwriter/__init__.pyc +0 -0
  190. data/tools/epydoc/docwriter/dotgraph.py +1351 -0
  191. data/tools/epydoc/docwriter/dotgraph.pyc +0 -0
  192. data/tools/epydoc/docwriter/html.py +3491 -0
  193. data/tools/epydoc/docwriter/html.pyc +0 -0
  194. data/tools/epydoc/docwriter/html_colorize.py +909 -0
  195. data/tools/epydoc/docwriter/html_colorize.pyc +0 -0
  196. data/tools/epydoc/docwriter/html_css.py +550 -0
  197. data/tools/epydoc/docwriter/html_css.pyc +0 -0
  198. data/tools/epydoc/docwriter/html_help.py +190 -0
  199. data/tools/epydoc/docwriter/html_help.pyc +0 -0
  200. data/tools/epydoc/docwriter/latex.py +1187 -0
  201. data/tools/epydoc/docwriter/latex.pyc +0 -0
  202. data/tools/epydoc/docwriter/plaintext.py +276 -0
  203. data/tools/epydoc/docwriter/plaintext.pyc +0 -0
  204. data/tools/epydoc/docwriter/xlink.py +505 -0
  205. data/tools/epydoc/docwriter/xlink.pyc +0 -0
  206. data/tools/epydoc/gui.py +1148 -0
  207. data/tools/epydoc/gui.pyc +0 -0
  208. data/tools/epydoc/log.py +204 -0
  209. data/tools/epydoc/log.pyc +0 -0
  210. data/tools/epydoc/markup/__init__.py +623 -0
  211. data/tools/epydoc/markup/__init__.pyc +0 -0
  212. data/tools/epydoc/markup/doctest.py +311 -0
  213. data/tools/epydoc/markup/doctest.pyc +0 -0
  214. data/tools/epydoc/markup/epytext.py +2116 -0
  215. data/tools/epydoc/markup/epytext.pyc +0 -0
  216. data/tools/epydoc/markup/javadoc.py +250 -0
  217. data/tools/epydoc/markup/javadoc.pyc +0 -0
  218. data/tools/epydoc/markup/plaintext.py +78 -0
  219. data/tools/epydoc/markup/plaintext.pyc +0 -0
  220. data/tools/epydoc/markup/pyval_repr.py +532 -0
  221. data/tools/epydoc/markup/pyval_repr.pyc +0 -0
  222. data/tools/epydoc/markup/restructuredtext.py +906 -0
  223. data/tools/epydoc/markup/restructuredtext.pyc +0 -0
  224. data/tools/epydoc/test/__init__.py +97 -0
  225. data/tools/epydoc/test/__init__.pyc +0 -0
  226. data/tools/epydoc/test/util.py +226 -0
  227. data/tools/epydoc/test/util.pyc +0 -0
  228. data/tools/epydoc/util.py +289 -0
  229. data/tools/epydoc/util.pyc +0 -0
  230. data/tools/logilab/logilab/__init__.py +5 -0
  231. data/tools/logilab/logilab/astng/__init__.py +82 -0
  232. data/tools/logilab/logilab/astng/__pkginfo__.py +76 -0
  233. data/tools/logilab/logilab/astng/_exceptions.py +64 -0
  234. data/tools/logilab/logilab/astng/_nodes_ast.py +667 -0
  235. data/tools/logilab/logilab/astng/_nodes_compiler.py +758 -0
  236. data/tools/logilab/logilab/astng/bases.py +608 -0
  237. data/tools/logilab/logilab/astng/builder.py +239 -0
  238. data/tools/logilab/logilab/astng/inference.py +426 -0
  239. data/tools/logilab/logilab/astng/inspector.py +289 -0
  240. data/tools/logilab/logilab/astng/manager.py +421 -0
  241. data/tools/logilab/logilab/astng/mixins.py +165 -0
  242. data/tools/logilab/logilab/astng/node_classes.py +848 -0
  243. data/tools/logilab/logilab/astng/nodes.py +85 -0
  244. data/tools/logilab/logilab/astng/nodes_as_string.py +389 -0
  245. data/tools/logilab/logilab/astng/patchcomptransformer.py +159 -0
  246. data/tools/logilab/logilab/astng/protocols.py +333 -0
  247. data/tools/logilab/logilab/astng/raw_building.py +212 -0
  248. data/tools/logilab/logilab/astng/rebuilder.py +307 -0
  249. data/tools/logilab/logilab/astng/scoped_nodes.py +951 -0
  250. data/tools/logilab/logilab/astng/test/__init__.py +19 -0
  251. data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  252. data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.zip +0 -0
  253. data/tools/logilab/logilab/astng/test/data/SSL1/Connection1.py +33 -0
  254. data/tools/logilab/logilab/astng/test/data/SSL1/__init__.py +20 -0
  255. data/tools/logilab/logilab/astng/test/data/__init__.py +20 -0
  256. data/tools/logilab/logilab/astng/test/data/all.py +29 -0
  257. data/tools/logilab/logilab/astng/test/data/appl/__init__.py +23 -0
  258. data/tools/logilab/logilab/astng/test/data/appl/myConnection.py +30 -0
  259. data/tools/logilab/logilab/astng/test/data/format.py +34 -0
  260. data/tools/logilab/logilab/astng/test/data/module.py +90 -0
  261. data/tools/logilab/logilab/astng/test/data/module2.py +112 -0
  262. data/tools/logilab/logilab/astng/test/data/noendingnewline.py +57 -0
  263. data/tools/logilab/logilab/astng/test/data/nonregr.py +76 -0
  264. data/tools/logilab/logilab/astng/test/data/notall.py +28 -0
  265. data/tools/logilab/logilab/astng/test/data2/__init__.py +20 -0
  266. data/tools/logilab/logilab/astng/test/data2/clientmodule_test.py +51 -0
  267. data/tools/logilab/logilab/astng/test/data2/suppliermodule_test.py +32 -0
  268. data/tools/logilab/logilab/astng/test/regrtest.py +135 -0
  269. data/tools/logilab/logilab/astng/test/regrtest_data/absimport.py +22 -0
  270. data/tools/logilab/logilab/astng/test/regrtest_data/descriptor_crash.py +31 -0
  271. data/tools/logilab/logilab/astng/test/regrtest_data/import_package_subpackage_module.py +68 -0
  272. data/tools/logilab/logilab/astng/test/regrtest_data/package/__init__.py +24 -0
  273. data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/__init__.py +20 -0
  274. data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/module.py +20 -0
  275. data/tools/logilab/logilab/astng/test/unittest_builder.py +684 -0
  276. data/tools/logilab/logilab/astng/test/unittest_inference.py +1112 -0
  277. data/tools/logilab/logilab/astng/test/unittest_inspector.py +105 -0
  278. data/tools/logilab/logilab/astng/test/unittest_lookup.py +302 -0
  279. data/tools/logilab/logilab/astng/test/unittest_manager.py +98 -0
  280. data/tools/logilab/logilab/astng/test/unittest_nodes.py +302 -0
  281. data/tools/logilab/logilab/astng/test/unittest_scoped_nodes.py +501 -0
  282. data/tools/logilab/logilab/astng/test/unittest_utils.py +104 -0
  283. data/tools/logilab/logilab/astng/utils.py +342 -0
  284. data/tools/logilab/logilab/common/__init__.py +140 -0
  285. data/tools/logilab/logilab/common/__pkginfo__.py +43 -0
  286. data/tools/logilab/logilab/common/adbh.py +35 -0
  287. data/tools/logilab/logilab/common/cache.py +114 -0
  288. data/tools/logilab/logilab/common/changelog.py +234 -0
  289. data/tools/logilab/logilab/common/clcommands.py +181 -0
  290. data/tools/logilab/logilab/common/cli.py +212 -0
  291. data/tools/logilab/logilab/common/compat.py +328 -0
  292. data/tools/logilab/logilab/common/configuration.py +1087 -0
  293. data/tools/logilab/logilab/common/contexts.py +58 -0
  294. data/tools/logilab/logilab/common/corbautils.py +117 -0
  295. data/tools/logilab/logilab/common/daemon.py +171 -0
  296. data/tools/logilab/logilab/common/date.py +279 -0
  297. data/tools/logilab/logilab/common/db.py +49 -0
  298. data/tools/logilab/logilab/common/dbf.py +229 -0
  299. data/tools/logilab/logilab/common/debugger.py +208 -0
  300. data/tools/logilab/logilab/common/decorators.py +190 -0
  301. data/tools/logilab/logilab/common/deprecation.py +118 -0
  302. data/tools/logilab/logilab/common/fileutils.py +409 -0
  303. data/tools/logilab/logilab/common/graph.py +259 -0
  304. data/tools/logilab/logilab/common/html.py +142 -0
  305. data/tools/logilab/logilab/common/interface.py +76 -0
  306. data/tools/logilab/logilab/common/logging_ext.py +166 -0
  307. data/tools/logilab/logilab/common/modutils.py +670 -0
  308. data/tools/logilab/logilab/common/optik_ext.py +383 -0
  309. data/tools/logilab/logilab/common/optparser.py +92 -0
  310. data/tools/logilab/logilab/common/pdf_ext.py +111 -0
  311. data/tools/logilab/logilab/common/proc.py +276 -0
  312. data/tools/logilab/logilab/common/pyro_ext.py +146 -0
  313. data/tools/logilab/logilab/common/pytest.py +754 -0
  314. data/tools/logilab/logilab/common/shellutils.py +383 -0
  315. data/tools/logilab/logilab/common/sphinx_ext.py +87 -0
  316. data/tools/logilab/logilab/common/sphinxutils.py +122 -0
  317. data/tools/logilab/logilab/common/sqlgen.py +31 -0
  318. data/tools/logilab/logilab/common/table.py +930 -0
  319. data/tools/logilab/logilab/common/tasksqueue.py +97 -0
  320. data/tools/logilab/logilab/common/test/__init__.py +1 -0
  321. data/tools/logilab/logilab/common/test/data/ChangeLog +184 -0
  322. data/tools/logilab/logilab/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  323. data/tools/logilab/logilab/common/test/data/__init__.py +1 -0
  324. data/tools/logilab/logilab/common/test/data/content_differ_dir/NOTHING +0 -0
  325. data/tools/logilab/logilab/common/test/data/content_differ_dir/README +1 -0
  326. data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/coin +1 -0
  327. data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
  328. data/tools/logilab/logilab/common/test/data/file_differ_dir/NOTHING +0 -0
  329. data/tools/logilab/logilab/common/test/data/file_differ_dir/README +1 -0
  330. data/tools/logilab/logilab/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
  331. data/tools/logilab/logilab/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
  332. data/tools/logilab/logilab/common/test/data/find_test/__init__.py +0 -0
  333. data/tools/logilab/logilab/common/test/data/find_test/foo.txt +0 -0
  334. data/tools/logilab/logilab/common/test/data/find_test/module.py +0 -0
  335. data/tools/logilab/logilab/common/test/data/find_test/module2.py +0 -0
  336. data/tools/logilab/logilab/common/test/data/find_test/newlines.txt +0 -0
  337. data/tools/logilab/logilab/common/test/data/find_test/noendingnewline.py +0 -0
  338. data/tools/logilab/logilab/common/test/data/find_test/nonregr.py +0 -0
  339. data/tools/logilab/logilab/common/test/data/find_test/normal_file.txt +0 -0
  340. data/tools/logilab/logilab/common/test/data/find_test/spam.txt +0 -0
  341. data/tools/logilab/logilab/common/test/data/find_test/sub/doc.txt +0 -0
  342. data/tools/logilab/logilab/common/test/data/find_test/sub/momo.py +0 -0
  343. data/tools/logilab/logilab/common/test/data/find_test/test.ini +0 -0
  344. data/tools/logilab/logilab/common/test/data/find_test/test1.msg +0 -0
  345. data/tools/logilab/logilab/common/test/data/find_test/test2.msg +0 -0
  346. data/tools/logilab/logilab/common/test/data/find_test/write_protected_file.txt +0 -0
  347. data/tools/logilab/logilab/common/test/data/foo.txt +9 -0
  348. data/tools/logilab/logilab/common/test/data/module.py +88 -0
  349. data/tools/logilab/logilab/common/test/data/module2.py +77 -0
  350. data/tools/logilab/logilab/common/test/data/newlines.txt +3 -0
  351. data/tools/logilab/logilab/common/test/data/noendingnewline.py +36 -0
  352. data/tools/logilab/logilab/common/test/data/nonregr.py +14 -0
  353. data/tools/logilab/logilab/common/test/data/normal_file.txt +0 -0
  354. data/tools/logilab/logilab/common/test/data/reference_dir/NOTHING +0 -0
  355. data/tools/logilab/logilab/common/test/data/reference_dir/README +1 -0
  356. data/tools/logilab/logilab/common/test/data/reference_dir/subdir/coin +1 -0
  357. data/tools/logilab/logilab/common/test/data/reference_dir/subdir/toto.txt +53 -0
  358. data/tools/logilab/logilab/common/test/data/same_dir/NOTHING +0 -0
  359. data/tools/logilab/logilab/common/test/data/same_dir/README +1 -0
  360. data/tools/logilab/logilab/common/test/data/same_dir/subdir/coin +1 -0
  361. data/tools/logilab/logilab/common/test/data/same_dir/subdir/toto.txt +53 -0
  362. data/tools/logilab/logilab/common/test/data/spam.txt +9 -0
  363. data/tools/logilab/logilab/common/test/data/sub/doc.txt +1 -0
  364. data/tools/logilab/logilab/common/test/data/sub/momo.py +1 -0
  365. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/NOTHING +0 -0
  366. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/README +1 -0
  367. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/coin +1 -0
  368. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
  369. data/tools/logilab/logilab/common/test/data/test.ini +20 -0
  370. data/tools/logilab/logilab/common/test/data/test1.msg +30 -0
  371. data/tools/logilab/logilab/common/test/data/test2.msg +42 -0
  372. data/tools/logilab/logilab/common/test/data/write_protected_file.txt +0 -0
  373. data/tools/logilab/logilab/common/test/foomod.py +17 -0
  374. data/tools/logilab/logilab/common/test/unittest_cache.py +129 -0
  375. data/tools/logilab/logilab/common/test/unittest_changelog.py +37 -0
  376. data/tools/logilab/logilab/common/test/unittest_compat.py +239 -0
  377. data/tools/logilab/logilab/common/test/unittest_configuration.py +348 -0
  378. data/tools/logilab/logilab/common/test/unittest_date.py +154 -0
  379. data/tools/logilab/logilab/common/test/unittest_decorators.py +62 -0
  380. data/tools/logilab/logilab/common/test/unittest_deprecation.py +76 -0
  381. data/tools/logilab/logilab/common/test/unittest_fileutils.py +133 -0
  382. data/tools/logilab/logilab/common/test/unittest_graph.py +50 -0
  383. data/tools/logilab/logilab/common/test/unittest_html.py +76 -0
  384. data/tools/logilab/logilab/common/test/unittest_interface.py +87 -0
  385. data/tools/logilab/logilab/common/test/unittest_modutils.py +244 -0
  386. data/tools/logilab/logilab/common/test/unittest_pytest.py +50 -0
  387. data/tools/logilab/logilab/common/test/unittest_shellutils.py +248 -0
  388. data/tools/logilab/logilab/common/test/unittest_table.py +448 -0
  389. data/tools/logilab/logilab/common/test/unittest_taskqueue.py +71 -0
  390. data/tools/logilab/logilab/common/test/unittest_testlib.py +956 -0
  391. data/tools/logilab/logilab/common/test/unittest_textutils.py +247 -0
  392. data/tools/logilab/logilab/common/test/unittest_tree.py +248 -0
  393. data/tools/logilab/logilab/common/test/unittest_umessage.py +55 -0
  394. data/tools/logilab/logilab/common/test/unittest_ureports_html.py +64 -0
  395. data/tools/logilab/logilab/common/test/unittest_ureports_text.py +105 -0
  396. data/tools/logilab/logilab/common/test/unittest_xmlutils.py +75 -0
  397. data/tools/logilab/logilab/common/test/utils.py +87 -0
  398. data/tools/logilab/logilab/common/testlib.py +1927 -0
  399. data/tools/logilab/logilab/common/textutils.py +476 -0
  400. data/tools/logilab/logilab/common/tree.py +372 -0
  401. data/tools/logilab/logilab/common/umessage.py +161 -0
  402. data/tools/logilab/logilab/common/ureports/__init__.py +174 -0
  403. data/tools/logilab/logilab/common/ureports/docbook_writer.py +139 -0
  404. data/tools/logilab/logilab/common/ureports/html_writer.py +131 -0
  405. data/tools/logilab/logilab/common/ureports/nodes.py +201 -0
  406. data/tools/logilab/logilab/common/ureports/text_writer.py +140 -0
  407. data/tools/logilab/logilab/common/vcgutils.py +216 -0
  408. data/tools/logilab/logilab/common/visitor.py +107 -0
  409. data/tools/logilab/logilab/common/xmlrpcutils.py +136 -0
  410. data/tools/logilab/logilab/common/xmlutils.py +61 -0
  411. data/tools/pychecker/COPYRIGHT +31 -0
  412. data/tools/pychecker/ChangeLog +349 -0
  413. data/tools/pychecker/CodeChecks.py +1969 -0
  414. data/tools/pychecker/CodeChecks.pyc +0 -0
  415. data/tools/pychecker/CodeChecks.pyo +0 -0
  416. data/tools/pychecker/Config.py +475 -0
  417. data/tools/pychecker/Config.pyc +0 -0
  418. data/tools/pychecker/Config.pyo +0 -0
  419. data/tools/pychecker/KNOWN_BUGS +100 -0
  420. data/tools/pychecker/MAINTAINERS +81 -0
  421. data/tools/pychecker/NEWS +406 -0
  422. data/tools/pychecker/OP.py +131 -0
  423. data/tools/pychecker/OP.pyc +0 -0
  424. data/tools/pychecker/OP.pyo +0 -0
  425. data/tools/pychecker/OptionTypes.py +117 -0
  426. data/tools/pychecker/OptionTypes.pyc +0 -0
  427. data/tools/pychecker/OptionTypes.pyo +0 -0
  428. data/tools/pychecker/README +152 -0
  429. data/tools/pychecker/Stack.py +115 -0
  430. data/tools/pychecker/Stack.pyc +0 -0
  431. data/tools/pychecker/Stack.pyo +0 -0
  432. data/tools/pychecker/TODO +101 -0
  433. data/tools/pychecker/VERSION +1 -0
  434. data/tools/pychecker/Warning.py +50 -0
  435. data/tools/pychecker/Warning.pyc +0 -0
  436. data/tools/pychecker/Warning.pyo +0 -0
  437. data/tools/pychecker/__init__.py +17 -0
  438. data/tools/pychecker/__init__.pyc +0 -0
  439. data/tools/pychecker/__init__.pyo +0 -0
  440. data/tools/pychecker/checker.py +961 -0
  441. data/tools/pychecker/checker.pyc +0 -0
  442. data/tools/pychecker/checker.pyo +0 -0
  443. data/tools/pychecker/function.py +159 -0
  444. data/tools/pychecker/function.pyc +0 -0
  445. data/tools/pychecker/function.pyo +0 -0
  446. data/tools/pychecker/msgs.py +175 -0
  447. data/tools/pychecker/msgs.pyc +0 -0
  448. data/tools/pychecker/msgs.pyo +0 -0
  449. data/tools/pychecker/options.py +275 -0
  450. data/tools/pychecker/options.pyc +0 -0
  451. data/tools/pychecker/options.pyo +0 -0
  452. data/tools/pychecker/pcmodules.py +19 -0
  453. data/tools/pychecker/pcmodules.pyc +0 -0
  454. data/tools/pychecker/pcmodules.pyo +0 -0
  455. data/tools/pychecker/printer.py +47 -0
  456. data/tools/pychecker/printer.pyc +0 -0
  457. data/tools/pychecker/printer.pyo +0 -0
  458. data/tools/pychecker/python.py +427 -0
  459. data/tools/pychecker/python.pyc +0 -0
  460. data/tools/pychecker/python.pyo +0 -0
  461. data/tools/pychecker/utils.py +102 -0
  462. data/tools/pychecker/utils.pyc +0 -0
  463. data/tools/pychecker/utils.pyo +0 -0
  464. data/tools/pychecker/warn.py +778 -0
  465. data/tools/pychecker/warn.pyc +0 -0
  466. data/tools/pychecker/warn.pyo +0 -0
  467. data/tools/pylint2/pylint/__init__.py +16 -0
  468. data/tools/pylint2/pylint/__pkginfo__.py +67 -0
  469. data/tools/pylint2/pylint/checkers/__init__.py +155 -0
  470. data/tools/pylint2/pylint/checkers/base.py +749 -0
  471. data/tools/pylint2/pylint/checkers/classes.py +527 -0
  472. data/tools/pylint2/pylint/checkers/design_analysis.py +344 -0
  473. data/tools/pylint2/pylint/checkers/exceptions.py +183 -0
  474. data/tools/pylint2/pylint/checkers/format.py +367 -0
  475. data/tools/pylint2/pylint/checkers/imports.py +379 -0
  476. data/tools/pylint2/pylint/checkers/logging.py +98 -0
  477. data/tools/pylint2/pylint/checkers/misc.py +128 -0
  478. data/tools/pylint2/pylint/checkers/newstyle.py +107 -0
  479. data/tools/pylint2/pylint/checkers/raw_metrics.py +125 -0
  480. data/tools/pylint2/pylint/checkers/similar.py +333 -0
  481. data/tools/pylint2/pylint/checkers/string_format.py +239 -0
  482. data/tools/pylint2/pylint/checkers/typecheck.py +364 -0
  483. data/tools/pylint2/pylint/checkers/utils.py +208 -0
  484. data/tools/pylint2/pylint/checkers/variables.py +498 -0
  485. data/tools/pylint2/pylint/config.py +149 -0
  486. data/tools/pylint2/pylint/epylint.py +149 -0
  487. data/tools/pylint2/pylint/gui.py +433 -0
  488. data/tools/pylint2/pylint/interfaces.py +98 -0
  489. data/tools/pylint2/pylint/lint.py +914 -0
  490. data/tools/pylint2/pylint/pyreverse/__init__.py +5 -0
  491. data/tools/pylint2/pylint/pyreverse/diadefslib.py +229 -0
  492. data/tools/pylint2/pylint/pyreverse/diagrams.py +247 -0
  493. data/tools/pylint2/pylint/pyreverse/main.py +123 -0
  494. data/tools/pylint2/pylint/pyreverse/utils.py +131 -0
  495. data/tools/pylint2/pylint/pyreverse/writer.py +196 -0
  496. data/tools/pylint2/pylint/reporters/__init__.py +67 -0
  497. data/tools/pylint2/pylint/reporters/guireporter.py +36 -0
  498. data/tools/pylint2/pylint/reporters/html.py +69 -0
  499. data/tools/pylint2/pylint/reporters/text.py +156 -0
  500. data/tools/pylint2/pylint/utils.py +518 -0
  501. data/tools/pylint2/pylint.py +16 -0
  502. data/tools/test/suite.py +35 -0
  503. metadata +566 -0
@@ -0,0 +1,749 @@
1
+ # Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
2
+ # Copyright (c) 2009-2010 Arista Networks, Inc.
3
+ # http://www.logilab.fr/ -- mailto:contact@logilab.fr
4
+ # This program is free software; you can redistribute it and/or modify it under
5
+ # the terms of the GNU General Public License as published by the Free Software
6
+ # Foundation; either version 2 of the License, or (at your option) any later
7
+ # version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along with
14
+ # this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
+ """basic checker for Python code"""
17
+
18
+
19
+ from logilab import astng
20
+ from logilab.common.compat import any
21
+ from logilab.common.ureports import Table
22
+ from logilab.astng import are_exclusive
23
+
24
+ from pylint.interfaces import IASTNGChecker
25
+ from pylint.reporters import diff_string
26
+ from pylint.checkers import BaseChecker, EmptyReport
27
+
28
+
29
+ import re
30
+
31
+ # regex for class/function/variable/constant name
32
+ CLASS_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]+$')
33
+ MOD_NAME_RGX = re.compile('(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$')
34
+ CONST_NAME_RGX = re.compile('(([A-Z_][A-Z0-9_]*)|(__.*__))$')
35
+ COMP_VAR_RGX = re.compile('[A-Za-z_][A-Za-z0-9_]*$')
36
+ DEFAULT_NAME_RGX = re.compile('[a-z_][a-z0-9_]{2,30}$')
37
+ # do not require a doc string on system methods
38
+ NO_REQUIRED_DOC_RGX = re.compile('__.*__')
39
+
40
+ del re
41
+
42
+ def in_loop(node):
43
+ """return True if the node is inside a kind of for loop"""
44
+ parent = node.parent
45
+ while parent is not None:
46
+ if isinstance(parent, (astng.For, astng.ListComp, astng.GenExpr)):
47
+ return True
48
+ parent = parent.parent
49
+ return False
50
+
51
+ def in_nested_list(nested_list, obj):
52
+ """return true if the object is an element of <nested_list> or of a nested
53
+ list
54
+ """
55
+ for elmt in nested_list:
56
+ if isinstance(elmt, (list, tuple)):
57
+ if in_nested_list(elmt, obj):
58
+ return True
59
+ elif elmt == obj:
60
+ return True
61
+ return False
62
+
63
+ def report_by_type_stats(sect, stats, old_stats):
64
+ """make a report of
65
+
66
+ * percentage of different types documented
67
+ * percentage of different types with a bad name
68
+ """
69
+ # percentage of different types documented and/or with a bad name
70
+ nice_stats = {}
71
+ for node_type in ('module', 'class', 'method', 'function'):
72
+ try:
73
+ total = stats[node_type]
74
+ except KeyError:
75
+ raise EmptyReport()
76
+ nice_stats[node_type] = {}
77
+ if total != 0:
78
+ try:
79
+ documented = total - stats['undocumented_'+node_type]
80
+ percent = (documented * 100.) / total
81
+ nice_stats[node_type]['percent_documented'] = '%.2f' % percent
82
+ except KeyError:
83
+ nice_stats[node_type]['percent_documented'] = 'NC'
84
+ try:
85
+ percent = (stats['badname_'+node_type] * 100.) / total
86
+ nice_stats[node_type]['percent_badname'] = '%.2f' % percent
87
+ except KeyError:
88
+ nice_stats[node_type]['percent_badname'] = 'NC'
89
+ lines = ('type', 'number', 'old number', 'difference',
90
+ '%documented', '%badname')
91
+ for node_type in ('module', 'class', 'method', 'function'):
92
+ new = stats[node_type]
93
+ old = old_stats.get(node_type, None)
94
+ if old is not None:
95
+ diff_str = diff_string(old, new)
96
+ else:
97
+ old, diff_str = 'NC', 'NC'
98
+ lines += (node_type, str(new), str(old), diff_str,
99
+ nice_stats[node_type].get('percent_documented', '0'),
100
+ nice_stats[node_type].get('percent_badname', '0'))
101
+ sect.append(Table(children=lines, cols=6, rheaders=1))
102
+
103
+ class _BasicChecker(BaseChecker):
104
+ __implements__ = IASTNGChecker
105
+ name = 'basic'
106
+
107
+ class BasicErrorChecker(_BasicChecker):
108
+ msgs = {
109
+ 'E0100': ('__init__ method is a generator',
110
+ 'Used when the special class method __init__ is turned into a '
111
+ 'generator by a yield in its body.'),
112
+ 'E0101': ('Explicit return in __init__',
113
+ 'Used when the special class method __init__ has an explicit \
114
+ return value.'),
115
+ 'E0102': ('%s already defined line %s',
116
+ 'Used when a function / class / method is redefined.'),
117
+ 'E0103': ('%r not properly in loop',
118
+ 'Used when break or continue keywords are used outside a loop.'),
119
+
120
+ 'E0104': ('Return outside function',
121
+ 'Used when a "return" statement is found outside a function or '
122
+ 'method.'),
123
+ 'E0105': ('Yield outside function',
124
+ 'Used when a "yield" statement is found outside a function or '
125
+ 'method.'),
126
+ 'E0106': ('Return with argument inside generator',
127
+ 'Used when a "return" statement with an argument is found '
128
+ 'outside in a generator function or method (e.g. with some '
129
+ '"yield" statements).'),
130
+ 'E0107': ("Use of the non-existent %s operator",
131
+ "Used when you attempt to use the C-style pre-increment or"
132
+ "pre-decrement operator -- and ++, which doesn't exist in Python."),
133
+ }
134
+
135
+ def __init__(self, linter):
136
+ _BasicChecker.__init__(self, linter)
137
+ self._returns = None
138
+
139
+ def open(self):
140
+ self._returns = []
141
+
142
+ def visit_class(self, node):
143
+ self._check_redefinition('class', node)
144
+
145
+ def visit_function(self, node):
146
+ self._returns.append([])
147
+ self._check_redefinition(node.is_method() and 'method' or 'function', node)
148
+
149
+ def leave_function(self, node):
150
+ """most of the work is done here on close:
151
+ checks for max returns, branch, return in __init__
152
+ """
153
+ returns = self._returns.pop()
154
+ if node.is_method() and node.name == '__init__':
155
+ if node.is_generator():
156
+ self.add_message('E0100', node=node)
157
+ else:
158
+ values = [r.value for r in returns]
159
+ if [v for v in values if not (v is None or
160
+ (isinstance(v, astng.Const) and v.value is None)
161
+ or (isinstance(v, astng.Name) and v.name == 'None'))]:
162
+ self.add_message('E0101', node=node)
163
+ elif node.is_generator():
164
+ # make sure we don't mix non-None returns and yields
165
+ for retnode in returns:
166
+ if isinstance(retnode, astng.Return) and \
167
+ isinstance(retnode.value, astng.Const) and \
168
+ retnode.value.value is not None:
169
+ self.add_message('E0106', node=node,
170
+ line=retnode.fromlineno)
171
+
172
+ def visit_return(self, node):
173
+ # if self._returns is empty, we're outside a function
174
+ if not self._returns:
175
+ self.add_message('E0104', node=node)
176
+ return
177
+ self._returns[-1].append(node)
178
+
179
+ def visit_yield(self, node):
180
+ # if self._returns is empty, we're outside a function
181
+ if not self._returns:
182
+ self.add_message('E0105', node=node)
183
+ return
184
+ self._returns[-1].append(node)
185
+
186
+ def visit_continue(self, node):
187
+ self._check_in_loop(node, 'continue')
188
+
189
+ def visit_break(self, node):
190
+ self._check_in_loop(node, 'break')
191
+
192
+ def visit_unaryop(self, node):
193
+ """check use of the non-existent ++ adn -- operator operator"""
194
+ if ((node.op in '+-') and
195
+ isinstance(node.operand, astng.UnaryOp) and
196
+ (node.operand.op == node.op)):
197
+ self.add_message('E0107', node=node, args=node.op*2)
198
+
199
+ def _check_in_loop(self, node, node_name):
200
+ """check that a node is inside a for or while loop"""
201
+ _node = node.parent
202
+ while _node:
203
+ if isinstance(_node, (astng.For, astng.While)):
204
+ break
205
+ _node = _node.parent
206
+ else:
207
+ self.add_message('E0103', node=node, args=node_name)
208
+
209
+ def _check_redefinition(self, redeftype, node):
210
+ """check for redefinition of a function / method / class name"""
211
+ defined_self = node.parent.frame()[node.name]
212
+ if defined_self is not node and not are_exclusive(node, defined_self):
213
+ self.add_message('E0102', node=node,
214
+ args=(redeftype, defined_self.fromlineno))
215
+
216
+
217
+
218
+ class BasicChecker(_BasicChecker):
219
+ """checks for :
220
+ * doc strings
221
+ * modules / classes / functions / methods / arguments / variables name
222
+ * number of arguments, local variables, branches, returns and statements in
223
+ functions, methods
224
+ * required module attributes
225
+ * dangerous default values as arguments
226
+ * redefinition of function / method / class
227
+ * uses of the global statement
228
+ """
229
+
230
+ __implements__ = IASTNGChecker
231
+
232
+ name = 'basic'
233
+ msgs = {
234
+ 'W0101': ('Unreachable code',
235
+ 'Used when there is some code behind a "return" or "raise" \
236
+ statement, which will never be accessed.'),
237
+ 'W0102': ('Dangerous default value %s as argument',
238
+ 'Used when a mutable value as list or dictionary is detected in \
239
+ a default value for an argument.'),
240
+ 'W0104': ('Statement seems to have no effect',
241
+ 'Used when a statement doesn\'t have (or at least seems to) \
242
+ any effect.'),
243
+ 'W0105': ('String statement has no effect',
244
+ 'Used when a string is used as a statement (which of course \
245
+ has no effect). This is a particular case of W0104 with its \
246
+ own message so you can easily disable it if you\'re using \
247
+ those strings as documentation, instead of comments.'),
248
+ 'W0108': ('Lambda may not be necessary',
249
+ 'Used when the body of a lambda expression is a function call \
250
+ on the same argument list as the lambda itself; such lambda \
251
+ expressions are in all but a few cases replaceable with the \
252
+ function being called in the body of the lambda.'),
253
+ 'W0109': ("Duplicate key %r in dictionary",
254
+ "Used when a dictionary expression binds the same key multiple \
255
+ times."),
256
+ 'W0122': ('Use of the exec statement',
257
+ 'Used when you use the "exec" statement, to discourage its \
258
+ usage. That doesn\'t mean you can not use it !'),
259
+
260
+ 'W0141': ('Used builtin function %r',
261
+ 'Used when a black listed builtin function is used (see the '
262
+ 'bad-function option). Usual black listed functions are the ones '
263
+ 'like map, or filter , where Python offers now some cleaner '
264
+ 'alternative like list comprehension.'),
265
+ 'W0142': ('Used * or ** magic',
266
+ 'Used when a function or method is called using `*args` or '
267
+ '`**kwargs` to dispatch arguments. This doesn\'t improve '
268
+ 'readability and should be used with care.'),
269
+ 'W0150': ("%s statement in finally block may swallow exception",
270
+ "Used when a break or a return statement is found inside the \
271
+ finally clause of a try...finally block: the exceptions raised \
272
+ in the try clause will be silently swallowed instead of being \
273
+ re-raised."),
274
+ 'W0199': ('Assert called on a 2-uple. Did you mean \'assert x,y\'?',
275
+ 'A call of assert on a tuple will always evaluate to true if '
276
+ 'the tuple is not empty, and will always evaluate to false if '
277
+ 'it is.'),
278
+
279
+ 'C0121': ('Missing required attribute "%s"', # W0103
280
+ 'Used when an attribute required for modules is missing.'),
281
+
282
+ }
283
+
284
+ options = (('required-attributes',
285
+ {'default' : (), 'type' : 'csv',
286
+ 'metavar' : '<attributes>',
287
+ 'help' : 'Required attributes for module, separated by a '
288
+ 'comma'}
289
+ ),
290
+ ('bad-functions',
291
+ {'default' : ('map', 'filter', 'apply', 'input'),
292
+ 'type' :'csv', 'metavar' : '<builtin function names>',
293
+ 'help' : 'List of builtins function names that should not be '
294
+ 'used, separated by a comma'}
295
+ ),
296
+ )
297
+ reports = ( ('RP0101', 'Statistics by type', report_by_type_stats), )
298
+
299
+ def __init__(self, linter):
300
+ _BasicChecker.__init__(self, linter)
301
+ self.stats = None
302
+ self._tryfinallys = None
303
+
304
+ def open(self):
305
+ """initialize visit variables and statistics
306
+ """
307
+ self._tryfinallys = []
308
+ self.stats = self.linter.add_stats(module=0, function=0,
309
+ method=0, class_=0)
310
+
311
+ def visit_module(self, node):
312
+ """check module name, docstring and required arguments
313
+ """
314
+ self.stats['module'] += 1
315
+ self._check_required_attributes(node, self.config.required_attributes)
316
+
317
+ def visit_class(self, node):
318
+ """check module name, docstring and redefinition
319
+ increment branch counter
320
+ """
321
+ self.stats['class'] += 1
322
+
323
+ def visit_discard(self, node):
324
+ """check for various kind of statements without effect"""
325
+ expr = node.value
326
+ if isinstance(expr, astng.Const) and isinstance(expr.value, basestring):
327
+ # treat string statement in a separated message
328
+ self.add_message('W0105', node=node)
329
+ return
330
+ # ignore if this is :
331
+ # * a function call (can't predicate side effects)
332
+ # * the unique children of a try/except body
333
+ # * a yield (which are wrapped by a discard node in _ast XXX)
334
+ if not (any(expr.nodes_of_class((astng.CallFunc, astng.Yield)))
335
+ or isinstance(node.parent, astng.TryExcept) and node.parent.body == [node]):
336
+ self.add_message('W0104', node=node)
337
+
338
+ def visit_lambda(self, node):
339
+ """check whether or not the lambda is suspicious
340
+ """
341
+ # if the body of the lambda is a call expression with the same
342
+ # argument list as the lambda itself, then the lambda is
343
+ # possibly unnecessary and at least suspicious.
344
+ if node.args.defaults:
345
+ # If the arguments of the lambda include defaults, then a
346
+ # judgment cannot be made because there is no way to check
347
+ # that the defaults defined by the lambda are the same as
348
+ # the defaults defined by the function called in the body
349
+ # of the lambda.
350
+ return
351
+ call = node.body
352
+ if not isinstance(call, astng.CallFunc):
353
+ # The body of the lambda must be a function call expression
354
+ # for the lambda to be unnecessary.
355
+ return
356
+ # XXX are lambda still different with astng >= 0.18 ?
357
+ # *args and **kwargs need to be treated specially, since they
358
+ # are structured differently between the lambda and the function
359
+ # call (in the lambda they appear in the args.args list and are
360
+ # indicated as * and ** by two bits in the lambda's flags, but
361
+ # in the function call they are omitted from the args list and
362
+ # are indicated by separate attributes on the function call node).
363
+ ordinary_args = list(node.args.args)
364
+ if node.args.kwarg:
365
+ if (not call.kwargs
366
+ or not isinstance(call.kwargs, astng.Name)
367
+ or node.args.kwarg != call.kwargs.name):
368
+ return
369
+ elif call.kwargs:
370
+ return
371
+ if node.args.vararg:
372
+ if (not call.starargs
373
+ or not isinstance(call.starargs, astng.Name)
374
+ or node.args.vararg != call.starargs.name):
375
+ return
376
+ elif call.starargs:
377
+ return
378
+ # The "ordinary" arguments must be in a correspondence such that:
379
+ # ordinary_args[i].name == call.args[i].name.
380
+ if len(ordinary_args) != len(call.args):
381
+ return
382
+ for i in xrange(len(ordinary_args)):
383
+ if not isinstance(call.args[i], astng.Name):
384
+ return
385
+ if node.args.args[i].name != call.args[i].name:
386
+ return
387
+ self.add_message('W0108', line=node.fromlineno, node=node)
388
+
389
+ def visit_function(self, node):
390
+ """check function name, docstring, arguments, redefinition,
391
+ variable names, max locals
392
+ """
393
+ self.stats[node.is_method() and 'method' or 'function'] += 1
394
+ # check default arguments'value
395
+ self._check_defaults(node)
396
+
397
+ def visit_return(self, node):
398
+ """1 - check is the node has a right sibling (if so, that's some
399
+ unreachable code)
400
+ 2 - check is the node is inside the finally clause of a try...finally
401
+ block
402
+ """
403
+ self._check_unreachable(node)
404
+ # Is it inside final body of a try...finally bloc ?
405
+ self._check_not_in_finally(node, 'return', (astng.Function,))
406
+
407
+ def visit_continue(self, node):
408
+ """check is the node has a right sibling (if so, that's some unreachable
409
+ code)
410
+ """
411
+ self._check_unreachable(node)
412
+
413
+ def visit_break(self, node):
414
+ """1 - check is the node has a right sibling (if so, that's some
415
+ unreachable code)
416
+ 2 - check is the node is inside the finally clause of a try...finally
417
+ block
418
+ """
419
+ # 1 - Is it right sibling ?
420
+ self._check_unreachable(node)
421
+ # 2 - Is it inside final body of a try...finally bloc ?
422
+ self._check_not_in_finally(node, 'break', (astng.For, astng.While,))
423
+
424
+ def visit_raise(self, node):
425
+ """check is the node has a right sibling (if so, that's some unreachable
426
+ code)
427
+ """
428
+ self._check_unreachable(node)
429
+
430
+ def visit_exec(self, node):
431
+ """just print a warning on exec statements"""
432
+ self.add_message('W0122', node=node)
433
+
434
+ def visit_callfunc(self, node):
435
+ """visit a CallFunc node -> check if this is not a blacklisted builtin
436
+ call and check for * or ** use
437
+ """
438
+ if isinstance(node.func, astng.Name):
439
+ name = node.func.name
440
+ # ignore the name if it's not a builtin (i.e. not defined in the
441
+ # locals nor globals scope)
442
+ if not (node.frame().has_key(name) or
443
+ node.root().has_key(name)):
444
+ if name in self.config.bad_functions:
445
+ self.add_message('W0141', node=node, args=name)
446
+ if node.starargs or node.kwargs:
447
+ scope = node.scope()
448
+ if isinstance(scope, astng.Function):
449
+ toprocess = [(n, vn) for (n, vn) in ((node.starargs, scope.args.vararg),
450
+ (node.kwargs, scope.args.kwarg)) if n]
451
+ if toprocess:
452
+ for cfnode, fargname in toprocess[:]:
453
+ if getattr(cfnode, 'name', None) == fargname:
454
+ toprocess.remove((cfnode, fargname))
455
+ if not toprocess:
456
+ return # W0142 can be skipped
457
+ self.add_message('W0142', node=node.func)
458
+
459
+ def visit_assert(self, node):
460
+ """check the use of an assert statement on a tuple."""
461
+ if node.fail is None and isinstance(node.test, astng.Tuple) and \
462
+ len(node.test.elts) == 2:
463
+ self.add_message('W0199', line=node.fromlineno, node=node)
464
+
465
+ def visit_dict(self, node):
466
+ """check duplicate key in dictionary"""
467
+ keys = set()
468
+ for k, v in node.items:
469
+ if isinstance(k, astng.Const):
470
+ key = k.value
471
+ if key in keys:
472
+ self.add_message('W0109', node=node, args=key)
473
+ keys.add(key)
474
+
475
+ def visit_tryfinally(self, node):
476
+ """update try...finally flag"""
477
+ self._tryfinallys.append(node)
478
+
479
+ def leave_tryfinally(self, node):
480
+ """update try...finally flag"""
481
+ self._tryfinallys.pop()
482
+
483
+
484
+ def _check_unreachable(self, node):
485
+ """check unreachable code"""
486
+ unreach_stmt = node.next_sibling()
487
+ if unreach_stmt is not None:
488
+ self.add_message('W0101', node=unreach_stmt)
489
+
490
+ def _check_defaults(self, node):
491
+ """check for dangerous default values as arguments"""
492
+ for default in node.args.defaults:
493
+ try:
494
+ value = default.infer().next()
495
+ except astng.InferenceError:
496
+ continue
497
+ if isinstance(value, (astng.Dict, astng.List)):
498
+ if value is default:
499
+ msg = default.as_string()
500
+ else:
501
+ msg = '%s (%s)' % (default.as_string(), value.as_string())
502
+ self.add_message('W0102', node=node, args=(msg,))
503
+
504
+ def _check_required_attributes(self, node, attributes):
505
+ """check for required attributes"""
506
+ for attr in attributes:
507
+ if not node.has_key(attr):
508
+ self.add_message('C0121', node=node, args=attr)
509
+
510
+ def _check_not_in_finally(self, node, node_name, breaker_classes=()):
511
+ """check that a node is not inside a finally clause of a
512
+ try...finally statement.
513
+ If we found before a try...finally bloc a parent which its type is
514
+ in breaker_classes, we skip the whole check."""
515
+ # if self._tryfinallys is empty, we're not a in try...finally bloc
516
+ if not self._tryfinallys:
517
+ return
518
+ # the node could be a grand-grand...-children of the try...finally
519
+ _parent = node.parent
520
+ _node = node
521
+ while _parent and not isinstance(_parent, breaker_classes):
522
+ if hasattr(_parent, 'finalbody') and _node in _parent.finalbody:
523
+ self.add_message('W0150', node=node, args=node_name)
524
+ return
525
+ _node = _parent
526
+ _parent = _node.parent
527
+
528
+
529
+
530
+ class NameChecker(_BasicChecker):
531
+ msgs = {
532
+ 'C0102': ('Black listed name "%s"',
533
+ 'Used when the name is listed in the black list (unauthorized \
534
+ names).'),
535
+ 'C0103': ('Invalid name "%s" (should match %s)',
536
+ 'Used when the name doesn\'t match the regular expression \
537
+ associated to its type (constant, variable, class...).'),
538
+
539
+ }
540
+ options = (('module-rgx',
541
+ {'default' : MOD_NAME_RGX,
542
+ 'type' :'regexp', 'metavar' : '<regexp>',
543
+ 'help' : 'Regular expression which should only match correct '
544
+ 'module names'}
545
+ ),
546
+ ('const-rgx',
547
+ {'default' : CONST_NAME_RGX,
548
+ 'type' :'regexp', 'metavar' : '<regexp>',
549
+ 'help' : 'Regular expression which should only match correct '
550
+ 'module level names'}
551
+ ),
552
+ ('class-rgx',
553
+ {'default' : CLASS_NAME_RGX,
554
+ 'type' :'regexp', 'metavar' : '<regexp>',
555
+ 'help' : 'Regular expression which should only match correct '
556
+ 'class names'}
557
+ ),
558
+ ('function-rgx',
559
+ {'default' : DEFAULT_NAME_RGX,
560
+ 'type' :'regexp', 'metavar' : '<regexp>',
561
+ 'help' : 'Regular expression which should only match correct '
562
+ 'function names'}
563
+ ),
564
+ ('method-rgx',
565
+ {'default' : DEFAULT_NAME_RGX,
566
+ 'type' :'regexp', 'metavar' : '<regexp>',
567
+ 'help' : 'Regular expression which should only match correct '
568
+ 'method names'}
569
+ ),
570
+ ('attr-rgx',
571
+ {'default' : DEFAULT_NAME_RGX,
572
+ 'type' :'regexp', 'metavar' : '<regexp>',
573
+ 'help' : 'Regular expression which should only match correct '
574
+ 'instance attribute names'}
575
+ ),
576
+ ('argument-rgx',
577
+ {'default' : DEFAULT_NAME_RGX,
578
+ 'type' :'regexp', 'metavar' : '<regexp>',
579
+ 'help' : 'Regular expression which should only match correct '
580
+ 'argument names'}),
581
+ ('variable-rgx',
582
+ {'default' : DEFAULT_NAME_RGX,
583
+ 'type' :'regexp', 'metavar' : '<regexp>',
584
+ 'help' : 'Regular expression which should only match correct '
585
+ 'variable names'}
586
+ ),
587
+ ('inlinevar-rgx',
588
+ {'default' : COMP_VAR_RGX,
589
+ 'type' :'regexp', 'metavar' : '<regexp>',
590
+ 'help' : 'Regular expression which should only match correct '
591
+ 'list comprehension / generator expression variable \
592
+ names'}
593
+ ),
594
+ # XXX use set
595
+ ('good-names',
596
+ {'default' : ('i', 'j', 'k', 'ex', 'Run', '_'),
597
+ 'type' :'csv', 'metavar' : '<names>',
598
+ 'help' : 'Good variable names which should always be accepted,'
599
+ ' separated by a comma'}
600
+ ),
601
+ ('bad-names',
602
+ {'default' : ('foo', 'bar', 'baz', 'toto', 'tutu', 'tata'),
603
+ 'type' :'csv', 'metavar' : '<names>',
604
+ 'help' : 'Bad variable names which should always be refused, '
605
+ 'separated by a comma'}
606
+ ),
607
+ )
608
+
609
+ def open(self):
610
+ self.stats = self.linter.add_stats(badname_module=0,
611
+ badname_class=0, badname_function=0,
612
+ badname_method=0, badname_attr=0,
613
+ badname_const=0,
614
+ badname_variable=0,
615
+ badname_inlinevar=0,
616
+ badname_argument=0)
617
+
618
+ def visit_module(self, node):
619
+ self._check_name('module', node.name.split('.')[-1], node)
620
+
621
+ def visit_class(self, node):
622
+ self._check_name('class', node.name, node)
623
+ for attr, anodes in node.instance_attrs.items():
624
+ self._check_name('attr', attr, anodes[0])
625
+
626
+ def visit_function(self, node):
627
+ self._check_name(node.is_method() and 'method' or 'function',
628
+ node.name, node)
629
+ # check arguments name
630
+ args = node.args.args
631
+ if args is not None:
632
+ self._recursive_check_names(args, node)
633
+
634
+ def visit_assname(self, node):
635
+ """check module level assigned names"""
636
+ frame = node.frame()
637
+ ass_type = node.ass_type()
638
+ if isinstance(ass_type, (astng.Comprehension, astng.Comprehension)):
639
+ self._check_name('inlinevar', node.name, node)
640
+ elif isinstance(frame, astng.Module):
641
+ if isinstance(ass_type, astng.Assign) and not in_loop(ass_type):
642
+ self._check_name('const', node.name, node)
643
+ elif isinstance(frame, astng.Function):
644
+ # global introduced variable aren't in the function locals
645
+ if node.name in frame:
646
+ self._check_name('variable', node.name, node)
647
+
648
+ def _recursive_check_names(self, args, node):
649
+ """check names in a possibly recursive list <arg>"""
650
+ for arg in args:
651
+ #if type(arg) is type(''):
652
+ if isinstance(arg, astng.AssName):
653
+ self._check_name('argument', arg.name, node)
654
+ else:
655
+ self._recursive_check_names(arg.elts, node)
656
+
657
+ def _check_name(self, node_type, name, node):
658
+ """check for a name using the type's regexp"""
659
+ if name in self.config.good_names:
660
+ return
661
+ if name in self.config.bad_names:
662
+ self.stats['badname_' + node_type] += 1
663
+ self.add_message('C0102', node=node, args=name)
664
+ return
665
+ regexp = getattr(self.config, node_type + '_rgx')
666
+ if regexp.match(name) is None:
667
+ self.add_message('C0103', node=node, args=(name, regexp.pattern))
668
+ self.stats['badname_' + node_type] += 1
669
+
670
+
671
+
672
+ class DocStringChecker(_BasicChecker):
673
+ msgs = {
674
+ 'C0111': ('Missing docstring', # W0131
675
+ 'Used when a module, function, class or method has no docstring.\
676
+ Some special methods like __init__ doesn\'t necessary require a \
677
+ docstring.'),
678
+ 'C0112': ('Empty docstring', # W0132
679
+ 'Used when a module, function, class or method has an empty \
680
+ docstring (it would be too easy ;).'),
681
+ }
682
+ options = (('no-docstring-rgx',
683
+ {'default' : NO_REQUIRED_DOC_RGX,
684
+ 'type' : 'regexp', 'metavar' : '<regexp>',
685
+ 'help' : 'Regular expression which should only match '
686
+ 'functions or classes name which do not require a '
687
+ 'docstring'}
688
+ ),
689
+ )
690
+
691
+ def open(self):
692
+ self.stats = self.linter.add_stats(undocumented_module=0,
693
+ undocumented_function=0,
694
+ undocumented_method=0,
695
+ undocumented_class=0)
696
+
697
+ def visit_module(self, node):
698
+ self._check_docstring('module', node)
699
+
700
+ def visit_class(self, node):
701
+ if self.config.no_docstring_rgx.match(node.name) is None:
702
+ self._check_docstring('class', node)
703
+
704
+ def visit_function(self, node):
705
+ if self.config.no_docstring_rgx.match(node.name) is None:
706
+ ftype = node.is_method() and 'method' or 'function'
707
+ if isinstance(node.parent.frame(), astng.Class):
708
+ overridden = False
709
+ # check if node is from a method overridden by its ancestor
710
+ for ancestor in node.parent.frame().ancestors():
711
+ if node.name in ancestor and \
712
+ isinstance(ancestor[node.name], astng.Function):
713
+ overridden = True
714
+ break
715
+ if not overridden:
716
+ self._check_docstring(ftype, node)
717
+ else:
718
+ self._check_docstring(ftype, node)
719
+
720
+ def _check_docstring(self, node_type, node):
721
+ """check the node has a non empty docstring"""
722
+ docstring = node.doc
723
+ if docstring is None:
724
+ self.stats['undocumented_'+node_type] += 1
725
+ self.add_message('C0111', node=node)
726
+ elif not docstring.strip():
727
+ self.stats['undocumented_'+node_type] += 1
728
+ self.add_message('C0112', node=node)
729
+
730
+
731
+ class PassChecker(_BasicChecker):
732
+ """check is the pass statement is really necessary"""
733
+ msgs = {'W0107': ('Unnecessary pass statement',
734
+ 'Used when a "pass" statement that can be avoided is '
735
+ 'encountered.)'),
736
+ }
737
+
738
+ def visit_pass(self, node):
739
+ if len(node.parent.child_sequence(node)) > 1:
740
+ self.add_message('W0107', node=node)
741
+
742
+
743
+ def register(linter):
744
+ """required method to auto register this checker"""
745
+ linter.register_checker(BasicErrorChecker(linter))
746
+ linter.register_checker(BasicChecker(linter))
747
+ linter.register_checker(NameChecker(linter))
748
+ linter.register_checker(DocStringChecker(linter))
749
+ linter.register_checker(PassChecker(linter))