本文整理汇总了Python中cmakefile_editor.CMakeFileEditor.remove_value方法的典型用法代码示例。如果您正苦于以下问题:Python CMakeFileEditor.remove_value方法的具体用法?Python CMakeFileEditor.remove_value怎么用?Python CMakeFileEditor.remove_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmakefile_editor.CMakeFileEditor
的用法示例。
在下文中一共展示了CMakeFileEditor.remove_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_subdir
# 需要导入模块: from cmakefile_editor import CMakeFileEditor [as 别名]
# 或者: from cmakefile_editor.CMakeFileEditor import remove_value [as 别名]
def _run_subdir(self, path, globs, makefile_vars, cmakeedit_func=None):
""" Delete all files that match a certain pattern in path.
path - The directory in which this will take place
globs - A tuple of standard UNIX globs of files to delete (e.g. *.xml)
makefile_vars - A tuple with a list of CMakeLists.txt-variables which
may contain references to the globbed files
cmakeedit_func - If the CMakeLists.txt needs special editing, use this
"""
# 1. Create a filtered list
files = []
for g in globs:
files = files + sorted(glob.glob("%s/%s"% (path, g)))
files_filt = []
print "Searching for matching files in %s/:" % path
for f in files:
if re.search(self._info['pattern'], os.path.basename(f)) is not None:
files_filt.append(f)
if not files_filt:
print "None found."
return []
# 2. Delete files, Makefile entries and other occurrences
files_deleted = []
ed = CMakeFileEditor('%s/CMakeLists.txt' % path)
yes = self._info['yes']
for f in files_filt:
b = os.path.basename(f)
if not yes:
ans = raw_input("Really delete %s? [Y/n/a/q]: " % f).lower().strip()
if ans == 'a':
yes = True
if ans == 'q':
sys.exit(0)
if ans == 'n':
continue
files_deleted.append(b)
print "Deleting %s." % f
self.scm.remove_file(f)
os.unlink(f)
print "Deleting occurrences of %s from %s/CMakeLists.txt..." % (b, path)
for var in makefile_vars:
ed.remove_value(var, b)
if cmakeedit_func is not None:
cmakeedit_func(b, ed)
ed.write()
self.scm.mark_files_updated(('%s/CMakeLists.txt' % path,))
return files_deleted