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


Python Utilities.files_exist方法代码示例

本文整理汇总了Python中utilities.Utilities.files_exist方法的典型用法代码示例。如果您正苦于以下问题:Python Utilities.files_exist方法的具体用法?Python Utilities.files_exist怎么用?Python Utilities.files_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utilities.Utilities的用法示例。


在下文中一共展示了Utilities.files_exist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_data

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import files_exist [as 别名]
 def load_data(self):
     """
     Loads persisted data on disk, if it exists, into our L{GraphStructure}
     object.
     """
     if Utilities.files_exist(self.graph_file, self.id_file):
         self.gstorage.load_graph(self.graph_file, self.id_file)
开发者ID:Sreeni34,项目名称:DropDatabase,代码行数:9,代码来源:load_data.py

示例2: load_graph

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import files_exist [as 别名]
    def load_graph(self, graph_file, id_file):
        """
        Loads the L{GraphStructure} object from two files. The first file
        persists the in-memory graph data while the second file persists
        the unique ids. The two files must exist or else nothing will happen.

        @type graph_file: String
        @param graph_file: File to store the in-memory graph structure
        @type id_file: String
        @param id_file: File to store unique id number
        """

        if not Utilities.files_exist(graph_file, id_file):
            print 'One or more files does not exist' 
            return

        # Stores graph data from file and loads it to internal graph
        # self.gs.set_graph(nx.read_graphml(graph_file))
        # self.gs.set_graph(nx.read_gpickle(graph_file))
        f1 = open(graph_file, 'r')
        self.gs.set_graph(pickle.load(f1))
        f1.close()

        # Read current id from file to GraphStructure
        f2 = open(id_file, 'r')
        val = f2.readline().strip()
        if val == "":
            val = 0
        self.gs.set_id(int(val))
        f2.close()
开发者ID:Sreeni34,项目名称:DropDatabase,代码行数:32,代码来源:graph_storage.py

示例3: load_persistent_data

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import files_exist [as 别名]
 def load_persistent_data(self):
     """
     Loads persisted data on disk, if it exists, into our GraphStructure
     object.
     """
     print "Loading database from disk..."
     if Utilities.files_exist(self.graph_file, self.id_file):
         self.gstorage.load_graph(self.graph_file, self.id_file)
         print "Finished loading database from disk."
     else:
         print "No files to load from."
开发者ID:Sreeni34,项目名称:DropDatabase,代码行数:13,代码来源:start.py


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