Aestate
CompulsoryRun.py
Go to the documentation of this file.
1 class Compulsory(object):
2  @staticmethod
3  def run_function(func, args, kwargs):
4  """
5  强制执行
6  """
7  try:
8  return func(*args, **kwargs)
9  except TypeError as e:
10  pass
11 
12  try:
13  return func(*args)
14  except TypeError as e:
15  pass
16 
17  try:
18  return func(**kwargs)
19  except TypeError as e:
20  pass
21 
22  try:
23  return func()
24  except TypeError as e:
25  pass
26 
27  return None
28 
29  @staticmethod
30  def search_target(module, target_names):
31 
32  """
33  深度搜素树
34  """
35 
36  from aestate.util.Log import ALog
37 
38  if len(target_names) == 0:
39  return module
40  # 当前的标记位置
41  now_target = target_names[0]
42  del target_names[0]
43  if hasattr(module, now_target):
44  next_module = getattr(module, now_target)
45  return Compulsory.search_target(next_module, target_names)
46  else:
47  ALog.log_error(f'The package name does not exist in the search tree: {now_target}, please check ' +
48  'whether the package name is filled in correctly', ImportError, raise_exception=True)
aestate.util.CompulsoryRun.Compulsory
Definition: CompulsoryRun.py:1
aestate.util.CompulsoryRun.Compulsory.run_function
def run_function(func, args, kwargs)
Definition: CompulsoryRun.py:3
aestate.util.Log
Definition: Log.py:1
aestate.util.CompulsoryRun.Compulsory.search_target
def search_target(module, target_names)
Definition: CompulsoryRun.py:30