本文整理汇总了Python中util.config.Config.batch方法的典型用法代码示例。如果您正苦于以下问题:Python Config.batch方法的具体用法?Python Config.batch怎么用?Python Config.batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.config.Config
的用法示例。
在下文中一共展示了Config.batch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_directory
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import batch [as 别名]
def clear_directory(font_root, type, basename):
"""
Remove existing links to a font in a dir to prevent inconsistencies.
If physical copies are encountered the user is asked if he wants
to remove them (and then if that decision should be remembered).
In batch mode this would simply cause the program to fail.
"""
target_dir = os.path.join(font_root, type)
real_files = []
for ln in os.listdir(target_dir):
abs_ln = os.path.join(target_dir, ln)
if ln.startswith(basename):
if os.path.islink(abs_ln):
os.unlink(abs_ln)
elif os.path.isfile(abs_ln):
real_files.append(abs_ln)
if real_files:
if Config.batch():
# the files will fail later when trying to link them
pass
else:
# handle the presence of physical font files
if Config.remove_existing_files:
for f in real_files:
os.remove(f)
else:
print "The following font files are phyiscal copies:"
for f in real_files:
print " -", f
rem = raw_input("Do you want to remove them and replace them with links (y/anything)? ")
rem = True if rem.lower() == 'y' else False
if rem:
for f in real_files:
os.remove(f)
print "Done."
remember = raw_input("Do you want to remember this decision (y/anything)? ")
Config.remove_existing_files = rem if remember.lower() == 'y' else False