main_util.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:raw-data-repository 作者: all-of-us 项目源码 文件源码
def get_parser(description=None):
  """Gets an ArgumentParser, defaulting to the caller's __doc__ as the description."""
  if description is None:
    caller_frame = inspect.stack()[1]
    caller_path = caller_frame[1]
    caller_module_name = inspect.getmodulename(caller_path)
    try:
      caller_module = importlib.import_module(caller_module_name)
      doc = caller_module.__doc__
    except ImportError:
      logging.error(
          'Could not auto-detect __doc__ for parser description for module %r, '
          'derived from caller path %r.',
          caller_module_name,
          caller_path)
      doc = None
  else:
    doc = description
  return argparse.ArgumentParser(
      description=doc,
      formatter_class=argparse.RawDescriptionHelpFormatter)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号