本文整理汇总了Python中pip.backwardcompat.StringIO方法的典型用法代码示例。如果您正苦于以下问题:Python backwardcompat.StringIO方法的具体用法?Python backwardcompat.StringIO怎么用?Python backwardcompat.StringIO使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip.backwardcompat
的用法示例。
在下文中一共展示了backwardcompat.StringIO方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_entrypoints
# 需要导入模块: from pip import backwardcompat [as 别名]
# 或者: from pip.backwardcompat import StringIO [as 别名]
def get_entrypoints(filename):
if not os.path.exists(filename):
return {}, {}
# This is done because you can pass a string to entry_points wrappers which
# means that they may or may not be valid INI files. The attempt here is to
# strip leading and trailing whitespace in order to make them valid INI
# files.
with open(filename) as fp:
data = StringIO()
for line in fp:
data.write(line.strip())
data.write("\n")
data.seek(0)
cp = ConfigParser.RawConfigParser()
cp.readfp(data)
console = {}
gui = {}
if cp.has_section('console_scripts'):
console = dict(cp.items('console_scripts'))
if cp.has_section('gui_scripts'):
gui = dict(cp.items('gui_scripts'))
return console, gui
示例2: format_exc
# 需要导入模块: from pip import backwardcompat [as 别名]
# 或者: from pip.backwardcompat import StringIO [as 别名]
def format_exc(exc_info=None):
if exc_info is None:
exc_info = sys.exc_info()
out = StringIO()
traceback.print_exception(*exc_info, **dict(file=out))
return out.getvalue()