本文整理汇总了Python中util.Util.remove_file方法的典型用法代码示例。如果您正苦于以下问题:Python Util.remove_file方法的具体用法?Python Util.remove_file怎么用?Python Util.remove_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.remove_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import remove_file [as 别名]
def build(self, is_main=False, is_method=False, is_class=False):
'''
Copies the base java file, moves the changes into it and compiles it.
If an Exception occurs, the change is rolled back.
'''
shutil.copyfile(START_FILE, MAIN_FILE)
self.parse_file(MAIN_FILE)
# Attempt to compile the new change
try:
Util.compile_java([MAIN_FILE] + self.full_class_names)
except Exception as e:
if verbose_output == True:
print 'Exception: %s' % e
else:
print 'An Exception occurred compiling the program'
# Determine who caused the exception and remove the code
if is_main is True:
self.main_input.pop()
elif is_method is True:
self.methods.pop()
self.method_names.pop()
elif is_class is True:
self.classes.pop()
self.class_names.pop()
filename = self.full_class_names.pop()
Util.remove_file(filename)
return
if is_main is True:
self.run()
示例2: create_class
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import remove_file [as 别名]
def create_class(self):
'''
Create a new file using the class name, and then copy the class
contents into the new file.
'''
filename = "%s.%s" % (self.class_names[-1], 'java')
Util.remove_file(filename)
self.full_class_names.append(filename)
file = open(filename, 'w+')
file.write(self.classes[-1])
file.close()