本文整理汇总了Python中src.file_utils.exists方法的典型用法代码示例。如果您正苦于以下问题:Python file_utils.exists方法的具体用法?Python file_utils.exists怎么用?Python file_utils.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.file_utils
的用法示例。
在下文中一共展示了file_utils.exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_semantic_maps
# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import exists [as 别名]
def _get_semantic_maps(folder_name, building_name, map, flip):
# Load file from the cache.
file_name = '{:s}_{:d}_{:d}_{:d}_{:d}_{:d}_{:d}.pkl'
file_name = file_name.format(building_name, map.size[0], map.size[1],
map.origin[0], map.origin[1], map.resolution,
flip)
file_name = os.path.join(folder_name, file_name)
logging.info('Loading semantic maps from %s.', file_name)
if fu.exists(file_name):
a = utils.load_variables(file_name)
maps = a['maps'] #HxWx#C
cats = a['cats']
else:
logging.error('file_name: %s not found.', file_name)
maps = None
cats = None
return maps, cats
示例2: mkdir_if_missing
# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import exists [as 别名]
def mkdir_if_missing(output_dir):
if not fu.exists(output_dir):
fu.makedirs(output_dir)
示例3: save_variables
# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import exists [as 别名]
def save_variables(pickle_file_name, var, info, overwrite = False):
if fu.exists(pickle_file_name) and overwrite == False:
raise Exception('{:s} exists and over write is false.'.format(pickle_file_name))
# Construct the dictionary
assert(type(var) == list); assert(type(info) == list);
d = {}
for i in xrange(len(var)):
d[info[i]] = var[i]
with fu.fopen(pickle_file_name, 'w') as f:
cPickle.dump(d, f, cPickle.HIGHEST_PROTOCOL)
示例4: load_variables
# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import exists [as 别名]
def load_variables(pickle_file_name):
if fu.exists(pickle_file_name):
with fu.fopen(pickle_file_name, 'r') as f:
d = cPickle.load(f)
return d
else:
raise Exception('{:s} does not exists.'.format(pickle_file_name))
示例5: get_meta_data
# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import exists [as 别名]
def get_meta_data(self, file_name, data_dir=None):
if data_dir is None:
data_dir = self.get_data_dir()
full_file_name = os.path.join(data_dir, 'meta', file_name)
assert(fu.exists(full_file_name)), \
'{:s} does not exist'.format(full_file_name)
ext = os.path.splitext(full_file_name)[1]
if ext == '.txt':
ls = []
with fu.fopen(full_file_name, 'r') as f:
for l in f:
ls.append(l.rstrip())
elif ext == '.pkl':
ls = utils.load_variables(full_file_name)
return ls