rbimporter.py
Go to the documentation of this file.
1 import sys
2 import __builtin__
3 
4 rollbackImporter = None
5 
7  def __init__(self):
8  self.previousModules = []
9  for k in sys.modules.keys():
10  self.previousModules.append(k)
11  self.realImport = __builtin__.__import__
12  __builtin__.__import__ = self._import
13  self.newModules = {}
14 
15  def _import(self, *args):
16  n = args[0]
17  f = args[3]
18  try:
19  g = args[1]
20  except:
21  g = {}
22  try:
23  l = args[2]
24  except:
25  l = {}
26  result = apply(self.realImport, (n, g, l, f))
27  self.newModules[n] = 1
28  return result
29 
30  def uninstall(self):
31  for m in self.newModules.keys():
32  if m not in self.previousModules:
33  del(sys.modules[m])
34  __builtin__.__import__ = self.realImport
35 
36 def refresh():
37  global rollbackImporter
38  if rollbackImporter:
39  rollbackImporter.uninstall()
40  rollbackImporter = RollbackImporter()
41 
42 refresh()
def refresh()
Definition: rbimporter.py:36
def _import(self, args)
Definition: rbimporter.py:15


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05