本文整理汇总了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)
示例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()
示例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."