You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
5.9KB

  1. """
  2. pylib: rapid testing and development utils
  3. this module uses apipkg.py for lazy-loading sub modules
  4. and classes. The initpkg-dictionary below specifies
  5. name->value mappings where value can be another namespace
  6. dictionary or an import path.
  7. (c) Holger Krekel and others, 2004-2014
  8. """
  9. from py._error import error
  10. try:
  11. from py._vendored_packages import apipkg
  12. lib_not_mangled_by_packagers = True
  13. vendor_prefix = '._vendored_packages.'
  14. except ImportError:
  15. import apipkg
  16. lib_not_mangled_by_packagers = False
  17. vendor_prefix = ''
  18. try:
  19. from ._version import version as __version__
  20. except ImportError:
  21. # broken installation, we don't even try
  22. __version__ = "unknown"
  23. apipkg.initpkg(__name__, attr={'_apipkg': apipkg, 'error': error}, exportdefs={
  24. # access to all standard lib modules
  25. 'std': '._std:std',
  26. '_pydir' : '.__metainfo:pydir',
  27. 'version': 'py:__version__', # backward compatibility
  28. # pytest-2.0 has a flat namespace, we use alias modules
  29. # to keep old references compatible
  30. 'test' : 'pytest',
  31. # hook into the top-level standard library
  32. 'process' : {
  33. '__doc__' : '._process:__doc__',
  34. 'cmdexec' : '._process.cmdexec:cmdexec',
  35. 'kill' : '._process.killproc:kill',
  36. 'ForkedFunc' : '._process.forkedfunc:ForkedFunc',
  37. },
  38. 'apipkg' : {
  39. 'initpkg' : vendor_prefix + 'apipkg:initpkg',
  40. 'ApiModule' : vendor_prefix + 'apipkg:ApiModule',
  41. },
  42. 'iniconfig' : {
  43. 'IniConfig' : vendor_prefix + 'iniconfig:IniConfig',
  44. 'ParseError' : vendor_prefix + 'iniconfig:ParseError',
  45. },
  46. 'path' : {
  47. '__doc__' : '._path:__doc__',
  48. 'svnwc' : '._path.svnwc:SvnWCCommandPath',
  49. 'svnurl' : '._path.svnurl:SvnCommandPath',
  50. 'local' : '._path.local:LocalPath',
  51. 'SvnAuth' : '._path.svnwc:SvnAuth',
  52. },
  53. # python inspection/code-generation API
  54. 'code' : {
  55. '__doc__' : '._code:__doc__',
  56. 'compile' : '._code.source:compile_',
  57. 'Source' : '._code.source:Source',
  58. 'Code' : '._code.code:Code',
  59. 'Frame' : '._code.code:Frame',
  60. 'ExceptionInfo' : '._code.code:ExceptionInfo',
  61. 'Traceback' : '._code.code:Traceback',
  62. 'getfslineno' : '._code.source:getfslineno',
  63. 'getrawcode' : '._code.code:getrawcode',
  64. 'patch_builtins' : '._code.code:patch_builtins',
  65. 'unpatch_builtins' : '._code.code:unpatch_builtins',
  66. '_AssertionError' : '._code.assertion:AssertionError',
  67. '_reinterpret_old' : '._code.assertion:reinterpret_old',
  68. '_reinterpret' : '._code.assertion:reinterpret',
  69. '_reprcompare' : '._code.assertion:_reprcompare',
  70. '_format_explanation' : '._code.assertion:_format_explanation',
  71. },
  72. # backports and additions of builtins
  73. 'builtin' : {
  74. '__doc__' : '._builtin:__doc__',
  75. 'enumerate' : '._builtin:enumerate',
  76. 'reversed' : '._builtin:reversed',
  77. 'sorted' : '._builtin:sorted',
  78. 'any' : '._builtin:any',
  79. 'all' : '._builtin:all',
  80. 'set' : '._builtin:set',
  81. 'frozenset' : '._builtin:frozenset',
  82. 'BaseException' : '._builtin:BaseException',
  83. 'GeneratorExit' : '._builtin:GeneratorExit',
  84. '_sysex' : '._builtin:_sysex',
  85. 'print_' : '._builtin:print_',
  86. '_reraise' : '._builtin:_reraise',
  87. '_tryimport' : '._builtin:_tryimport',
  88. 'exec_' : '._builtin:exec_',
  89. '_basestring' : '._builtin:_basestring',
  90. '_totext' : '._builtin:_totext',
  91. '_isbytes' : '._builtin:_isbytes',
  92. '_istext' : '._builtin:_istext',
  93. '_getimself' : '._builtin:_getimself',
  94. '_getfuncdict' : '._builtin:_getfuncdict',
  95. '_getcode' : '._builtin:_getcode',
  96. 'builtins' : '._builtin:builtins',
  97. 'execfile' : '._builtin:execfile',
  98. 'callable' : '._builtin:callable',
  99. 'bytes' : '._builtin:bytes',
  100. 'text' : '._builtin:text',
  101. },
  102. # input-output helping
  103. 'io' : {
  104. '__doc__' : '._io:__doc__',
  105. 'dupfile' : '._io.capture:dupfile',
  106. 'TextIO' : '._io.capture:TextIO',
  107. 'BytesIO' : '._io.capture:BytesIO',
  108. 'FDCapture' : '._io.capture:FDCapture',
  109. 'StdCapture' : '._io.capture:StdCapture',
  110. 'StdCaptureFD' : '._io.capture:StdCaptureFD',
  111. 'TerminalWriter' : '._io.terminalwriter:TerminalWriter',
  112. 'ansi_print' : '._io.terminalwriter:ansi_print',
  113. 'get_terminal_width' : '._io.terminalwriter:get_terminal_width',
  114. 'saferepr' : '._io.saferepr:saferepr',
  115. },
  116. # small and mean xml/html generation
  117. 'xml' : {
  118. '__doc__' : '._xmlgen:__doc__',
  119. 'html' : '._xmlgen:html',
  120. 'Tag' : '._xmlgen:Tag',
  121. 'raw' : '._xmlgen:raw',
  122. 'Namespace' : '._xmlgen:Namespace',
  123. 'escape' : '._xmlgen:escape',
  124. },
  125. 'log' : {
  126. # logging API ('producers' and 'consumers' connected via keywords)
  127. '__doc__' : '._log:__doc__',
  128. '_apiwarn' : '._log.warning:_apiwarn',
  129. 'Producer' : '._log.log:Producer',
  130. 'setconsumer' : '._log.log:setconsumer',
  131. '_setstate' : '._log.log:setstate',
  132. '_getstate' : '._log.log:getstate',
  133. 'Path' : '._log.log:Path',
  134. 'STDOUT' : '._log.log:STDOUT',
  135. 'STDERR' : '._log.log:STDERR',
  136. 'Syslog' : '._log.log:Syslog',
  137. },
  138. })