本文整理汇总了Python中FileUtils.strip_file_extension方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.strip_file_extension方法的具体用法?Python FileUtils.strip_file_extension怎么用?Python FileUtils.strip_file_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.strip_file_extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testStripFileExtension
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import strip_file_extension [as 别名]
def testStripFileExtension(self):
files = (
("test.c", "test"),
("test.o", "test"),
("test.s", "test"),
("test.S", "test"),
("test.i", "test"),
("test.ii", "test"),
("test", "test"),
("test.c.o", "test.c"),
(".test.c", ".test"),
("../../../../.test.c", "../../../../.test"),
("./.test.c.c", "./.test.c"),
("../../test.o.c.ii", "../../test.o.c")
)
for file in files:
self.assertEqual(FileUtils.strip_file_extension(file[0]), file[1])
示例2: get_output_file_name_for_step
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import strip_file_extension [as 别名]
def get_output_file_name_for_step(self, input_file, stop_step):
"""Take a filename as input, and return the name of the file
that will be output if we execute the command :
gcc -stop_step filename."""
# associate a stop level to the corresponding output
# filename extension
# 1 is stoping after preprocessing and before compilation
# 2 is stoping after compilation and before assembly
# 3 is stoping after assembly and before linking
output_extensions = {1: ".i", 2: ".s", 3: ".o"}
start_level = get_start_step_of_file(input_file)
if start_level > stop_step:
# here we want the compilation process to stop when it starts,
# so nothing is output
return ""
else:
new_ext = output_extensions[stop_step]
return FileUtils.strip_file_extension(input_file) + new_ext