当前位置: 首页>>代码示例>>Python>>正文


Python Util.remove_file方法代码示例

本文整理汇总了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()
开发者ID:aeggum,项目名称:JavaConsole,代码行数:35,代码来源:console.py

示例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()
开发者ID:aeggum,项目名称:JavaConsole,代码行数:14,代码来源:console.py


注:本文中的util.Util.remove_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。