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,909 @@
1
+ #
2
+ # epydoc.html: HTML colorizers
3
+ # Edward Loper
4
+ #
5
+ # Created [10/16/02 09:49 PM]
6
+ # $Id: html_colorize.py,v 1.1 2009/11/26 13:20:45 casa Exp $
7
+ #
8
+
9
+ """
10
+ Functions to produce colorized HTML code for various objects.
11
+ Currently, C{html_colorize} defines functions to colorize
12
+ Python source code.
13
+ """
14
+ __docformat__ = 'epytext en'
15
+
16
+ import re, codecs
17
+ from epydoc import log
18
+ from epydoc.util import py_src_filename
19
+ from epydoc.apidoc import *
20
+ import tokenize, token, cgi, keyword
21
+ try: from cStringIO import StringIO
22
+ except: from StringIO import StringIO
23
+
24
+ ######################################################################
25
+ ## Python source colorizer
26
+ ######################################################################
27
+ """
28
+ Goals:
29
+ - colorize tokens appropriately (using css)
30
+ - optionally add line numbers
31
+ -
32
+ """
33
+
34
+ #: Javascript code for the PythonSourceColorizer
35
+ PYSRC_JAVASCRIPTS = '''\
36
+ function expand(id) {
37
+ var elt = document.getElementById(id+"-expanded");
38
+ if (elt) elt.style.display = "block";
39
+ var elt = document.getElementById(id+"-expanded-linenums");
40
+ if (elt) elt.style.display = "block";
41
+ var elt = document.getElementById(id+"-collapsed");
42
+ if (elt) { elt.innerHTML = ""; elt.style.display = "none"; }
43
+ var elt = document.getElementById(id+"-collapsed-linenums");
44
+ if (elt) { elt.innerHTML = ""; elt.style.display = "none"; }
45
+ var elt = document.getElementById(id+"-toggle");
46
+ if (elt) { elt.innerHTML = "-"; }
47
+ }
48
+
49
+ function collapse(id) {
50
+ var elt = document.getElementById(id+"-expanded");
51
+ if (elt) elt.style.display = "none";
52
+ var elt = document.getElementById(id+"-expanded-linenums");
53
+ if (elt) elt.style.display = "none";
54
+ var elt = document.getElementById(id+"-collapsed-linenums");
55
+ if (elt) { elt.innerHTML = "<br />"; elt.style.display="block"; }
56
+ var elt = document.getElementById(id+"-toggle");
57
+ if (elt) { elt.innerHTML = "+"; }
58
+ var elt = document.getElementById(id+"-collapsed");
59
+ if (elt) {
60
+ elt.style.display = "block";
61
+
62
+ var indent = elt.getAttribute("indent");
63
+ var pad = elt.getAttribute("pad");
64
+ var s = "<tt class=\'py-lineno\'>";
65
+ for (var i=0; i<pad.length; i++) { s += "&nbsp;" }
66
+ s += "</tt>";
67
+ s += "&nbsp;&nbsp;<tt class=\'py-line\'>";
68
+ for (var i=0; i<indent.length; i++) { s += "&nbsp;" }
69
+ s += "<a href=\'#\' onclick=\'expand(\\"" + id;
70
+ s += "\\");return false\'>...</a></tt><br />";
71
+ elt.innerHTML = s;
72
+ }
73
+ }
74
+
75
+ function toggle(id) {
76
+ elt = document.getElementById(id+"-toggle");
77
+ if (elt.innerHTML == "-")
78
+ collapse(id);
79
+ else
80
+ expand(id);
81
+ return false;
82
+ }
83
+
84
+ function highlight(id) {
85
+ var elt = document.getElementById(id+"-def");
86
+ if (elt) elt.className = "py-highlight-hdr";
87
+ var elt = document.getElementById(id+"-expanded");
88
+ if (elt) elt.className = "py-highlight";
89
+ var elt = document.getElementById(id+"-collapsed");
90
+ if (elt) elt.className = "py-highlight";
91
+ }
92
+
93
+ function num_lines(s) {
94
+ var n = 1;
95
+ var pos = s.indexOf("\\n");
96
+ while ( pos > 0) {
97
+ n += 1;
98
+ pos = s.indexOf("\\n", pos+1);
99
+ }
100
+ return n;
101
+ }
102
+
103
+ // Collapse all blocks that mave more than `min_lines` lines.
104
+ function collapse_all(min_lines) {
105
+ var elts = document.getElementsByTagName("div");
106
+ for (var i=0; i<elts.length; i++) {
107
+ var elt = elts[i];
108
+ var split = elt.id.indexOf("-");
109
+ if (split > 0)
110
+ if (elt.id.substring(split, elt.id.length) == "-expanded")
111
+ if (num_lines(elt.innerHTML) > min_lines)
112
+ collapse(elt.id.substring(0, split));
113
+ }
114
+ }
115
+
116
+ function expandto(href) {
117
+ var start = href.indexOf("#")+1;
118
+ if (start != 0 && start != href.length) {
119
+ if (href.substring(start, href.length) != "-") {
120
+ collapse_all(4);
121
+ pos = href.indexOf(".", start);
122
+ while (pos != -1) {
123
+ var id = href.substring(start, pos);
124
+ expand(id);
125
+ pos = href.indexOf(".", pos+1);
126
+ }
127
+ var id = href.substring(start, href.length);
128
+ expand(id);
129
+ highlight(id);
130
+ }
131
+ }
132
+ }
133
+
134
+ function kill_doclink(id) {
135
+ var parent = document.getElementById(id);
136
+ parent.removeChild(parent.childNodes.item(0));
137
+ }
138
+ function auto_kill_doclink(ev) {
139
+ if (!ev) var ev = window.event;
140
+ if (!this.contains(ev.toElement)) {
141
+ var parent = document.getElementById(this.parentID);
142
+ parent.removeChild(parent.childNodes.item(0));
143
+ }
144
+ }
145
+
146
+ function doclink(id, name, targets_id) {
147
+ var elt = document.getElementById(id);
148
+
149
+ // If we already opened the box, then destroy it.
150
+ // (This case should never occur, but leave it in just in case.)
151
+ if (elt.childNodes.length > 1) {
152
+ elt.removeChild(elt.childNodes.item(0));
153
+ }
154
+ else {
155
+ // The outer box: relative + inline positioning.
156
+ var box1 = document.createElement("div");
157
+ box1.style.position = "relative";
158
+ box1.style.display = "inline";
159
+ box1.style.top = 0;
160
+ box1.style.left = 0;
161
+
162
+ // A shadow for fun
163
+ var shadow = document.createElement("div");
164
+ shadow.style.position = "absolute";
165
+ shadow.style.left = "-1.3em";
166
+ shadow.style.top = "-1.3em";
167
+ shadow.style.background = "#404040";
168
+
169
+ // The inner box: absolute positioning.
170
+ var box2 = document.createElement("div");
171
+ box2.style.position = "relative";
172
+ box2.style.border = "1px solid #a0a0a0";
173
+ box2.style.left = "-.2em";
174
+ box2.style.top = "-.2em";
175
+ box2.style.background = "white";
176
+ box2.style.padding = ".3em .4em .3em .4em";
177
+ box2.style.fontStyle = "normal";
178
+ box2.onmouseout=auto_kill_doclink;
179
+ box2.parentID = id;
180
+
181
+ // Get the targets
182
+ var targets_elt = document.getElementById(targets_id);
183
+ var targets = targets_elt.getAttribute("targets");
184
+ var links = "";
185
+ target_list = targets.split(",");
186
+ for (var i=0; i<target_list.length; i++) {
187
+ var target = target_list[i].split("=");
188
+ links += "<li><a href=\'" + target[1] +
189
+ "\' style=\'text-decoration:none\'>" +
190
+ target[0] + "</a></li>";
191
+ }
192
+
193
+ // Put it all together.
194
+ elt.insertBefore(box1, elt.childNodes.item(0));
195
+ //box1.appendChild(box2);
196
+ box1.appendChild(shadow);
197
+ shadow.appendChild(box2);
198
+ box2.innerHTML =
199
+ "Which <b>"+name+"</b> do you want to see documentation for?" +
200
+ "<ul style=\'margin-bottom: 0;\'>" +
201
+ links +
202
+ "<li><a href=\'#\' style=\'text-decoration:none\' " +
203
+ "onclick=\'kill_doclink(\\""+id+"\\");return false;\'>"+
204
+ "<i>None of the above</i></a></li></ul>";
205
+ }
206
+ return false;
207
+ }
208
+ '''
209
+
210
+ PYSRC_EXPANDTO_JAVASCRIPT = '''\
211
+ <script type="text/javascript">
212
+ <!--
213
+ expandto(location.href);
214
+ // -->
215
+ </script>
216
+ '''
217
+
218
+ class PythonSourceColorizer:
219
+ """
220
+ A class that renders a python module's source code into HTML
221
+ pages. These HTML pages are intended to be provided along with
222
+ the API documentation for a module, in case a user wants to learn
223
+ more about a particular object by examining its source code.
224
+ Links are therefore generated from the API documentation to the
225
+ source code pages, and from the source code pages back into the
226
+ API documentation.
227
+
228
+ The HTML generated by C{PythonSourceColorizer} has several notable
229
+ features:
230
+
231
+ - CSS styles are used to color tokens according to their type.
232
+ (See L{CSS_CLASSES} for a list of the different token types
233
+ that are identified).
234
+
235
+ - Line numbers are included to the left of each line.
236
+
237
+ - The first line of each class and function definition includes
238
+ a link to the API source documentation for that object.
239
+
240
+ - The first line of each class and function definition includes
241
+ an anchor that can be used to link directly to that class or
242
+ function.
243
+
244
+ - If javascript is enabled, and the page is loaded using the
245
+ anchor for a class or function (i.e., if the url ends in
246
+ C{'#I{<name>}'}), then that class or function will automatically
247
+ be highlighted; and all other classes and function definition
248
+ blocks will be 'collapsed'. These collapsed blocks can be
249
+ expanded by clicking on them.
250
+
251
+ - Unicode input is supported (including automatic detection
252
+ of C{'coding:'} declarations).
253
+
254
+ """
255
+ #: A look-up table that is used to determine which CSS class
256
+ #: should be used to colorize a given token. The following keys
257
+ #: may be used:
258
+ #: - Any token name (e.g., C{'STRING'})
259
+ #: - Any operator token (e.g., C{'='} or C{'@'}).
260
+ #: - C{'KEYWORD'} -- Python keywords such as C{'for'} and C{'if'}
261
+ #: - C{'DEFNAME'} -- the name of a class or function at the top
262
+ #: of its definition statement.
263
+ #: - C{'BASECLASS'} -- names of base classes at the top of a class
264
+ #: definition statement.
265
+ #: - C{'PARAM'} -- function parameters
266
+ #: - C{'DOCSTRING'} -- docstrings
267
+ #: - C{'DECORATOR'} -- decorator names
268
+ #: If no CSS class can be found for a given token, then it won't
269
+ #: be marked with any CSS class.
270
+ CSS_CLASSES = {
271
+ 'NUMBER': 'py-number',
272
+ 'STRING': 'py-string',
273
+ 'COMMENT': 'py-comment',
274
+ 'NAME': 'py-name',
275
+ 'KEYWORD': 'py-keyword',
276
+ 'DEFNAME': 'py-def-name',
277
+ 'BASECLASS': 'py-base-class',
278
+ 'PARAM': 'py-param',
279
+ 'DOCSTRING': 'py-docstring',
280
+ 'DECORATOR': 'py-decorator',
281
+ 'OP': 'py-op',
282
+ '@': 'py-decorator',
283
+ }
284
+
285
+ #: HTML code for the beginning of a collapsable function or class
286
+ #: definition block. The block contains two <div>...</div>
287
+ #: elements -- a collapsed version and an expanded version -- and
288
+ #: only one of these elements is visible at any given time. By
289
+ #: default, all definition blocks are expanded.
290
+ #:
291
+ #: This string should be interpolated with the following values::
292
+ #: (name, indentation, name)
293
+ #: Where C{name} is the anchor name for the function or class; and
294
+ #: indentation is a string of whitespace used to indent the
295
+ #: ellipsis marker in the collapsed version.
296
+ START_DEF_BLOCK = (
297
+ '<div id="%s-collapsed" style="display:none;" '
298
+ 'pad="%s" indent="%s"></div>'
299
+ '<div id="%s-expanded">')
300
+
301
+ #: HTML code for the end of a collapsable function or class
302
+ #: definition block.
303
+ END_DEF_BLOCK = '</div>'
304
+
305
+ #: A regular expression used to pick out the unicode encoding for
306
+ #: the source file.
307
+ UNICODE_CODING_RE = re.compile(r'.*?\n?.*?coding[:=]\s*([-\w.]+)')
308
+
309
+ #: A configuration constant, used to determine whether or not to add
310
+ #: collapsable <div> elements for definition blocks.
311
+ ADD_DEF_BLOCKS = True
312
+
313
+ #: A configuration constant, used to determine whether or not to
314
+ #: add line numbers.
315
+ ADD_LINE_NUMBERS = True
316
+
317
+ #: A configuration constant, used to determine whether or not to
318
+ #: add tooltips for linked names.
319
+ ADD_TOOLTIPS = True
320
+
321
+ #: If true, then try to guess which target is appropriate for
322
+ #: linked names; if false, then always open a div asking the
323
+ #: user which one they want.
324
+ GUESS_LINK_TARGETS = False
325
+
326
+ def __init__(self, module_filename, module_name,
327
+ docindex=None, url_func=None, name_to_docs=None,
328
+ tab_width=8):
329
+ """
330
+ Create a new HTML colorizer for the specified module.
331
+
332
+ @param module_filename: The name of the file containing the
333
+ module; its text will be loaded from this file.
334
+ @param module_name: The dotted name of the module; this will
335
+ be used to create links back into the API source
336
+ documentation.
337
+ """
338
+ # Get the source version, if possible.
339
+ try: module_filename = py_src_filename(module_filename)
340
+ except: pass
341
+
342
+ #: The filename of the module we're colorizing.
343
+ self.module_filename = module_filename
344
+
345
+ #: The dotted name of the module we're colorizing.
346
+ self.module_name = module_name
347
+
348
+ #: A docindex, used to create href links from identifiers to
349
+ #: the API documentation for their values.
350
+ self.docindex = docindex
351
+
352
+ #: A mapping from short names to lists of ValueDoc, used to
353
+ #: decide which values an identifier might map to when creating
354
+ #: href links from identifiers to the API docs for their values.
355
+ self.name_to_docs = name_to_docs
356
+
357
+ #: A function that maps APIDoc -> URL, used to create href
358
+ #: links from identifiers to the API documentation for their
359
+ #: values.
360
+ self.url_func = url_func
361
+
362
+ #: The index in C{text} of the last character of the last
363
+ #: token we've processed.
364
+ self.pos = 0
365
+
366
+ #: A list that maps line numbers to character offsets in
367
+ #: C{text}. In particular, line C{M{i}} begins at character
368
+ #: C{line_offset[i]} in C{text}. Since line numbers begin at
369
+ #: 1, the first element of C{line_offsets} is C{None}.
370
+ self.line_offsets = []
371
+
372
+ #: A list of C{(toktype, toktext)} for all tokens on the
373
+ #: logical line that we are currently processing. Once a
374
+ #: complete line of tokens has been collected in C{cur_line},
375
+ #: it is sent to L{handle_line} for processing.
376
+ self.cur_line = []
377
+
378
+ #: A list of the names of the class or functions that include
379
+ #: the current block. C{context} has one element for each
380
+ #: level of indentation; C{context[i]} is the name of the class
381
+ #: or function defined by the C{i}th level of indentation, or
382
+ #: C{None} if that level of indentation doesn't correspond to a
383
+ #: class or function definition.
384
+ self.context = []
385
+
386
+ #: A list, corresponding one-to-one with L{self.context},
387
+ #: indicating the type of each entry. Each element of
388
+ #: C{context_types} is one of: C{'func'}, C{'class'}, C{None}.
389
+ self.context_types = []
390
+
391
+ #: A list of indentation strings for each of the current
392
+ #: block's indents. I.e., the current total indentation can
393
+ #: be found by taking C{''.join(self.indents)}.
394
+ self.indents = []
395
+
396
+ #: The line number of the line we're currently processing.
397
+ self.lineno = 0
398
+
399
+ #: The name of the class or function whose definition started
400
+ #: on the previous logical line, or C{None} if the previous
401
+ #: logical line was not a class or function definition.
402
+ self.def_name = None
403
+
404
+ #: The type of the class or function whose definition started
405
+ #: on the previous logical line, or C{None} if the previous
406
+ #: logical line was not a class or function definition.
407
+ #: Can be C{'func'}, C{'class'}, C{None}.
408
+ self.def_type = None
409
+
410
+ #: The number of spaces to replace each tab in source code with
411
+ self.tab_width = tab_width
412
+
413
+
414
+ def find_line_offsets(self):
415
+ """
416
+ Construct the L{line_offsets} table from C{self.text}.
417
+ """
418
+ # line 0 doesn't exist; line 1 starts at char offset 0.
419
+ self.line_offsets = [None, 0]
420
+ # Find all newlines in `text`, and add an entry to
421
+ # line_offsets for each one.
422
+ pos = self.text.find('\n')
423
+ while pos != -1:
424
+ self.line_offsets.append(pos+1)
425
+ pos = self.text.find('\n', pos+1)
426
+ # Add a final entry, marking the end of the string.
427
+ self.line_offsets.append(len(self.text))
428
+
429
+ def lineno_to_html(self):
430
+ template = '%%%ds' % self.linenum_size
431
+ n = template % self.lineno
432
+ return '<a name="L%s"></a><tt class="py-lineno">%s</tt>' \
433
+ % (self.lineno, n)
434
+
435
+ def colorize(self):
436
+ """
437
+ Return an HTML string that renders the source code for the
438
+ module that was specified in the constructor.
439
+ """
440
+ # Initialize all our state variables
441
+ self.pos = 0
442
+ self.cur_line = []
443
+ self.context = []
444
+ self.context_types = []
445
+ self.indents = []
446
+ self.lineno = 1
447
+ self.def_name = None
448
+ self.def_type = None
449
+ self.has_decorators = False
450
+
451
+ # Cache, used so we only need to list the target elements once
452
+ # for each variable.
453
+ self.doclink_targets_cache = {}
454
+
455
+ # Load the module's text.
456
+ self.text = open(self.module_filename).read()
457
+ self.text = self.text.expandtabs(self.tab_width).rstrip()+'\n'
458
+
459
+ # Construct the line_offsets table.
460
+ self.find_line_offsets()
461
+
462
+ num_lines = self.text.count('\n')+1
463
+ self.linenum_size = len(`num_lines+1`)
464
+
465
+ # Call the tokenizer, and send tokens to our `tokeneater()`
466
+ # method. If anything goes wrong, then fall-back to using
467
+ # the input text as-is (with no colorization).
468
+ try:
469
+ output = StringIO()
470
+ self.out = output.write
471
+ tokenize.tokenize(StringIO(self.text).readline, self.tokeneater)
472
+ html = output.getvalue()
473
+ if self.has_decorators:
474
+ html = self._FIX_DECORATOR_RE.sub(r'\2\1', html)
475
+ except tokenize.TokenError, ex:
476
+ html = self.text
477
+
478
+ # Check for a unicode encoding declaration.
479
+ m = self.UNICODE_CODING_RE.match(self.text)
480
+ if m: coding = m.group(1)
481
+ else: coding = 'iso-8859-1'
482
+
483
+ # Decode the html string into unicode, and then encode it back
484
+ # into ascii, replacing any non-ascii characters with xml
485
+ # character references.
486
+ try:
487
+ html = html.decode(coding).encode('ascii', 'xmlcharrefreplace')
488
+ except LookupError:
489
+ coding = 'iso-8859-1'
490
+ html = html.decode(coding).encode('ascii', 'xmlcharrefreplace')
491
+
492
+ # Call expandto.
493
+ html += PYSRC_EXPANDTO_JAVASCRIPT
494
+
495
+ return html
496
+
497
+ def tokeneater(self, toktype, toktext, (srow,scol), (erow,ecol), line):
498
+ """
499
+ A callback function used by C{tokenize.tokenize} to handle
500
+ each token in the module. C{tokeneater} collects tokens into
501
+ the C{self.cur_line} list until a complete logical line has
502
+ been formed; and then calls L{handle_line} to process that line.
503
+ """
504
+ # If we encounter any errors, then just give up.
505
+ if toktype == token.ERRORTOKEN:
506
+ raise tokenize.TokenError, toktype
507
+
508
+ # Did we skip anything whitespace? If so, add a pseudotoken
509
+ # for it, with toktype=None. (Note -- this skipped string
510
+ # might also contain continuation slashes; but I won't bother
511
+ # to colorize them.)
512
+ startpos = self.line_offsets[srow] + scol
513
+ if startpos > self.pos:
514
+ skipped = self.text[self.pos:startpos]
515
+ self.cur_line.append( (None, skipped) )
516
+
517
+ # Update our position.
518
+ self.pos = startpos + len(toktext)
519
+
520
+ # Update our current line.
521
+ self.cur_line.append( (toktype, toktext) )
522
+
523
+ # When we reach the end of a line, process it.
524
+ if toktype == token.NEWLINE or toktype == token.ENDMARKER:
525
+ self.handle_line(self.cur_line)
526
+ self.cur_line = []
527
+
528
+ _next_uid = 0
529
+
530
+ # [xx] note -- this works with byte strings, not unicode strings!
531
+ # I may change it to use unicode eventually, but when I do it
532
+ # needs to be changed all at once.
533
+ def handle_line(self, line):
534
+ """
535
+ Render a single logical line from the module, and write the
536
+ generated HTML to C{self.out}.
537
+
538
+ @param line: A single logical line, encoded as a list of
539
+ C{(toktype,tokttext)} pairs corresponding to the tokens in
540
+ the line.
541
+ """
542
+ # def_name is the name of the function or class defined by
543
+ # this line; or None if no funciton or class is defined.
544
+ def_name = None
545
+
546
+ # def_type is the type of the function or class defined by
547
+ # this line; or None if no funciton or class is defined.
548
+ def_type = None
549
+
550
+ # does this line start a class/func def?
551
+ starting_def_block = False
552
+
553
+ in_base_list = False
554
+ in_param_list = False
555
+ in_param_default = 0
556
+ at_module_top = (self.lineno == 1)
557
+
558
+ ended_def_blocks = 0
559
+
560
+ # The html output.
561
+ if self.ADD_LINE_NUMBERS:
562
+ s = self.lineno_to_html()
563
+ self.lineno += 1
564
+ else:
565
+ s = ''
566
+ s += ' <tt class="py-line">'
567
+
568
+ # Loop through each token, and colorize it appropriately.
569
+ for i, (toktype, toktext) in enumerate(line):
570
+ if type(s) is not str:
571
+ if type(s) is unicode:
572
+ log.error('While colorizing %s -- got unexpected '
573
+ 'unicode string' % self.module_name)
574
+ s = s.encode('ascii', 'xmlcharrefreplace')
575
+ else:
576
+ raise ValueError('Unexpected value for s -- %s' %
577
+ type(s).__name__)
578
+
579
+ # For each token, determine its css class and whether it
580
+ # should link to a url.
581
+ css_class = None
582
+ url = None
583
+ tooltip = None
584
+ onclick = uid = targets = None # these 3 are used together.
585
+
586
+ # Is this token the class name in a class definition? If
587
+ # so, then make it a link back into the API docs.
588
+ if i>=2 and line[i-2][1] == 'class':
589
+ in_base_list = True
590
+ css_class = self.CSS_CLASSES['DEFNAME']
591
+ def_name = toktext
592
+ def_type = 'class'
593
+ if 'func' not in self.context_types:
594
+ cls_name = self.context_name(def_name)
595
+ url = self.name2url(cls_name)
596
+ s = self.mark_def(s, cls_name)
597
+ starting_def_block = True
598
+
599
+ # Is this token the function name in a function def? If
600
+ # so, then make it a link back into the API docs.
601
+ elif i>=2 and line[i-2][1] == 'def':
602
+ in_param_list = True
603
+ css_class = self.CSS_CLASSES['DEFNAME']
604
+ def_name = toktext
605
+ def_type = 'func'
606
+ if 'func' not in self.context_types:
607
+ cls_name = self.context_name()
608
+ func_name = self.context_name(def_name)
609
+ url = self.name2url(cls_name, def_name)
610
+ s = self.mark_def(s, func_name)
611
+ starting_def_block = True
612
+
613
+ # For each indent, update the indents list (which we use
614
+ # to keep track of indentation strings) and the context
615
+ # list. If this indent is the start of a class or
616
+ # function def block, then self.def_name will be its name;
617
+ # otherwise, it will be None.
618
+ elif toktype == token.INDENT:
619
+ self.indents.append(toktext)
620
+ self.context.append(self.def_name)
621
+ self.context_types.append(self.def_type)
622
+
623
+ # When we dedent, pop the last elements off the indents
624
+ # list and the context list. If the last context element
625
+ # is a name, then we're ending a class or function def
626
+ # block; so write an end-div tag.
627
+ elif toktype == token.DEDENT:
628
+ self.indents.pop()
629
+ self.context_types.pop()
630
+ if self.context.pop():
631
+ ended_def_blocks += 1
632
+
633
+ # If this token contains whitespace, then don't bother to
634
+ # give it a css tag.
635
+ elif toktype in (None, tokenize.NL, token.NEWLINE,
636
+ token.ENDMARKER):
637
+ css_class = None
638
+
639
+ # Check if the token is a keyword.
640
+ elif toktype == token.NAME and keyword.iskeyword(toktext):
641
+ css_class = self.CSS_CLASSES['KEYWORD']
642
+
643
+ elif in_base_list and toktype == token.NAME:
644
+ css_class = self.CSS_CLASSES['BASECLASS']
645
+
646
+ elif (in_param_list and toktype == token.NAME and
647
+ not in_param_default):
648
+ css_class = self.CSS_CLASSES['PARAM']
649
+
650
+ # Class/function docstring.
651
+ elif (self.def_name and line[i-1][0] == token.INDENT and
652
+ self.is_docstring(line, i)):
653
+ css_class = self.CSS_CLASSES['DOCSTRING']
654
+
655
+ # Module docstring.
656
+ elif at_module_top and self.is_docstring(line, i):
657
+ css_class = self.CSS_CLASSES['DOCSTRING']
658
+
659
+ # check for decorators??
660
+ elif (toktype == token.NAME and
661
+ ((i>0 and line[i-1][1]=='@') or
662
+ (i>1 and line[i-1][0]==None and line[i-2][1] == '@'))):
663
+ css_class = self.CSS_CLASSES['DECORATOR']
664
+ self.has_decorators = True
665
+
666
+ # If it's a name, try to link it.
667
+ elif toktype == token.NAME:
668
+ css_class = self.CSS_CLASSES['NAME']
669
+ # If we have a variable named `toktext` in the current
670
+ # context, then link to that. Note that if we're inside
671
+ # a function, then that function is our context, not
672
+ # the namespace that contains it. [xx] this isn't always
673
+ # the right thing to do.
674
+ if (self.GUESS_LINK_TARGETS and self.docindex is not None
675
+ and self.url_func is not None):
676
+ context = [n for n in self.context if n is not None]
677
+ container = self.docindex.get_vardoc(
678
+ DottedName(self.module_name, *context))
679
+ if isinstance(container, NamespaceDoc):
680
+ doc = container.variables.get(toktext)
681
+ if doc is not None:
682
+ url = self.url_func(doc)
683
+ tooltip = str(doc.canonical_name)
684
+ # Otherwise, check the name_to_docs index to see what
685
+ # else this name might refer to.
686
+ if (url is None and self.name_to_docs is not None
687
+ and self.url_func is not None):
688
+ docs = self.name_to_docs.get(toktext)
689
+ if docs:
690
+ tooltip='\n'.join([str(d.canonical_name)
691
+ for d in docs])
692
+ if len(docs) == 1 and self.GUESS_LINK_TARGETS:
693
+ url = self.url_func(docs[0])
694
+ else:
695
+ uid, onclick, targets = self.doclink(toktext, docs)
696
+
697
+ # For all other tokens, look up the CSS class to use
698
+ # based on the token's type.
699
+ else:
700
+ if toktype == token.OP and toktext in self.CSS_CLASSES:
701
+ css_class = self.CSS_CLASSES[toktext]
702
+ elif token.tok_name[toktype] in self.CSS_CLASSES:
703
+ css_class = self.CSS_CLASSES[token.tok_name[toktype]]
704
+ else:
705
+ css_class = None
706
+
707
+ # update our status..
708
+ if toktext == ':':
709
+ in_base_list = False
710
+ in_param_list = False
711
+ if toktext == '=' and in_param_list:
712
+ in_param_default = True
713
+ if in_param_default:
714
+ if toktext in ('(','[','{'): in_param_default += 1
715
+ if toktext in (')',']','}'): in_param_default -= 1
716
+ if toktext == ',' and in_param_default == 1:
717
+ in_param_default = 0
718
+
719
+ # Write this token, with appropriate colorization.
720
+ if tooltip and self.ADD_TOOLTIPS:
721
+ tooltip_html = ' title="%s"' % tooltip
722
+ else: tooltip_html = ''
723
+ if css_class: css_class_html = ' class="%s"' % css_class
724
+ else: css_class_html = ''
725
+ if onclick:
726
+ if targets: targets_html = ' targets="%s"' % targets
727
+ else: targets_html = ''
728
+ s += ('<tt id="%s"%s%s><a%s%s href="#" onclick="%s">' %
729
+ (uid, css_class_html, targets_html, tooltip_html,
730
+ css_class_html, onclick))
731
+ elif url:
732
+ if isinstance(url, unicode):
733
+ url = url.encode('ascii', 'xmlcharrefreplace')
734
+ s += ('<a%s%s href="%s">' %
735
+ (tooltip_html, css_class_html, url))
736
+ elif css_class_html or tooltip_html:
737
+ s += '<tt%s%s>' % (tooltip_html, css_class_html)
738
+ if i == len(line)-1:
739
+ s += ' </tt>' # Closes <tt class="py-line">
740
+ s += cgi.escape(toktext)
741
+ else:
742
+ try:
743
+ s += self.add_line_numbers(cgi.escape(toktext), css_class)
744
+ except Exception, e:
745
+ print (toktext, css_class, toktext.encode('ascii'))
746
+ raise
747
+
748
+ if onclick: s += "</a></tt>"
749
+ elif url: s += '</a>'
750
+ elif css_class_html or tooltip_html: s += '</tt>'
751
+
752
+ if self.ADD_DEF_BLOCKS:
753
+ for i in range(ended_def_blocks):
754
+ self.out(self.END_DEF_BLOCK)
755
+
756
+ # Strip any empty <tt>s.
757
+ s = re.sub(r'<tt class="[\w+]"></tt>', '', s)
758
+
759
+ # Write the line.
760
+ self.out(s)
761
+
762
+ if def_name and starting_def_block:
763
+ self.out('</div>')
764
+
765
+ # Add div's if we're starting a def block.
766
+ if (self.ADD_DEF_BLOCKS and def_name and starting_def_block and
767
+ (line[-2][1] == ':')):
768
+ indentation = (''.join(self.indents)+' ').replace(' ', '+')
769
+ linenum_padding = '+'*self.linenum_size
770
+ name=self.context_name(def_name)
771
+ self.out(self.START_DEF_BLOCK % (name, linenum_padding,
772
+ indentation, name))
773
+
774
+ self.def_name = def_name
775
+ self.def_type = def_type
776
+
777
+ def context_name(self, extra=None):
778
+ pieces = [n for n in self.context if n is not None]
779
+ if extra is not None: pieces.append(extra)
780
+ return '.'.join(pieces)
781
+
782
+ def doclink(self, name, docs):
783
+ uid = 'link-%s' % self._next_uid
784
+ self._next_uid += 1
785
+ context = [n for n in self.context if n is not None]
786
+ container = DottedName(self.module_name, *context)
787
+ #else:
788
+ # container = None
789
+ targets = ','.join(['%s=%s' % (str(self.doc_descr(d,container)),
790
+ str(self.url_func(d)))
791
+ for d in docs])
792
+
793
+ if targets in self.doclink_targets_cache:
794
+ onclick = ("return doclink('%s', '%s', '%s');" %
795
+ (uid, name, self.doclink_targets_cache[targets]))
796
+ return uid, onclick, None
797
+ else:
798
+ self.doclink_targets_cache[targets] = uid
799
+ onclick = ("return doclink('%s', '%s', '%s');" %
800
+ (uid, name, uid))
801
+ return uid, onclick, targets
802
+
803
+ def doc_descr(self, doc, context):
804
+ name = str(doc.canonical_name)
805
+ descr = '%s %s' % (self.doc_kind(doc), name)
806
+ if isinstance(doc, RoutineDoc):
807
+ descr += '()'
808
+ return descr
809
+
810
+ # [XX] copied streight from html.py; this should be consolidated,
811
+ # probably into apidoc.
812
+ def doc_kind(self, doc):
813
+ if isinstance(doc, ModuleDoc) and doc.is_package == True:
814
+ return 'Package'
815
+ elif (isinstance(doc, ModuleDoc) and
816
+ doc.canonical_name[0].startswith('script')):
817
+ return 'Script'
818
+ elif isinstance(doc, ModuleDoc):
819
+ return 'Module'
820
+ elif isinstance(doc, ClassDoc):
821
+ return 'Class'
822
+ elif isinstance(doc, ClassMethodDoc):
823
+ return 'Class Method'
824
+ elif isinstance(doc, StaticMethodDoc):
825
+ return 'Static Method'
826
+ elif isinstance(doc, RoutineDoc):
827
+ if (self.docindex is not None and
828
+ isinstance(self.docindex.container(doc), ClassDoc)):
829
+ return 'Method'
830
+ else:
831
+ return 'Function'
832
+ else:
833
+ return 'Variable'
834
+
835
+ def mark_def(self, s, name):
836
+ replacement = ('<a name="%s"></a><div id="%s-def">\\1'
837
+ '<a class="py-toggle" href="#" id="%s-toggle" '
838
+ 'onclick="return toggle(\'%s\');">-</a>\\2' %
839
+ (name, name, name, name))
840
+ return re.sub('(.*) (<tt class="py-line">.*)\Z', replacement, s)
841
+
842
+ def is_docstring(self, line, i):
843
+ if line[i][0] != token.STRING: return False
844
+ for toktype, toktext in line[i:]:
845
+ if toktype not in (token.NEWLINE, tokenize.COMMENT,
846
+ tokenize.NL, token.STRING, None):
847
+ return False
848
+ return True
849
+
850
+ def add_line_numbers(self, s, css_class):
851
+ result = ''
852
+ start = 0
853
+ end = s.find('\n')+1
854
+ while end:
855
+ result += s[start:end-1]
856
+ if css_class: result += '</tt>'
857
+ result += ' </tt>' # py-line
858
+ result += '\n'
859
+ if self.ADD_LINE_NUMBERS:
860
+ result += self.lineno_to_html()
861
+ result += ' <tt class="py-line">'
862
+ if css_class: result += '<tt class="%s">' % css_class
863
+ start = end
864
+ end = s.find('\n', end)+1
865
+ self.lineno += 1
866
+ result += s[start:]
867
+ return result
868
+
869
+ def name2url(self, class_name, func_name=None):
870
+ if class_name:
871
+ class_name = '%s.%s' % (self.module_name, class_name)
872
+ if func_name:
873
+ return '%s-class.html#%s' % (class_name, func_name)
874
+ else:
875
+ return '%s-class.html' % class_name
876
+ else:
877
+ return '%s-module.html#%s' % (self.module_name, func_name)
878
+
879
+ #: A regexp used to move the <div> that marks the beginning of a
880
+ #: function or method to just before the decorators.
881
+ _FIX_DECORATOR_RE = re.compile(
882
+ r'((?:^<a name="L\d+"></a><tt class="py-lineno">\s*\d+</tt>'
883
+ r'\s*<tt class="py-line">(?:<tt class="py-decorator">.*|\s*</tt>|'
884
+ r'\s*<tt class="py-comment">.*)\n)+)'
885
+ r'(<a name="\w+"></a><div id="\w+-def">)', re.MULTILINE)
886
+
887
+ _HDR = '''\
888
+ <?xml version="1.0" encoding="ascii"?>
889
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
890
+ "DTD/xhtml1-transitional.dtd">
891
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
892
+ <head>
893
+ <title>$title$</title>
894
+ <link rel="stylesheet" href="epydoc.css" type="text/css" />
895
+ <script type="text/javascript" src="epydoc.js"></script>
896
+ </head>
897
+
898
+ <body bgcolor="white" text="black" link="blue" vlink="#204080"
899
+ alink="#204080">
900
+ '''
901
+ _FOOT = '</body></html>'
902
+ if __name__=='__main__':
903
+ #s = PythonSourceColorizer('../apidoc.py', 'epydoc.apidoc').colorize()
904
+ s = PythonSourceColorizer('/tmp/fo.py', 'epydoc.apidoc').colorize()
905
+ #print s
906
+ import codecs
907
+ f = codecs.open('/home/edloper/public_html/color3.html', 'w', 'ascii', 'xmlcharrefreplace')
908
+ f.write(_HDR+'<pre id="py-src-top" class="py-src">'+s+'</pre>'+_FOOT)
909
+ f.close()