Python future.standard_library.install_hooks() Examples
The following are 30
code examples of future.standard_library.install_hooks().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
future.standard_library
, or try the search function
.
Example #1
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def detect_hooks(): """ Returns True if the import hooks are installed, False if not. """ flog.debug('Detecting hooks ...') present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path]) if present: flog.debug('Detected.') else: flog.debug('Not detected.') return present # As of v0.12, this no longer happens implicitly: # if not PY3: # install_hooks()
Example #2
Source File: __init__.py From blackmamba with MIT License | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #3
Source File: __init__.py From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #4
Source File: __init__.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #5
Source File: test_requests.py From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 | 6 votes |
def test_remove_hooks_then_requests(self): code = """ from future import standard_library standard_library.install_hooks() import builtins import http.client import html.parser """ with write_module(code, self.tempdir): import test_imports_future_stdlib standard_library.remove_hooks() try: import requests except ImportError: print("Requests doesn't seem to be available. Skipping requests test ...") else: r = requests.get('http://google.com') self.assertTrue(r) self.assertTrue(True)
Example #6
Source File: __init__.py From deepWordBug with Apache License 2.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #7
Source File: __init__.py From arissploit with GNU General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #8
Source File: __init__.py From arissploit with GNU General Public License v3.0 | 6 votes |
def detect_hooks(): """ Returns True if the import hooks are installed, False if not. """ flog.debug('Detecting hooks ...') present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path]) if present: flog.debug('Detected.') else: flog.debug('Not detected.') return present # As of v0.12, this no longer happens implicitly: # if not PY3: # install_hooks()
Example #9
Source File: __init__.py From addon with GNU General Public License v3.0 | 6 votes |
def detect_hooks(): """ Returns True if the import hooks are installed, False if not. """ flog.debug('Detecting hooks ...') present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path]) if present: flog.debug('Detected.') else: flog.debug('Not detected.') return present # As of v0.12, this no longer happens implicitly: # if not PY3: # install_hooks()
Example #10
Source File: __init__.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #11
Source File: __init__.py From telegram-robot-rss with Mozilla Public License 2.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #12
Source File: __init__.py From addon with GNU General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #13
Source File: __init__.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #14
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #15
Source File: __init__.py From verge3d-blender-addon with GNU General Public License v3.0 | 6 votes |
def detect_hooks(): """ Returns True if the import hooks are installed, False if not. """ flog.debug('Detecting hooks ...') present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path]) if present: flog.debug('Detected.') else: flog.debug('Not detected.') return present # As of v0.12, this no longer happens implicitly: # if not PY3: # install_hooks()
Example #16
Source File: __init__.py From Tautulli with GNU General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #17
Source File: __init__.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #18
Source File: __init__.py From verge3d-blender-addon with GNU General Public License v3.0 | 6 votes |
def install_hooks(): """ This function installs the future.standard_library import hook into sys.meta_path. """ if PY3: return install_aliases() flog.debug('sys.meta_path was: {0}'.format(sys.meta_path)) flog.debug('Installing hooks ...') # Add it unless it's there already newhook = RenameImport(RENAMES) if not detect_hooks(): sys.meta_path.append(newhook) flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))
Example #19
Source File: __init__.py From blackmamba with MIT License | 5 votes |
def __enter__(self): # flog.debug('Entering hooks context manager') self.old_sys_modules = copy.copy(sys.modules) self.hooks_were_installed = detect_hooks() # self.scrubbed = scrub_py2_sys_modules() install_hooks() return self
Example #20
Source File: __init__.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def __enter__(self): # flog.debug('Entering hooks context manager') self.old_sys_modules = copy.copy(sys.modules) self.hooks_were_installed = detect_hooks() # self.scrubbed = scrub_py2_sys_modules() install_hooks() return self
Example #21
Source File: fix_add_future_standard_library_import.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def transform(self, node, results): # TODO: add a blank line between any __future__ imports and this? touch_import_top(u'future', u'standard_library', node) # TODO: also add standard_library.install_hooks()
Example #22
Source File: __init__.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def enable_hooks(): """ Deprecated. Use install_hooks() instead. This will be removed by ``future`` v1.0. """ install_hooks()
Example #23
Source File: __init__.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def __exit__(self, *args): if self.hooks_were_installed: install_hooks() # restore_sys_modules(self.scrubbed)
Example #24
Source File: __init__.py From blackmamba with MIT License | 5 votes |
def enable_hooks(): """ Deprecated. Use install_hooks() instead. This will be removed by ``future`` v1.0. """ install_hooks()
Example #25
Source File: __init__.py From arissploit with GNU General Public License v3.0 | 5 votes |
def __enter__(self): # flog.debug('Entering hooks context manager') self.old_sys_modules = copy.copy(sys.modules) self.hooks_were_installed = detect_hooks() # self.scrubbed = scrub_py2_sys_modules() install_hooks() return self
Example #26
Source File: __init__.py From blackmamba with MIT License | 5 votes |
def __exit__(self, *args): if self.hooks_were_installed: install_hooks() # restore_sys_modules(self.scrubbed)
Example #27
Source File: __init__.py From addon with GNU General Public License v3.0 | 5 votes |
def __enter__(self): # flog.debug('Entering hooks context manager') self.old_sys_modules = copy.copy(sys.modules) self.hooks_were_installed = detect_hooks() # self.scrubbed = scrub_py2_sys_modules() install_hooks() return self
Example #28
Source File: fix_add_future_standard_library_import.py From blackmamba with MIT License | 5 votes |
def transform(self, node, results): # TODO: add a blank line between any __future__ imports and this? touch_import_top(u'future', u'standard_library', node) # TODO: also add standard_library.install_hooks()
Example #29
Source File: __init__.py From addon with GNU General Public License v3.0 | 5 votes |
def __exit__(self, *args): if self.hooks_were_installed: install_hooks() # restore_sys_modules(self.scrubbed)
Example #30
Source File: __init__.py From addon with GNU General Public License v3.0 | 5 votes |
def enable_hooks(): """ Deprecated. Use install_hooks() instead. This will be removed by ``future`` v1.0. """ install_hooks()