exercism-analysis 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. checksums.yaml +7 -0
  2. data/exercism-analysis.gemspec +30 -0
  3. data/lib/exercism-analysis.rb +38 -0
  4. data/lib/exercism-analysis/adapters/adapter.rb +23 -0
  5. data/lib/exercism-analysis/adapters/clojure.rb +13 -0
  6. data/lib/exercism-analysis/adapters/go.rb +19 -0
  7. data/lib/exercism-analysis/adapters/javascript.rb +13 -0
  8. data/lib/exercism-analysis/adapters/python.rb +13 -0
  9. data/lib/exercism-analysis/adapters/ruby.rb +19 -0
  10. data/lib/exercism-analysis/analysis.rb +18 -0
  11. data/lib/exercism-analysis/analyzers/analyzer.rb +54 -0
  12. data/lib/exercism-analysis/analyzers/clojure/kibit.rb +25 -0
  13. data/lib/exercism-analysis/analyzers/go/golint.rb +23 -0
  14. data/lib/exercism-analysis/analyzers/javascript/jslint.rb +24 -0
  15. data/lib/exercism-analysis/analyzers/python/pylint.rb +24 -0
  16. data/lib/exercism-analysis/analyzers/ruby/control_flow.rb +21 -0
  17. data/lib/exercism-analysis/analyzers/ruby/enumerable_condition.rb +21 -0
  18. data/lib/exercism-analysis/analyzers/ruby/for_loop.rb +29 -0
  19. data/lib/exercism-analysis/analyzers/ruby/indentation.rb +21 -0
  20. data/lib/exercism-analysis/analyzers/ruby/iter_mutation.rb +37 -0
  21. data/lib/exercism-analysis/analyzers/ruby/output.rb +20 -0
  22. data/lib/exercism-analysis/analyzers/ruby/range.rb +28 -0
  23. data/lib/exercism-analysis/analyzers/ruby/roodi.rb +19 -0
  24. data/lib/exercism-analysis/analyzers/ruby/send.rb +25 -0
  25. data/lib/exercism-analysis/analyzers/ruby/shebang.rb +23 -0
  26. data/lib/exercism-analysis/analyzers/ruby/tab.rb +38 -0
  27. data/lib/exercism-analysis/processors/call_processor.rb +39 -0
  28. data/lib/exercism-analysis/processors/control_flow_processor.rb +27 -0
  29. data/lib/exercism-analysis/processors/enumerable_condition_processor.rb +31 -0
  30. data/lib/exercism-analysis/processors/for_loop_processor.rb +21 -0
  31. data/lib/exercism-analysis/processors/indentation_processor.rb +69 -0
  32. data/lib/exercism-analysis/processors/iter_mutation_processor.rb +50 -0
  33. data/lib/exercism-analysis/processors/processor.rb +34 -0
  34. data/lib/exercism-analysis/processors/range_processor.rb +23 -0
  35. data/lib/exercism-analysis/processors/send_processor.rb +23 -0
  36. data/lib/exercism-analysis/templates/each_to_map.rb +29 -0
  37. data/lib/exercism-analysis/templates/each_to_select.rb +31 -0
  38. data/lib/exercism-analysis/templates/range_exclusive.rb +19 -0
  39. data/lib/exercism-analysis/templates/template.rb +29 -0
  40. data/vendor/clojure/kibit-runner/LICENSE +214 -0
  41. data/vendor/clojure/kibit-runner/project.clj +10 -0
  42. data/vendor/clojure/kibit-runner/src/kibit_runner/core.clj +17 -0
  43. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT-standalone.jar +0 -0
  44. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT.jar +0 -0
  45. data/vendor/clojure/kibit-runner/target/stale/extract-native.dependencies +1 -0
  46. data/vendor/go/src/github.com/golang/lint/LICENSE +27 -0
  47. data/vendor/go/src/github.com/golang/lint/README +59 -0
  48. data/vendor/go/src/github.com/golang/lint/golint/golint.go +67 -0
  49. data/vendor/go/src/github.com/golang/lint/lint.go +1061 -0
  50. data/vendor/go/src/runner/golint_runner.go +23 -0
  51. data/vendor/javascript/jshint_runner.js +6 -0
  52. data/vendor/javascript/node_modules/jshint/README.md +47 -0
  53. data/vendor/javascript/node_modules/jshint/bin/apply +6 -0
  54. data/vendor/javascript/node_modules/jshint/bin/build +36 -0
  55. data/vendor/javascript/node_modules/jshint/bin/changelog +36 -0
  56. data/vendor/javascript/node_modules/jshint/bin/jshint +3 -0
  57. data/vendor/javascript/node_modules/jshint/bin/land +34 -0
  58. data/vendor/javascript/node_modules/jshint/data/ascii-identifier-data.js +22 -0
  59. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-part-only.js +1570 -0
  60. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-start.js +48477 -0
  61. data/vendor/javascript/node_modules/jshint/dist/jshint-rhino.js +60642 -0
  62. data/vendor/javascript/node_modules/jshint/dist/jshint.js +60525 -0
  63. data/vendor/javascript/node_modules/jshint/node_modules/cli/README.md +196 -0
  64. data/vendor/javascript/node_modules/jshint/node_modules/cli/cli.js +1139 -0
  65. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/cat.js +17 -0
  66. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/command.js +16 -0
  67. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/echo.js +54 -0
  68. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/glob.js +6 -0
  69. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/long_desc.js +20 -0
  70. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/progress.js +11 -0
  71. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/sort.js +18 -0
  72. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/spinner.js +9 -0
  73. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.coffee +27 -0
  74. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.js +25 -0
  75. data/vendor/javascript/node_modules/jshint/node_modules/cli/index.js +1 -0
  76. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/LICENSE +27 -0
  77. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/README.md +250 -0
  78. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/g.js +9 -0
  79. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/usr-local.js +9 -0
  80. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/glob.js +728 -0
  81. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  82. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/README.md +42 -0
  83. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  84. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  85. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/package.json +51 -0
  86. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/test.js +25 -0
  87. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/package.json +58 -0
  88. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/00-setup.js +176 -0
  89. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-comparison.js +63 -0
  90. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-results.json +351 -0
  91. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/cwd-test.js +55 -0
  92. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/globstar-match.js +19 -0
  93. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/mark.js +118 -0
  94. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/new-glob-optional-options.js +10 -0
  95. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/nocase-nomagic.js +113 -0
  96. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/pause-resume.js +73 -0
  97. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/readme-issue.js +36 -0
  98. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root-nomount.js +39 -0
  99. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root.js +46 -0
  100. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/stat.js +32 -0
  101. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/zz-cleanup.js +11 -0
  102. data/vendor/javascript/node_modules/jshint/node_modules/cli/package.json +70 -0
  103. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/LICENCE +19 -0
  104. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/README.md +33 -0
  105. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/index.js +86 -0
  106. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/LICENCE +19 -0
  107. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/README.md +45 -0
  108. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/index.js +5 -0
  109. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/package.json +89 -0
  110. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/seed.js +16 -0
  111. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/index.js +28 -0
  112. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/static/index.html +10 -0
  113. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/package.json +88 -0
  114. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/index.js +67 -0
  115. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/index.html +12 -0
  116. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/test-adapter.js +53 -0
  117. data/vendor/javascript/node_modules/jshint/node_modules/exit/Gruntfile.js +48 -0
  118. data/vendor/javascript/node_modules/jshint/node_modules/exit/LICENSE-MIT +22 -0
  119. data/vendor/javascript/node_modules/jshint/node_modules/exit/README.md +75 -0
  120. data/vendor/javascript/node_modules/jshint/node_modules/exit/lib/exit.js +41 -0
  121. data/vendor/javascript/node_modules/jshint/node_modules/exit/package.json +69 -0
  122. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/exit_test.js +121 -0
  123. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stderr.txt +10 -0
  124. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout-stderr.txt +20 -0
  125. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout.txt +10 -0
  126. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stderr.txt +100 -0
  127. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout-stderr.txt +200 -0
  128. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout.txt +100 -0
  129. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stderr.txt +1000 -0
  130. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout-stderr.txt +2000 -0
  131. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout.txt +1000 -0
  132. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/create-files.sh +8 -0
  133. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log-broken.js +23 -0
  134. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log.js +25 -0
  135. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/LICENSE +18 -0
  136. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/README.md +83 -0
  137. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/CollectingHandler.js +55 -0
  138. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/FeedHandler.js +95 -0
  139. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Parser.js +337 -0
  140. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/ProxyHandler.js +27 -0
  141. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Stream.js +35 -0
  142. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Tokenizer.js +891 -0
  143. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/WritableStream.js +21 -0
  144. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/index.js +68 -0
  145. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/LICENSE +11 -0
  146. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/index.js +14 -0
  147. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/package.json +40 -0
  148. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/readme.md +1 -0
  149. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/LICENSE +11 -0
  150. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/index.js +211 -0
  151. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/package.json +68 -0
  152. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/readme.md +102 -0
  153. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/01-basic.json +57 -0
  154. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  155. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  156. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  157. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  158. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  159. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  160. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  161. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  162. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  163. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  164. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  165. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  166. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  167. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  168. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  169. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  170. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  171. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  172. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  173. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  174. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  175. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/23-dom-lvl1.json +121 -0
  176. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/tests.js +58 -0
  177. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/LICENSE +11 -0
  178. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/index.js +14 -0
  179. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/helpers.js +141 -0
  180. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/legacy.js +87 -0
  181. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/manipulation.js +77 -0
  182. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/querying.js +94 -0
  183. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/stringify.js +93 -0
  184. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/traversal.js +24 -0
  185. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/package.json +71 -0
  186. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/readme.md +1 -0
  187. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/fixture.js +6 -0
  188. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/helpers.js +89 -0
  189. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/legacy.js +119 -0
  190. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/utils.js +9 -0
  191. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/LICENSE +11 -0
  192. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/index.js +31 -0
  193. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode.js +72 -0
  194. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode_codepoint.js +26 -0
  195. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/encode.js +48 -0
  196. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/decode.json +1 -0
  197. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/entities.json +1 -0
  198. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/legacy.json +1 -0
  199. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/xml.json +1 -0
  200. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/package.json +79 -0
  201. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/readme.md +31 -0
  202. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/mocha.opts +2 -0
  203. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/test.js +150 -0
  204. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/LICENSE +18 -0
  205. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/README.md +15 -0
  206. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/duplex.js +1 -0
  207. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/float.patch +923 -0
  208. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
  209. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
  210. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_readable.js +944 -0
  211. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_transform.js +209 -0
  212. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_writable.js +472 -0
  213. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
  214. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
  215. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
  216. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
  217. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
  218. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/LICENSE +16 -0
  219. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/README.md +42 -0
  220. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits.js +1 -0
  221. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits_browser.js +23 -0
  222. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/package.json +51 -0
  223. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/test.js +25 -0
  224. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/README.md +54 -0
  225. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/build/build.js +209 -0
  226. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/component.json +19 -0
  227. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/index.js +3 -0
  228. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/package.json +54 -0
  229. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/LICENSE +20 -0
  230. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/README.md +7 -0
  231. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/index.js +200 -0
  232. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/package.json +53 -0
  233. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/package.json +68 -0
  234. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/passthrough.js +1 -0
  235. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/readable.js +7 -0
  236. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/transform.js +1 -0
  237. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/writable.js +1 -0
  238. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/package.json +90 -0
  239. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/01-events.js +9 -0
  240. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/02-stream.js +23 -0
  241. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/03-feed.js +19 -0
  242. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Atom_Example.xml +25 -0
  243. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Attributes.html +16 -0
  244. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Basic.html +1 -0
  245. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RDF_Example.xml +63 -0
  246. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RSS_Example.xml +48 -0
  247. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/01-simple.json +44 -0
  248. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/02-template.json +63 -0
  249. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/03-lowercase_tags.json +46 -0
  250. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/04-cdata.json +50 -0
  251. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/05-cdata-special.json +35 -0
  252. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/06-leading-lt.json +16 -0
  253. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/07-self-closing.json +67 -0
  254. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/08-implicit-close-tags.json +59 -0
  255. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/09-attributes.json +68 -0
  256. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/10-crazy-attrib.json +52 -0
  257. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/11-script_in_script.json +54 -0
  258. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/12-long-comment-end.json +20 -0
  259. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/13-long-cdata-end.json +22 -0
  260. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/14-implicit-open-tags.json +27 -0
  261. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/15-lt-whitespace.json +16 -0
  262. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/16-double_attribs.json +45 -0
  263. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/17-numeric_entities.json +16 -0
  264. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/18-legacy_entities.json +16 -0
  265. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/19-named_entities.json +16 -0
  266. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/20-xml_entities.json +16 -0
  267. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/21-entity_in_attribute.json +38 -0
  268. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/22-double_brackets.json +41 -0
  269. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/23-legacy_entity_fail.json +16 -0
  270. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/24-special_special.json +133 -0
  271. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/25-empty_tag_name.json +13 -0
  272. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/26-not-quite-closed.json +35 -0
  273. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/27-entities_in_attributes.json +62 -0
  274. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/28-cdata_in_html.json +9 -0
  275. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/29-comment_edge-cases.json +18 -0
  276. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/30-cdata_edge-cases.json +22 -0
  277. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/01-rss.js +34 -0
  278. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/02-atom.js +18 -0
  279. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/03-rdf.js +20 -0
  280. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/01-basic.json +83 -0
  281. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/02-RSS.json +1093 -0
  282. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/03-Atom.json +644 -0
  283. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/04-RDF.json +1399 -0
  284. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/05-Attributes.json +354 -0
  285. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/api.js +63 -0
  286. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/test-helper.js +83 -0
  287. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/LICENSE +23 -0
  288. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/README.md +218 -0
  289. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/minimatch.js +1061 -0
  290. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  291. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  292. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  293. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
  294. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/package.json +50 -0
  295. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
  296. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  297. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  298. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  299. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  300. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  301. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/package.json +58 -0
  302. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  303. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  304. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/package.json +57 -0
  305. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/basic.js +399 -0
  306. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/brace-expand.js +33 -0
  307. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/caching.js +14 -0
  308. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/defaults.js +274 -0
  309. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  310. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/LICENSE +26 -0
  311. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/README.md +569 -0
  312. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/bin/shjs +51 -0
  313. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/global.js +3 -0
  314. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/make.js +47 -0
  315. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/package.json +61 -0
  316. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/generate-docs.js +21 -0
  317. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/run-tests.js +50 -0
  318. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/shell.js +157 -0
  319. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cat.js +43 -0
  320. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cd.js +19 -0
  321. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/chmod.js +208 -0
  322. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/common.js +203 -0
  323. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cp.js +201 -0
  324. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/dirs.js +191 -0
  325. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/echo.js +20 -0
  326. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/error.js +10 -0
  327. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/exec.js +181 -0
  328. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/find.js +51 -0
  329. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/grep.js +52 -0
  330. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ln.js +53 -0
  331. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ls.js +126 -0
  332. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mkdir.js +68 -0
  333. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mv.js +80 -0
  334. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/popd.js +1 -0
  335. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pushd.js +1 -0
  336. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pwd.js +11 -0
  337. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/rm.js +145 -0
  338. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/sed.js +43 -0
  339. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/tempdir.js +56 -0
  340. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/test.js +85 -0
  341. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/to.js +29 -0
  342. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/toEnd.js +29 -0
  343. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/which.js +83 -0
  344. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/cli.js +41 -0
  345. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/package.json +76 -0
  346. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/readme.md +74 -0
  347. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/strip-json-comments.js +64 -0
  348. data/vendor/javascript/node_modules/jshint/node_modules/underscore/LICENSE +23 -0
  349. data/vendor/javascript/node_modules/jshint/node_modules/underscore/README.md +22 -0
  350. data/vendor/javascript/node_modules/jshint/node_modules/underscore/package.json +66 -0
  351. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore-min.js +6 -0
  352. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore.js +1343 -0
  353. data/vendor/javascript/node_modules/jshint/package.json +80 -0
  354. data/vendor/javascript/node_modules/jshint/src/cli.js +731 -0
  355. data/vendor/javascript/node_modules/jshint/src/jshint.js +5023 -0
  356. data/vendor/javascript/node_modules/jshint/src/lex.js +1650 -0
  357. data/vendor/javascript/node_modules/jshint/src/messages.js +223 -0
  358. data/vendor/javascript/node_modules/jshint/src/platforms/rhino.js +115 -0
  359. data/vendor/javascript/node_modules/jshint/src/reg.js +38 -0
  360. data/vendor/javascript/node_modules/jshint/src/reporters/checkstyle.js +81 -0
  361. data/vendor/javascript/node_modules/jshint/src/reporters/default.js +34 -0
  362. data/vendor/javascript/node_modules/jshint/src/reporters/jslint_xml.js +57 -0
  363. data/vendor/javascript/node_modules/jshint/src/reporters/non_error.js +52 -0
  364. data/vendor/javascript/node_modules/jshint/src/state.js +28 -0
  365. data/vendor/javascript/node_modules/jshint/src/style.js +143 -0
  366. data/vendor/javascript/node_modules/jshint/src/vars.js +658 -0
  367. data/vendor/python/astroid/COPYING +339 -0
  368. data/vendor/python/astroid/COPYING.LESSER +510 -0
  369. data/vendor/python/astroid/ChangeLog +574 -0
  370. data/vendor/python/astroid/MANIFEST.in +9 -0
  371. data/vendor/python/astroid/README +56 -0
  372. data/vendor/python/astroid/README.Python3 +26 -0
  373. data/vendor/python/astroid/__init__.py +118 -0
  374. data/vendor/python/astroid/__init__.pyc +0 -0
  375. data/vendor/python/astroid/__pkginfo__.py +48 -0
  376. data/vendor/python/astroid/__pkginfo__.pyc +0 -0
  377. data/vendor/python/astroid/announce.txt +23 -0
  378. data/vendor/python/astroid/as_string.py +496 -0
  379. data/vendor/python/astroid/as_string.pyc +0 -0
  380. data/vendor/python/astroid/bases.py +618 -0
  381. data/vendor/python/astroid/bases.pyc +0 -0
  382. data/vendor/python/astroid/brain/py2gi.py +159 -0
  383. data/vendor/python/astroid/brain/py2gi.pyc +0 -0
  384. data/vendor/python/astroid/brain/py2mechanize.py +20 -0
  385. data/vendor/python/astroid/brain/py2mechanize.pyc +0 -0
  386. data/vendor/python/astroid/brain/py2qt4.py +25 -0
  387. data/vendor/python/astroid/brain/py2qt4.pyc +0 -0
  388. data/vendor/python/astroid/brain/py2stdlib.py +252 -0
  389. data/vendor/python/astroid/brain/py2stdlib.pyc +0 -0
  390. data/vendor/python/astroid/builder.py +238 -0
  391. data/vendor/python/astroid/builder.pyc +0 -0
  392. data/vendor/python/astroid/exceptions.py +51 -0
  393. data/vendor/python/astroid/exceptions.pyc +0 -0
  394. data/vendor/python/astroid/inference.py +393 -0
  395. data/vendor/python/astroid/inference.pyc +0 -0
  396. data/vendor/python/astroid/inspector.py +275 -0
  397. data/vendor/python/astroid/manager.py +336 -0
  398. data/vendor/python/astroid/manager.pyc +0 -0
  399. data/vendor/python/astroid/mixins.py +122 -0
  400. data/vendor/python/astroid/mixins.pyc +0 -0
  401. data/vendor/python/astroid/node_classes.py +928 -0
  402. data/vendor/python/astroid/node_classes.pyc +0 -0
  403. data/vendor/python/astroid/nodes.py +73 -0
  404. data/vendor/python/astroid/nodes.pyc +0 -0
  405. data/vendor/python/astroid/protocols.py +322 -0
  406. data/vendor/python/astroid/protocols.pyc +0 -0
  407. data/vendor/python/astroid/raw_building.py +361 -0
  408. data/vendor/python/astroid/raw_building.pyc +0 -0
  409. data/vendor/python/astroid/rebuilder.py +954 -0
  410. data/vendor/python/astroid/rebuilder.pyc +0 -0
  411. data/vendor/python/astroid/scoped_nodes.py +1118 -0
  412. data/vendor/python/astroid/scoped_nodes.pyc +0 -0
  413. data/vendor/python/astroid/setup.py +184 -0
  414. data/vendor/python/astroid/tox.ini +10 -0
  415. data/vendor/python/astroid/utils.py +236 -0
  416. data/vendor/python/astroid/utils.pyc +0 -0
  417. data/vendor/python/logilab/__init__.py +0 -0
  418. data/vendor/python/logilab/__init__.pyc +0 -0
  419. data/vendor/python/logilab/common/COPYING +339 -0
  420. data/vendor/python/logilab/common/COPYING.LESSER +510 -0
  421. data/vendor/python/logilab/common/ChangeLog +1517 -0
  422. data/vendor/python/logilab/common/MANIFEST.in +13 -0
  423. data/vendor/python/logilab/common/README +185 -0
  424. data/vendor/python/logilab/common/README.Python3 +29 -0
  425. data/vendor/python/logilab/common/__init__.py +171 -0
  426. data/vendor/python/logilab/common/__init__.pyc +0 -0
  427. data/vendor/python/logilab/common/__pkginfo__.py +53 -0
  428. data/vendor/python/logilab/common/__pkginfo__.pyc +0 -0
  429. data/vendor/python/logilab/common/announce.txt +25 -0
  430. data/vendor/python/logilab/common/bin/pytest +7 -0
  431. data/vendor/python/logilab/common/bin/pytest.bat +17 -0
  432. data/vendor/python/logilab/common/cache.py +114 -0
  433. data/vendor/python/logilab/common/changelog.py +236 -0
  434. data/vendor/python/logilab/common/changelog.pyc +0 -0
  435. data/vendor/python/logilab/common/clcommands.py +332 -0
  436. data/vendor/python/logilab/common/cli.py +208 -0
  437. data/vendor/python/logilab/common/compat.py +243 -0
  438. data/vendor/python/logilab/common/compat.pyc +0 -0
  439. data/vendor/python/logilab/common/configuration.py +1094 -0
  440. data/vendor/python/logilab/common/configuration.pyc +0 -0
  441. data/vendor/python/logilab/common/contexts.py +5 -0
  442. data/vendor/python/logilab/common/corbautils.py +117 -0
  443. data/vendor/python/logilab/common/daemon.py +100 -0
  444. data/vendor/python/logilab/common/date.py +333 -0
  445. data/vendor/python/logilab/common/dbf.py +229 -0
  446. data/vendor/python/logilab/common/debugger.py +210 -0
  447. data/vendor/python/logilab/common/decorators.py +281 -0
  448. data/vendor/python/logilab/common/decorators.pyc +0 -0
  449. data/vendor/python/logilab/common/deprecation.py +188 -0
  450. data/vendor/python/logilab/common/deprecation.pyc +0 -0
  451. data/vendor/python/logilab/common/fileutils.py +402 -0
  452. data/vendor/python/logilab/common/graph.py +276 -0
  453. data/vendor/python/logilab/common/graph.pyc +0 -0
  454. data/vendor/python/logilab/common/hg.py +130 -0
  455. data/vendor/python/logilab/common/interface.py +71 -0
  456. data/vendor/python/logilab/common/interface.pyc +0 -0
  457. data/vendor/python/logilab/common/logging_ext.py +193 -0
  458. data/vendor/python/logilab/common/modutils.py +695 -0
  459. data/vendor/python/logilab/common/modutils.pyc +0 -0
  460. data/vendor/python/logilab/common/optik_ext.py +391 -0
  461. data/vendor/python/logilab/common/optik_ext.pyc +0 -0
  462. data/vendor/python/logilab/common/optparser.py +90 -0
  463. data/vendor/python/logilab/common/proc.py +277 -0
  464. data/vendor/python/logilab/common/pyro_ext.py +180 -0
  465. data/vendor/python/logilab/common/pytest.py +1177 -0
  466. data/vendor/python/logilab/common/python-logilab-common.spec +184 -0
  467. data/vendor/python/logilab/common/registry.py +1113 -0
  468. data/vendor/python/logilab/common/setup.cfg +3 -0
  469. data/vendor/python/logilab/common/setup.py +189 -0
  470. data/vendor/python/logilab/common/shellutils.py +455 -0
  471. data/vendor/python/logilab/common/sphinx_ext.py +87 -0
  472. data/vendor/python/logilab/common/sphinxutils.py +122 -0
  473. data/vendor/python/logilab/common/table.py +925 -0
  474. data/vendor/python/logilab/common/tasksqueue.py +100 -0
  475. data/vendor/python/logilab/common/textutils.py +534 -0
  476. data/vendor/python/logilab/common/textutils.pyc +0 -0
  477. data/vendor/python/logilab/common/tree.py +369 -0
  478. data/vendor/python/logilab/common/tree.pyc +0 -0
  479. data/vendor/python/logilab/common/umessage.py +190 -0
  480. data/vendor/python/logilab/common/ureports/__init__.py +174 -0
  481. data/vendor/python/logilab/common/ureports/__init__.pyc +0 -0
  482. data/vendor/python/logilab/common/ureports/docbook_writer.py +139 -0
  483. data/vendor/python/logilab/common/ureports/html_writer.py +131 -0
  484. data/vendor/python/logilab/common/ureports/html_writer.pyc +0 -0
  485. data/vendor/python/logilab/common/ureports/nodes.py +201 -0
  486. data/vendor/python/logilab/common/ureports/nodes.pyc +0 -0
  487. data/vendor/python/logilab/common/ureports/text_writer.py +140 -0
  488. data/vendor/python/logilab/common/ureports/text_writer.pyc +0 -0
  489. data/vendor/python/logilab/common/urllib2ext.py +87 -0
  490. data/vendor/python/logilab/common/vcgutils.py +216 -0
  491. data/vendor/python/logilab/common/visitor.py +107 -0
  492. data/vendor/python/logilab/common/visitor.pyc +0 -0
  493. data/vendor/python/logilab/common/xmlrpcutils.py +131 -0
  494. data/vendor/python/logilab/common/xmlutils.py +61 -0
  495. data/vendor/python/pylint/CONTRIBUTORS.txt +38 -0
  496. data/vendor/python/pylint/COPYING +340 -0
  497. data/vendor/python/pylint/ChangeLog +1437 -0
  498. data/vendor/python/pylint/DEPENDS +3 -0
  499. data/vendor/python/pylint/MANIFEST.in +14 -0
  500. data/vendor/python/pylint/README +50 -0
  501. data/vendor/python/pylint/README.Python3 +37 -0
  502. data/vendor/python/pylint/__init__.py +44 -0
  503. data/vendor/python/pylint/__init__.pyc +0 -0
  504. data/vendor/python/pylint/__main__.py +3 -0
  505. data/vendor/python/pylint/__pkginfo__.py +74 -0
  506. data/vendor/python/pylint/__pkginfo__.pyc +0 -0
  507. data/vendor/python/pylint/bin/epylint +3 -0
  508. data/vendor/python/pylint/bin/epylint.bat +5 -0
  509. data/vendor/python/pylint/bin/pylint +3 -0
  510. data/vendor/python/pylint/bin/pylint-gui +3 -0
  511. data/vendor/python/pylint/bin/pylint-gui.bat +5 -0
  512. data/vendor/python/pylint/bin/pylint.bat +5 -0
  513. data/vendor/python/pylint/bin/pyreverse +3 -0
  514. data/vendor/python/pylint/bin/pyreverse.bat +5 -0
  515. data/vendor/python/pylint/bin/symilar +3 -0
  516. data/vendor/python/pylint/bin/symilar.bat +5 -0
  517. data/vendor/python/pylint/checkers/__init__.py +145 -0
  518. data/vendor/python/pylint/checkers/__init__.pyc +0 -0
  519. data/vendor/python/pylint/checkers/base.py +1141 -0
  520. data/vendor/python/pylint/checkers/base.pyc +0 -0
  521. data/vendor/python/pylint/checkers/classes.py +792 -0
  522. data/vendor/python/pylint/checkers/classes.pyc +0 -0
  523. data/vendor/python/pylint/checkers/design_analysis.py +367 -0
  524. data/vendor/python/pylint/checkers/design_analysis.pyc +0 -0
  525. data/vendor/python/pylint/checkers/exceptions.py +306 -0
  526. data/vendor/python/pylint/checkers/exceptions.pyc +0 -0
  527. data/vendor/python/pylint/checkers/format.py +943 -0
  528. data/vendor/python/pylint/checkers/format.pyc +0 -0
  529. data/vendor/python/pylint/checkers/imports.py +394 -0
  530. data/vendor/python/pylint/checkers/imports.pyc +0 -0
  531. data/vendor/python/pylint/checkers/logging.py +213 -0
  532. data/vendor/python/pylint/checkers/logging.pyc +0 -0
  533. data/vendor/python/pylint/checkers/misc.py +90 -0
  534. data/vendor/python/pylint/checkers/misc.pyc +0 -0
  535. data/vendor/python/pylint/checkers/newstyle.py +151 -0
  536. data/vendor/python/pylint/checkers/newstyle.pyc +0 -0
  537. data/vendor/python/pylint/checkers/raw_metrics.py +129 -0
  538. data/vendor/python/pylint/checkers/raw_metrics.pyc +0 -0
  539. data/vendor/python/pylint/checkers/similar.py +365 -0
  540. data/vendor/python/pylint/checkers/similar.pyc +0 -0
  541. data/vendor/python/pylint/checkers/stdlib.py +69 -0
  542. data/vendor/python/pylint/checkers/stdlib.pyc +0 -0
  543. data/vendor/python/pylint/checkers/strings.py +304 -0
  544. data/vendor/python/pylint/checkers/strings.pyc +0 -0
  545. data/vendor/python/pylint/checkers/typecheck.py +451 -0
  546. data/vendor/python/pylint/checkers/typecheck.pyc +0 -0
  547. data/vendor/python/pylint/checkers/utils.py +416 -0
  548. data/vendor/python/pylint/checkers/utils.pyc +0 -0
  549. data/vendor/python/pylint/checkers/variables.py +741 -0
  550. data/vendor/python/pylint/checkers/variables.pyc +0 -0
  551. data/vendor/python/pylint/config.py +156 -0
  552. data/vendor/python/pylint/config.pyc +0 -0
  553. data/vendor/python/pylint/epylint.py +175 -0
  554. data/vendor/python/pylint/gui.py +508 -0
  555. data/vendor/python/pylint/interfaces.py +72 -0
  556. data/vendor/python/pylint/interfaces.pyc +0 -0
  557. data/vendor/python/pylint/lint.py +1106 -0
  558. data/vendor/python/pylint/lint.pyc +0 -0
  559. data/vendor/python/pylint/pyreverse/__init__.py +5 -0
  560. data/vendor/python/pylint/pyreverse/diadefslib.py +233 -0
  561. data/vendor/python/pylint/pyreverse/diagrams.py +247 -0
  562. data/vendor/python/pylint/pyreverse/main.py +124 -0
  563. data/vendor/python/pylint/pyreverse/utils.py +131 -0
  564. data/vendor/python/pylint/pyreverse/writer.py +199 -0
  565. data/vendor/python/pylint/reporters/__init__.py +138 -0
  566. data/vendor/python/pylint/reporters/__init__.pyc +0 -0
  567. data/vendor/python/pylint/reporters/guireporter.py +28 -0
  568. data/vendor/python/pylint/reporters/guireporter.pyc +0 -0
  569. data/vendor/python/pylint/reporters/html.py +70 -0
  570. data/vendor/python/pylint/reporters/html.pyc +0 -0
  571. data/vendor/python/pylint/reporters/text.py +143 -0
  572. data/vendor/python/pylint/reporters/text.pyc +0 -0
  573. data/vendor/python/pylint/setup.cfg +3 -0
  574. data/vendor/python/pylint/setup.py +203 -0
  575. data/vendor/python/pylint/tox.ini +10 -0
  576. data/vendor/python/pylint/utils.py +744 -0
  577. data/vendor/python/pylint/utils.pyc +0 -0
  578. data/vendor/python/pylint_runner.py +22 -0
  579. metadata +675 -0
@@ -0,0 +1,1094 @@
1
+ # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2
+ # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3
+ #
4
+ # This file is part of logilab-common.
5
+ #
6
+ # logilab-common is free software: you can redistribute it and/or modify it under
7
+ # the terms of the GNU Lesser General Public License as published by the Free
8
+ # Software Foundation, either version 2.1 of the License, or (at your option) any
9
+ # later version.
10
+ #
11
+ # logilab-common is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License along
17
+ # with logilab-common. If not, see <http://www.gnu.org/licenses/>.
18
+ """Classes to handle advanced configuration in simple to complex applications.
19
+
20
+ Allows to load the configuration from a file or from command line
21
+ options, to generate a sample configuration file or to display
22
+ program's usage. Fills the gap between optik/optparse and ConfigParser
23
+ by adding data types (which are also available as a standalone optik
24
+ extension in the `optik_ext` module).
25
+
26
+
27
+ Quick start: simplest usage
28
+ ---------------------------
29
+
30
+ .. python ::
31
+
32
+ >>> import sys
33
+ >>> from logilab.common.configuration import Configuration
34
+ >>> options = [('dothis', {'type':'yn', 'default': True, 'metavar': '<y or n>'}),
35
+ ... ('value', {'type': 'string', 'metavar': '<string>'}),
36
+ ... ('multiple', {'type': 'csv', 'default': ('yop',),
37
+ ... 'metavar': '<comma separated values>',
38
+ ... 'help': 'you can also document the option'}),
39
+ ... ('number', {'type': 'int', 'default':2, 'metavar':'<int>'}),
40
+ ... ]
41
+ >>> config = Configuration(options=options, name='My config')
42
+ >>> print config['dothis']
43
+ True
44
+ >>> print config['value']
45
+ None
46
+ >>> print config['multiple']
47
+ ('yop',)
48
+ >>> print config['number']
49
+ 2
50
+ >>> print config.help()
51
+ Usage: [options]
52
+
53
+ Options:
54
+ -h, --help show this help message and exit
55
+ --dothis=<y or n>
56
+ --value=<string>
57
+ --multiple=<comma separated values>
58
+ you can also document the option [current: none]
59
+ --number=<int>
60
+
61
+ >>> f = open('myconfig.ini', 'w')
62
+ >>> f.write('''[MY CONFIG]
63
+ ... number = 3
64
+ ... dothis = no
65
+ ... multiple = 1,2,3
66
+ ... ''')
67
+ >>> f.close()
68
+ >>> config.load_file_configuration('myconfig.ini')
69
+ >>> print config['dothis']
70
+ False
71
+ >>> print config['value']
72
+ None
73
+ >>> print config['multiple']
74
+ ['1', '2', '3']
75
+ >>> print config['number']
76
+ 3
77
+ >>> sys.argv = ['mon prog', '--value', 'bacon', '--multiple', '4,5,6',
78
+ ... 'nonoptionargument']
79
+ >>> print config.load_command_line_configuration()
80
+ ['nonoptionargument']
81
+ >>> print config['value']
82
+ bacon
83
+ >>> config.generate_config()
84
+ # class for simple configurations which don't need the
85
+ # manager / providers model and prefer delegation to inheritance
86
+ #
87
+ # configuration values are accessible through a dict like interface
88
+ #
89
+ [MY CONFIG]
90
+
91
+ dothis=no
92
+
93
+ value=bacon
94
+
95
+ # you can also document the option
96
+ multiple=4,5,6
97
+
98
+ number=3
99
+ >>>
100
+ """
101
+ __docformat__ = "restructuredtext en"
102
+
103
+ __all__ = ('OptionsManagerMixIn', 'OptionsProviderMixIn',
104
+ 'ConfigurationMixIn', 'Configuration',
105
+ 'OptionsManager2ConfigurationAdapter')
106
+
107
+ import os
108
+ import sys
109
+ import re
110
+ from os.path import exists, expanduser
111
+ from copy import copy
112
+ from ConfigParser import ConfigParser, NoOptionError, NoSectionError, \
113
+ DuplicateSectionError
114
+ from warnings import warn
115
+
116
+ from logilab.common.compat import callable, raw_input, str_encode as _encode
117
+ from logilab.common.deprecation import deprecated
118
+ from logilab.common.textutils import normalize_text, unquote
119
+ from logilab.common import optik_ext
120
+
121
+ OptionError = optik_ext.OptionError
122
+
123
+ REQUIRED = []
124
+
125
+ class UnsupportedAction(Exception):
126
+ """raised by set_option when it doesn't know what to do for an action"""
127
+
128
+
129
+ def _get_encoding(encoding, stream):
130
+ encoding = encoding or getattr(stream, 'encoding', None)
131
+ if not encoding:
132
+ import locale
133
+ encoding = locale.getpreferredencoding()
134
+ return encoding
135
+
136
+
137
+ # validation functions ########################################################
138
+
139
+ # validators will return the validated value or raise optparse.OptionValueError
140
+ # XXX add to documentation
141
+
142
+ def choice_validator(optdict, name, value):
143
+ """validate and return a converted value for option of type 'choice'
144
+ """
145
+ if not value in optdict['choices']:
146
+ msg = "option %s: invalid value: %r, should be in %s"
147
+ raise optik_ext.OptionValueError(msg % (name, value, optdict['choices']))
148
+ return value
149
+
150
+ def multiple_choice_validator(optdict, name, value):
151
+ """validate and return a converted value for option of type 'choice'
152
+ """
153
+ choices = optdict['choices']
154
+ values = optik_ext.check_csv(None, name, value)
155
+ for value in values:
156
+ if not value in choices:
157
+ msg = "option %s: invalid value: %r, should be in %s"
158
+ raise optik_ext.OptionValueError(msg % (name, value, choices))
159
+ return values
160
+
161
+ def csv_validator(optdict, name, value):
162
+ """validate and return a converted value for option of type 'csv'
163
+ """
164
+ return optik_ext.check_csv(None, name, value)
165
+
166
+ def yn_validator(optdict, name, value):
167
+ """validate and return a converted value for option of type 'yn'
168
+ """
169
+ return optik_ext.check_yn(None, name, value)
170
+
171
+ def named_validator(optdict, name, value):
172
+ """validate and return a converted value for option of type 'named'
173
+ """
174
+ return optik_ext.check_named(None, name, value)
175
+
176
+ def file_validator(optdict, name, value):
177
+ """validate and return a filepath for option of type 'file'"""
178
+ return optik_ext.check_file(None, name, value)
179
+
180
+ def color_validator(optdict, name, value):
181
+ """validate and return a valid color for option of type 'color'"""
182
+ return optik_ext.check_color(None, name, value)
183
+
184
+ def password_validator(optdict, name, value):
185
+ """validate and return a string for option of type 'password'"""
186
+ return optik_ext.check_password(None, name, value)
187
+
188
+ def date_validator(optdict, name, value):
189
+ """validate and return a mx DateTime object for option of type 'date'"""
190
+ return optik_ext.check_date(None, name, value)
191
+
192
+ def time_validator(optdict, name, value):
193
+ """validate and return a time object for option of type 'time'"""
194
+ return optik_ext.check_time(None, name, value)
195
+
196
+ def bytes_validator(optdict, name, value):
197
+ """validate and return an integer for option of type 'bytes'"""
198
+ return optik_ext.check_bytes(None, name, value)
199
+
200
+
201
+ VALIDATORS = {'string': unquote,
202
+ 'int': int,
203
+ 'float': float,
204
+ 'file': file_validator,
205
+ 'font': unquote,
206
+ 'color': color_validator,
207
+ 'regexp': re.compile,
208
+ 'csv': csv_validator,
209
+ 'yn': yn_validator,
210
+ 'bool': yn_validator,
211
+ 'named': named_validator,
212
+ 'password': password_validator,
213
+ 'date': date_validator,
214
+ 'time': time_validator,
215
+ 'bytes': bytes_validator,
216
+ 'choice': choice_validator,
217
+ 'multiple_choice': multiple_choice_validator,
218
+ }
219
+
220
+ def _call_validator(opttype, optdict, option, value):
221
+ if opttype not in VALIDATORS:
222
+ raise Exception('Unsupported type "%s"' % opttype)
223
+ try:
224
+ return VALIDATORS[opttype](optdict, option, value)
225
+ except TypeError:
226
+ try:
227
+ return VALIDATORS[opttype](value)
228
+ except optik_ext.OptionValueError:
229
+ raise
230
+ except:
231
+ raise optik_ext.OptionValueError('%s value (%r) should be of type %s' %
232
+ (option, value, opttype))
233
+
234
+ # user input functions ########################################################
235
+
236
+ # user input functions will ask the user for input on stdin then validate
237
+ # the result and return the validated value or raise optparse.OptionValueError
238
+ # XXX add to documentation
239
+
240
+ def input_password(optdict, question='password:'):
241
+ from getpass import getpass
242
+ while True:
243
+ value = getpass(question)
244
+ value2 = getpass('confirm: ')
245
+ if value == value2:
246
+ return value
247
+ print 'password mismatch, try again'
248
+
249
+ def input_string(optdict, question):
250
+ value = raw_input(question).strip()
251
+ return value or None
252
+
253
+ def _make_input_function(opttype):
254
+ def input_validator(optdict, question):
255
+ while True:
256
+ value = raw_input(question)
257
+ if not value.strip():
258
+ return None
259
+ try:
260
+ return _call_validator(opttype, optdict, None, value)
261
+ except optik_ext.OptionValueError, ex:
262
+ msg = str(ex).split(':', 1)[-1].strip()
263
+ print 'bad value: %s' % msg
264
+ return input_validator
265
+
266
+ INPUT_FUNCTIONS = {
267
+ 'string': input_string,
268
+ 'password': input_password,
269
+ }
270
+
271
+ for opttype in VALIDATORS.keys():
272
+ INPUT_FUNCTIONS.setdefault(opttype, _make_input_function(opttype))
273
+
274
+ # utility functions ############################################################
275
+
276
+ def expand_default(self, option):
277
+ """monkey patch OptionParser.expand_default since we have a particular
278
+ way to handle defaults to avoid overriding values in the configuration
279
+ file
280
+ """
281
+ if self.parser is None or not self.default_tag:
282
+ return option.help
283
+ optname = option._long_opts[0][2:]
284
+ try:
285
+ provider = self.parser.options_manager._all_options[optname]
286
+ except KeyError:
287
+ value = None
288
+ else:
289
+ optdict = provider.get_option_def(optname)
290
+ optname = provider.option_attrname(optname, optdict)
291
+ value = getattr(provider.config, optname, optdict)
292
+ value = format_option_value(optdict, value)
293
+ if value is optik_ext.NO_DEFAULT or not value:
294
+ value = self.NO_DEFAULT_VALUE
295
+ return option.help.replace(self.default_tag, str(value))
296
+
297
+
298
+ def _validate(value, optdict, name=''):
299
+ """return a validated value for an option according to its type
300
+
301
+ optional argument name is only used for error message formatting
302
+ """
303
+ try:
304
+ _type = optdict['type']
305
+ except KeyError:
306
+ # FIXME
307
+ return value
308
+ return _call_validator(_type, optdict, name, value)
309
+ convert = deprecated('[0.60] convert() was renamed _validate()')(_validate)
310
+
311
+ # format and output functions ##################################################
312
+
313
+ def comment(string):
314
+ """return string as a comment"""
315
+ lines = [line.strip() for line in string.splitlines()]
316
+ return '# ' + ('%s# ' % os.linesep).join(lines)
317
+
318
+ def format_time(value):
319
+ if not value:
320
+ return '0'
321
+ if value != int(value):
322
+ return '%.2fs' % value
323
+ value = int(value)
324
+ nbmin, nbsec = divmod(value, 60)
325
+ if nbsec:
326
+ return '%ss' % value
327
+ nbhour, nbmin_ = divmod(nbmin, 60)
328
+ if nbmin_:
329
+ return '%smin' % nbmin
330
+ nbday, nbhour_ = divmod(nbhour, 24)
331
+ if nbhour_:
332
+ return '%sh' % nbhour
333
+ return '%sd' % nbday
334
+
335
+ def format_bytes(value):
336
+ if not value:
337
+ return '0'
338
+ if value != int(value):
339
+ return '%.2fB' % value
340
+ value = int(value)
341
+ prevunit = 'B'
342
+ for unit in ('KB', 'MB', 'GB', 'TB'):
343
+ next, remain = divmod(value, 1024)
344
+ if remain:
345
+ return '%s%s' % (value, prevunit)
346
+ prevunit = unit
347
+ value = next
348
+ return '%s%s' % (value, unit)
349
+
350
+ def format_option_value(optdict, value):
351
+ """return the user input's value from a 'compiled' value"""
352
+ if isinstance(value, (list, tuple)):
353
+ value = ','.join(value)
354
+ elif isinstance(value, dict):
355
+ value = ','.join(['%s:%s' % (k, v) for k, v in value.items()])
356
+ elif hasattr(value, 'match'): # optdict.get('type') == 'regexp'
357
+ # compiled regexp
358
+ value = value.pattern
359
+ elif optdict.get('type') == 'yn':
360
+ value = value and 'yes' or 'no'
361
+ elif isinstance(value, (str, unicode)) and value.isspace():
362
+ value = "'%s'" % value
363
+ elif optdict.get('type') == 'time' and isinstance(value, (float, int, long)):
364
+ value = format_time(value)
365
+ elif optdict.get('type') == 'bytes' and hasattr(value, '__int__'):
366
+ value = format_bytes(value)
367
+ return value
368
+
369
+ def ini_format_section(stream, section, options, encoding=None, doc=None):
370
+ """format an options section using the INI format"""
371
+ encoding = _get_encoding(encoding, stream)
372
+ if doc:
373
+ print >> stream, _encode(comment(doc), encoding)
374
+ print >> stream, '[%s]' % section
375
+ ini_format(stream, options, encoding)
376
+
377
+ def ini_format(stream, options, encoding):
378
+ """format options using the INI format"""
379
+ for optname, optdict, value in options:
380
+ value = format_option_value(optdict, value)
381
+ help = optdict.get('help')
382
+ if help:
383
+ help = normalize_text(help, line_len=79, indent='# ')
384
+ print >> stream
385
+ print >> stream, _encode(help, encoding)
386
+ else:
387
+ print >> stream
388
+ if value is None:
389
+ print >> stream, '#%s=' % optname
390
+ else:
391
+ value = _encode(value, encoding).strip()
392
+ print >> stream, '%s=%s' % (optname, value)
393
+
394
+ format_section = ini_format_section
395
+
396
+ def rest_format_section(stream, section, options, encoding=None, doc=None):
397
+ """format an options section using the INI format"""
398
+ encoding = _get_encoding(encoding, stream)
399
+ if section:
400
+ print >> stream, '%s\n%s' % (section, "'"*len(section))
401
+ if doc:
402
+ print >> stream, _encode(normalize_text(doc, line_len=79, indent=''),
403
+ encoding)
404
+ print >> stream
405
+ for optname, optdict, value in options:
406
+ help = optdict.get('help')
407
+ print >> stream, ':%s:' % optname
408
+ if help:
409
+ help = normalize_text(help, line_len=79, indent=' ')
410
+ print >> stream, _encode(help, encoding)
411
+ if value:
412
+ value = _encode(format_option_value(optdict, value), encoding)
413
+ print >> stream, ''
414
+ print >> stream, ' Default: ``%s``' % value.replace("`` ", "```` ``")
415
+
416
+ # Options Manager ##############################################################
417
+
418
+ class OptionsManagerMixIn(object):
419
+ """MixIn to handle a configuration from both a configuration file and
420
+ command line options
421
+ """
422
+
423
+ def __init__(self, usage, config_file=None, version=None, quiet=0):
424
+ self.config_file = config_file
425
+ self.reset_parsers(usage, version=version)
426
+ # list of registered options providers
427
+ self.options_providers = []
428
+ # dictionary associating option name to checker
429
+ self._all_options = {}
430
+ self._short_options = {}
431
+ self._nocallback_options = {}
432
+ self._mygroups = dict()
433
+ # verbosity
434
+ self.quiet = quiet
435
+ self._maxlevel = 0
436
+
437
+ def reset_parsers(self, usage='', version=None):
438
+ # configuration file parser
439
+ self.cfgfile_parser = ConfigParser()
440
+ # command line parser
441
+ self.cmdline_parser = optik_ext.OptionParser(usage=usage, version=version)
442
+ self.cmdline_parser.options_manager = self
443
+ self._optik_option_attrs = set(self.cmdline_parser.option_class.ATTRS)
444
+
445
+ def register_options_provider(self, provider, own_group=True):
446
+ """register an options provider"""
447
+ assert provider.priority <= 0, "provider's priority can't be >= 0"
448
+ for i in range(len(self.options_providers)):
449
+ if provider.priority > self.options_providers[i].priority:
450
+ self.options_providers.insert(i, provider)
451
+ break
452
+ else:
453
+ self.options_providers.append(provider)
454
+ non_group_spec_options = [option for option in provider.options
455
+ if 'group' not in option[1]]
456
+ groups = getattr(provider, 'option_groups', ())
457
+ if own_group and non_group_spec_options:
458
+ self.add_option_group(provider.name.upper(), provider.__doc__,
459
+ non_group_spec_options, provider)
460
+ else:
461
+ for opt, optdict in non_group_spec_options:
462
+ self.add_optik_option(provider, self.cmdline_parser, opt, optdict)
463
+ for gname, gdoc in groups:
464
+ gname = gname.upper()
465
+ goptions = [option for option in provider.options
466
+ if option[1].get('group', '').upper() == gname]
467
+ self.add_option_group(gname, gdoc, goptions, provider)
468
+
469
+ def add_option_group(self, group_name, doc, options, provider):
470
+ """add an option group including the listed options
471
+ """
472
+ assert options
473
+ # add option group to the command line parser
474
+ if group_name in self._mygroups:
475
+ group = self._mygroups[group_name]
476
+ else:
477
+ group = optik_ext.OptionGroup(self.cmdline_parser,
478
+ title=group_name.capitalize())
479
+ self.cmdline_parser.add_option_group(group)
480
+ group.level = provider.level
481
+ self._mygroups[group_name] = group
482
+ # add section to the config file
483
+ if group_name != "DEFAULT":
484
+ self.cfgfile_parser.add_section(group_name)
485
+ # add provider's specific options
486
+ for opt, optdict in options:
487
+ self.add_optik_option(provider, group, opt, optdict)
488
+
489
+ def add_optik_option(self, provider, optikcontainer, opt, optdict):
490
+ if 'inputlevel' in optdict:
491
+ warn('[0.50] "inputlevel" in option dictionary for %s is deprecated,'
492
+ ' use "level"' % opt, DeprecationWarning)
493
+ optdict['level'] = optdict.pop('inputlevel')
494
+ args, optdict = self.optik_option(provider, opt, optdict)
495
+ option = optikcontainer.add_option(*args, **optdict)
496
+ self._all_options[opt] = provider
497
+ self._maxlevel = max(self._maxlevel, option.level or 0)
498
+
499
+ def optik_option(self, provider, opt, optdict):
500
+ """get our personal option definition and return a suitable form for
501
+ use with optik/optparse
502
+ """
503
+ optdict = copy(optdict)
504
+ others = {}
505
+ if 'action' in optdict:
506
+ self._nocallback_options[provider] = opt
507
+ else:
508
+ optdict['action'] = 'callback'
509
+ optdict['callback'] = self.cb_set_provider_option
510
+ # default is handled here and *must not* be given to optik if you
511
+ # want the whole machinery to work
512
+ if 'default' in optdict:
513
+ if ('help' in optdict
514
+ and optdict.get('default') is not None
515
+ and not optdict['action'] in ('store_true', 'store_false')):
516
+ optdict['help'] += ' [current: %default]'
517
+ del optdict['default']
518
+ args = ['--' + str(opt)]
519
+ if 'short' in optdict:
520
+ self._short_options[optdict['short']] = opt
521
+ args.append('-' + optdict['short'])
522
+ del optdict['short']
523
+ # cleanup option definition dict before giving it to optik
524
+ for key in optdict.keys():
525
+ if not key in self._optik_option_attrs:
526
+ optdict.pop(key)
527
+ return args, optdict
528
+
529
+ def cb_set_provider_option(self, option, opt, value, parser):
530
+ """optik callback for option setting"""
531
+ if opt.startswith('--'):
532
+ # remove -- on long option
533
+ opt = opt[2:]
534
+ else:
535
+ # short option, get its long equivalent
536
+ opt = self._short_options[opt[1:]]
537
+ # trick since we can't set action='store_true' on options
538
+ if value is None:
539
+ value = 1
540
+ self.global_set_option(opt, value)
541
+
542
+ def global_set_option(self, opt, value):
543
+ """set option on the correct option provider"""
544
+ self._all_options[opt].set_option(opt, value)
545
+
546
+ def generate_config(self, stream=None, skipsections=(), encoding=None):
547
+ """write a configuration file according to the current configuration
548
+ into the given stream or stdout
549
+ """
550
+ options_by_section = {}
551
+ sections = []
552
+ for provider in self.options_providers:
553
+ for section, options in provider.options_by_section():
554
+ if section is None:
555
+ section = provider.name
556
+ if section in skipsections:
557
+ continue
558
+ options = [(n, d, v) for (n, d, v) in options
559
+ if d.get('type') is not None]
560
+ if not options:
561
+ continue
562
+ if not section in sections:
563
+ sections.append(section)
564
+ alloptions = options_by_section.setdefault(section, [])
565
+ alloptions += options
566
+ stream = stream or sys.stdout
567
+ encoding = _get_encoding(encoding, stream)
568
+ printed = False
569
+ for section in sections:
570
+ if printed:
571
+ print >> stream, '\n'
572
+ format_section(stream, section.upper(), options_by_section[section],
573
+ encoding)
574
+ printed = True
575
+
576
+ def generate_manpage(self, pkginfo, section=1, stream=None):
577
+ """write a man page for the current configuration into the given
578
+ stream or stdout
579
+ """
580
+ self._monkeypatch_expand_default()
581
+ try:
582
+ optik_ext.generate_manpage(self.cmdline_parser, pkginfo,
583
+ section, stream=stream or sys.stdout,
584
+ level=self._maxlevel)
585
+ finally:
586
+ self._unmonkeypatch_expand_default()
587
+
588
+ # initialization methods ##################################################
589
+
590
+ def load_provider_defaults(self):
591
+ """initialize configuration using default values"""
592
+ for provider in self.options_providers:
593
+ provider.load_defaults()
594
+
595
+ def load_file_configuration(self, config_file=None):
596
+ """load the configuration from file"""
597
+ self.read_config_file(config_file)
598
+ self.load_config_file()
599
+
600
+ def read_config_file(self, config_file=None):
601
+ """read the configuration file but do not load it (i.e. dispatching
602
+ values to each options provider)
603
+ """
604
+ helplevel = 1
605
+ while helplevel <= self._maxlevel:
606
+ opt = '-'.join(['long'] * helplevel) + '-help'
607
+ if opt in self._all_options:
608
+ break # already processed
609
+ def helpfunc(option, opt, val, p, level=helplevel):
610
+ print self.help(level)
611
+ sys.exit(0)
612
+ helpmsg = '%s verbose help.' % ' '.join(['more'] * helplevel)
613
+ optdict = {'action' : 'callback', 'callback' : helpfunc,
614
+ 'help' : helpmsg}
615
+ provider = self.options_providers[0]
616
+ self.add_optik_option(provider, self.cmdline_parser, opt, optdict)
617
+ provider.options += ( (opt, optdict), )
618
+ helplevel += 1
619
+ if config_file is None:
620
+ config_file = self.config_file
621
+ if config_file is not None:
622
+ config_file = expanduser(config_file)
623
+ if config_file and exists(config_file):
624
+ parser = self.cfgfile_parser
625
+ parser.read([config_file])
626
+ # normalize sections'title
627
+ for sect, values in parser._sections.items():
628
+ if not sect.isupper() and values:
629
+ parser._sections[sect.upper()] = values
630
+ elif not self.quiet:
631
+ msg = 'No config file found, using default configuration'
632
+ print >> sys.stderr, msg
633
+ return
634
+
635
+ def input_config(self, onlysection=None, inputlevel=0, stream=None):
636
+ """interactively get configuration values by asking to the user and generate
637
+ a configuration file
638
+ """
639
+ if onlysection is not None:
640
+ onlysection = onlysection.upper()
641
+ for provider in self.options_providers:
642
+ for section, option, optdict in provider.all_options():
643
+ if onlysection is not None and section != onlysection:
644
+ continue
645
+ if not 'type' in optdict:
646
+ # ignore action without type (callback, store_true...)
647
+ continue
648
+ provider.input_option(option, optdict, inputlevel)
649
+ # now we can generate the configuration file
650
+ if stream is not None:
651
+ self.generate_config(stream)
652
+
653
+ def load_config_file(self):
654
+ """dispatch values previously read from a configuration file to each
655
+ options provider)
656
+ """
657
+ parser = self.cfgfile_parser
658
+ for provider in self.options_providers:
659
+ for section, option, optdict in provider.all_options():
660
+ try:
661
+ value = parser.get(section, option)
662
+ provider.set_option(option, value, optdict=optdict)
663
+ except (NoSectionError, NoOptionError), ex:
664
+ continue
665
+
666
+ def load_configuration(self, **kwargs):
667
+ """override configuration according to given parameters
668
+ """
669
+ for opt, opt_value in kwargs.items():
670
+ opt = opt.replace('_', '-')
671
+ provider = self._all_options[opt]
672
+ provider.set_option(opt, opt_value)
673
+
674
+ def load_command_line_configuration(self, args=None):
675
+ """override configuration according to command line parameters
676
+
677
+ return additional arguments
678
+ """
679
+ self._monkeypatch_expand_default()
680
+ try:
681
+ if args is None:
682
+ args = sys.argv[1:]
683
+ else:
684
+ args = list(args)
685
+ (options, args) = self.cmdline_parser.parse_args(args=args)
686
+ for provider in self._nocallback_options.keys():
687
+ config = provider.config
688
+ for attr in config.__dict__.keys():
689
+ value = getattr(options, attr, None)
690
+ if value is None:
691
+ continue
692
+ setattr(config, attr, value)
693
+ return args
694
+ finally:
695
+ self._unmonkeypatch_expand_default()
696
+
697
+
698
+ # help methods ############################################################
699
+
700
+ def add_help_section(self, title, description, level=0):
701
+ """add a dummy option section for help purpose """
702
+ group = optik_ext.OptionGroup(self.cmdline_parser,
703
+ title=title.capitalize(),
704
+ description=description)
705
+ group.level = level
706
+ self._maxlevel = max(self._maxlevel, level)
707
+ self.cmdline_parser.add_option_group(group)
708
+
709
+ def _monkeypatch_expand_default(self):
710
+ # monkey patch optik_ext to deal with our default values
711
+ try:
712
+ self.__expand_default_backup = optik_ext.HelpFormatter.expand_default
713
+ optik_ext.HelpFormatter.expand_default = expand_default
714
+ except AttributeError:
715
+ # python < 2.4: nothing to be done
716
+ pass
717
+ def _unmonkeypatch_expand_default(self):
718
+ # remove monkey patch
719
+ if hasattr(optik_ext.HelpFormatter, 'expand_default'):
720
+ # unpatch optik_ext to avoid side effects
721
+ optik_ext.HelpFormatter.expand_default = self.__expand_default_backup
722
+
723
+ def help(self, level=0):
724
+ """return the usage string for available options """
725
+ self.cmdline_parser.formatter.output_level = level
726
+ self._monkeypatch_expand_default()
727
+ try:
728
+ return self.cmdline_parser.format_help()
729
+ finally:
730
+ self._unmonkeypatch_expand_default()
731
+
732
+
733
+ class Method(object):
734
+ """used to ease late binding of default method (so you can define options
735
+ on the class using default methods on the configuration instance)
736
+ """
737
+ def __init__(self, methname):
738
+ self.method = methname
739
+ self._inst = None
740
+
741
+ def bind(self, instance):
742
+ """bind the method to its instance"""
743
+ if self._inst is None:
744
+ self._inst = instance
745
+
746
+ def __call__(self, *args, **kwargs):
747
+ assert self._inst, 'unbound method'
748
+ return getattr(self._inst, self.method)(*args, **kwargs)
749
+
750
+ # Options Provider #############################################################
751
+
752
+ class OptionsProviderMixIn(object):
753
+ """Mixin to provide options to an OptionsManager"""
754
+
755
+ # those attributes should be overridden
756
+ priority = -1
757
+ name = 'default'
758
+ options = ()
759
+ level = 0
760
+
761
+ def __init__(self):
762
+ self.config = optik_ext.Values()
763
+ for option in self.options:
764
+ try:
765
+ option, optdict = option
766
+ except ValueError:
767
+ raise Exception('Bad option: %r' % option)
768
+ if isinstance(optdict.get('default'), Method):
769
+ optdict['default'].bind(self)
770
+ elif isinstance(optdict.get('callback'), Method):
771
+ optdict['callback'].bind(self)
772
+ self.load_defaults()
773
+
774
+ def load_defaults(self):
775
+ """initialize the provider using default values"""
776
+ for opt, optdict in self.options:
777
+ action = optdict.get('action')
778
+ if action != 'callback':
779
+ # callback action have no default
780
+ default = self.option_default(opt, optdict)
781
+ if default is REQUIRED:
782
+ continue
783
+ self.set_option(opt, default, action, optdict)
784
+
785
+ def option_default(self, opt, optdict=None):
786
+ """return the default value for an option"""
787
+ if optdict is None:
788
+ optdict = self.get_option_def(opt)
789
+ default = optdict.get('default')
790
+ if callable(default):
791
+ default = default()
792
+ return default
793
+
794
+ def option_attrname(self, opt, optdict=None):
795
+ """get the config attribute corresponding to opt
796
+ """
797
+ if optdict is None:
798
+ optdict = self.get_option_def(opt)
799
+ return optdict.get('dest', opt.replace('-', '_'))
800
+ option_name = deprecated('[0.60] OptionsProviderMixIn.option_name() was renamed to option_attrname()')(option_attrname)
801
+
802
+ def option_value(self, opt):
803
+ """get the current value for the given option"""
804
+ return getattr(self.config, self.option_attrname(opt), None)
805
+
806
+ def set_option(self, opt, value, action=None, optdict=None):
807
+ """method called to set an option (registered in the options list)
808
+ """
809
+ if optdict is None:
810
+ optdict = self.get_option_def(opt)
811
+ if value is not None:
812
+ value = _validate(value, optdict, opt)
813
+ if action is None:
814
+ action = optdict.get('action', 'store')
815
+ if optdict.get('type') == 'named': # XXX need specific handling
816
+ optname = self.option_attrname(opt, optdict)
817
+ currentvalue = getattr(self.config, optname, None)
818
+ if currentvalue:
819
+ currentvalue.update(value)
820
+ value = currentvalue
821
+ if action == 'store':
822
+ setattr(self.config, self.option_attrname(opt, optdict), value)
823
+ elif action in ('store_true', 'count'):
824
+ setattr(self.config, self.option_attrname(opt, optdict), 0)
825
+ elif action == 'store_false':
826
+ setattr(self.config, self.option_attrname(opt, optdict), 1)
827
+ elif action == 'append':
828
+ opt = self.option_attrname(opt, optdict)
829
+ _list = getattr(self.config, opt, None)
830
+ if _list is None:
831
+ if isinstance(value, (list, tuple)):
832
+ _list = value
833
+ elif value is not None:
834
+ _list = []
835
+ _list.append(value)
836
+ setattr(self.config, opt, _list)
837
+ elif isinstance(_list, tuple):
838
+ setattr(self.config, opt, _list + (value,))
839
+ else:
840
+ _list.append(value)
841
+ elif action == 'callback':
842
+ optdict['callback'](None, opt, value, None)
843
+ else:
844
+ raise UnsupportedAction(action)
845
+
846
+ def input_option(self, option, optdict, inputlevel=99):
847
+ default = self.option_default(option, optdict)
848
+ if default is REQUIRED:
849
+ defaultstr = '(required): '
850
+ elif optdict.get('level', 0) > inputlevel:
851
+ return
852
+ elif optdict['type'] == 'password' or default is None:
853
+ defaultstr = ': '
854
+ else:
855
+ defaultstr = '(default: %s): ' % format_option_value(optdict, default)
856
+ print ':%s:' % option
857
+ print optdict.get('help') or option
858
+ inputfunc = INPUT_FUNCTIONS[optdict['type']]
859
+ value = inputfunc(optdict, defaultstr)
860
+ while default is REQUIRED and not value:
861
+ print 'please specify a value'
862
+ value = inputfunc(optdict, '%s: ' % option)
863
+ if value is None and default is not None:
864
+ value = default
865
+ self.set_option(option, value, optdict=optdict)
866
+
867
+ def get_option_def(self, opt):
868
+ """return the dictionary defining an option given it's name"""
869
+ assert self.options
870
+ for option in self.options:
871
+ if option[0] == opt:
872
+ return option[1]
873
+ raise OptionError('no such option %s in section %r'
874
+ % (opt, self.name), opt)
875
+
876
+
877
+ def all_options(self):
878
+ """return an iterator on available options for this provider
879
+ option are actually described by a 3-uple:
880
+ (section, option name, option dictionary)
881
+ """
882
+ for section, options in self.options_by_section():
883
+ if section is None:
884
+ if self.name is None:
885
+ continue
886
+ section = self.name.upper()
887
+ for option, optiondict, value in options:
888
+ yield section, option, optiondict
889
+
890
+ def options_by_section(self):
891
+ """return an iterator on options grouped by section
892
+
893
+ (section, [list of (optname, optdict, optvalue)])
894
+ """
895
+ sections = {}
896
+ for optname, optdict in self.options:
897
+ sections.setdefault(optdict.get('group'), []).append(
898
+ (optname, optdict, self.option_value(optname)))
899
+ if None in sections:
900
+ yield None, sections.pop(None)
901
+ for section, options in sections.items():
902
+ yield section.upper(), options
903
+
904
+ def options_and_values(self, options=None):
905
+ if options is None:
906
+ options = self.options
907
+ for optname, optdict in options:
908
+ yield (optname, optdict, self.option_value(optname))
909
+
910
+ # configuration ################################################################
911
+
912
+ class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn):
913
+ """basic mixin for simple configurations which don't need the
914
+ manager / providers model
915
+ """
916
+ def __init__(self, *args, **kwargs):
917
+ if not args:
918
+ kwargs.setdefault('usage', '')
919
+ kwargs.setdefault('quiet', 1)
920
+ OptionsManagerMixIn.__init__(self, *args, **kwargs)
921
+ OptionsProviderMixIn.__init__(self)
922
+ if not getattr(self, 'option_groups', None):
923
+ self.option_groups = []
924
+ for option, optdict in self.options:
925
+ try:
926
+ gdef = (optdict['group'].upper(), '')
927
+ except KeyError:
928
+ continue
929
+ if not gdef in self.option_groups:
930
+ self.option_groups.append(gdef)
931
+ self.register_options_provider(self, own_group=False)
932
+
933
+ def register_options(self, options):
934
+ """add some options to the configuration"""
935
+ options_by_group = {}
936
+ for optname, optdict in options:
937
+ options_by_group.setdefault(optdict.get('group', self.name.upper()), []).append((optname, optdict))
938
+ for group, options in options_by_group.items():
939
+ self.add_option_group(group, None, options, self)
940
+ self.options += tuple(options)
941
+
942
+ def load_defaults(self):
943
+ OptionsProviderMixIn.load_defaults(self)
944
+
945
+ def __iter__(self):
946
+ return iter(self.config.__dict__.iteritems())
947
+
948
+ def __getitem__(self, key):
949
+ try:
950
+ return getattr(self.config, self.option_attrname(key))
951
+ except (optik_ext.OptionValueError, AttributeError):
952
+ raise KeyError(key)
953
+
954
+ def __setitem__(self, key, value):
955
+ self.set_option(key, value)
956
+
957
+ def get(self, key, default=None):
958
+ try:
959
+ return getattr(self.config, self.option_attrname(key))
960
+ except (OptionError, AttributeError):
961
+ return default
962
+
963
+
964
+ class Configuration(ConfigurationMixIn):
965
+ """class for simple configurations which don't need the
966
+ manager / providers model and prefer delegation to inheritance
967
+
968
+ configuration values are accessible through a dict like interface
969
+ """
970
+
971
+ def __init__(self, config_file=None, options=None, name=None,
972
+ usage=None, doc=None, version=None):
973
+ if options is not None:
974
+ self.options = options
975
+ if name is not None:
976
+ self.name = name
977
+ if doc is not None:
978
+ self.__doc__ = doc
979
+ super(Configuration, self).__init__(config_file=config_file, usage=usage, version=version)
980
+
981
+
982
+ class OptionsManager2ConfigurationAdapter(object):
983
+ """Adapt an option manager to behave like a
984
+ `logilab.common.configuration.Configuration` instance
985
+ """
986
+ def __init__(self, provider):
987
+ self.config = provider
988
+
989
+ def __getattr__(self, key):
990
+ return getattr(self.config, key)
991
+
992
+ def __getitem__(self, key):
993
+ provider = self.config._all_options[key]
994
+ try:
995
+ return getattr(provider.config, provider.option_attrname(key))
996
+ except AttributeError:
997
+ raise KeyError(key)
998
+
999
+ def __setitem__(self, key, value):
1000
+ self.config.global_set_option(self.config.option_attrname(key), value)
1001
+
1002
+ def get(self, key, default=None):
1003
+ provider = self.config._all_options[key]
1004
+ try:
1005
+ return getattr(provider.config, provider.option_attrname(key))
1006
+ except AttributeError:
1007
+ return default
1008
+
1009
+ # other functions ##############################################################
1010
+
1011
+ def read_old_config(newconfig, changes, configfile):
1012
+ """initialize newconfig from a deprecated configuration file
1013
+
1014
+ possible changes:
1015
+ * ('renamed', oldname, newname)
1016
+ * ('moved', option, oldgroup, newgroup)
1017
+ * ('typechanged', option, oldtype, newvalue)
1018
+ """
1019
+ # build an index of changes
1020
+ changesindex = {}
1021
+ for action in changes:
1022
+ if action[0] == 'moved':
1023
+ option, oldgroup, newgroup = action[1:]
1024
+ changesindex.setdefault(option, []).append((action[0], oldgroup, newgroup))
1025
+ continue
1026
+ if action[0] == 'renamed':
1027
+ oldname, newname = action[1:]
1028
+ changesindex.setdefault(newname, []).append((action[0], oldname))
1029
+ continue
1030
+ if action[0] == 'typechanged':
1031
+ option, oldtype, newvalue = action[1:]
1032
+ changesindex.setdefault(option, []).append((action[0], oldtype, newvalue))
1033
+ continue
1034
+ if action[1] in ('added', 'removed'):
1035
+ continue # nothing to do here
1036
+ raise Exception('unknown change %s' % action[0])
1037
+ # build a config object able to read the old config
1038
+ options = []
1039
+ for optname, optdef in newconfig.options:
1040
+ for action in changesindex.pop(optname, ()):
1041
+ if action[0] == 'moved':
1042
+ oldgroup, newgroup = action[1:]
1043
+ optdef = optdef.copy()
1044
+ optdef['group'] = oldgroup
1045
+ elif action[0] == 'renamed':
1046
+ optname = action[1]
1047
+ elif action[0] == 'typechanged':
1048
+ oldtype = action[1]
1049
+ optdef = optdef.copy()
1050
+ optdef['type'] = oldtype
1051
+ options.append((optname, optdef))
1052
+ if changesindex:
1053
+ raise Exception('unapplied changes: %s' % changesindex)
1054
+ oldconfig = Configuration(options=options, name=newconfig.name)
1055
+ # read the old config
1056
+ oldconfig.load_file_configuration(configfile)
1057
+ # apply values reverting changes
1058
+ changes.reverse()
1059
+ done = set()
1060
+ for action in changes:
1061
+ if action[0] == 'renamed':
1062
+ oldname, newname = action[1:]
1063
+ newconfig[newname] = oldconfig[oldname]
1064
+ done.add(newname)
1065
+ elif action[0] == 'typechanged':
1066
+ optname, oldtype, newvalue = action[1:]
1067
+ newconfig[optname] = newvalue
1068
+ done.add(optname)
1069
+ for optname, optdef in newconfig.options:
1070
+ if optdef.get('type') and not optname in done:
1071
+ newconfig.set_option(optname, oldconfig[optname], optdict=optdef)
1072
+
1073
+
1074
+ def merge_options(options, optgroup=None):
1075
+ """preprocess a list of options and remove duplicates, returning a new list
1076
+ (tuple actually) of options.
1077
+
1078
+ Options dictionaries are copied to avoid later side-effect. Also, if
1079
+ `otpgroup` argument is specified, ensure all options are in the given group.
1080
+ """
1081
+ alloptions = {}
1082
+ options = list(options)
1083
+ for i in range(len(options)-1, -1, -1):
1084
+ optname, optdict = options[i]
1085
+ if optname in alloptions:
1086
+ options.pop(i)
1087
+ alloptions[optname].update(optdict)
1088
+ else:
1089
+ optdict = optdict.copy()
1090
+ options[i] = (optname, optdict)
1091
+ alloptions[optname] = optdict
1092
+ if optgroup is not None:
1093
+ alloptions[optname]['group'] = optgroup
1094
+ return tuple(options)