OpenDroneMap-ODM/opendm/io.py

49 wiersze
988 B
Python
Czysty Zwykły widok Historia

2015-11-26 12:15:02 +00:00
import os
2017-05-12 22:47:28 +00:00
import shutil, errno
2015-11-26 12:15:02 +00:00
2015-11-26 12:15:02 +00:00
def get_files_list(path_dir):
return os.listdir(path_dir)
2015-11-26 12:15:02 +00:00
def absolute_path_file(path_file):
return os.path.abspath(path_file)
2015-11-26 12:15:02 +00:00
def extract_file_from_path_file(path_file):
path, file = os.path.split(path_file)
return file
2015-11-26 12:15:02 +00:00
def extract_path_from_file(file):
path_file = os.path.abspath(os.path.dirname(file))
path, file = os.path.split(path_file)
return path
2015-11-26 12:15:02 +00:00
def join_paths(path1, path2):
return os.path.join(path1, path2)
2015-11-26 12:15:02 +00:00
def file_exists(path_file):
return os.path.isfile(path_file)
2015-12-02 11:16:30 +00:00
def dir_exists(dirname):
return os.path.isdir(dirname)
2017-05-12 22:47:28 +00:00
def copy(src, dst):
try:
shutil.copytree(src, dst)
except OSError as e:
if e.errno == errno.ENOTDIR:
shutil.copy(src, dst)
else: raise
# find a file in the root directory
def find(filename, folder):
for root, dirs, files in os.walk(folder):
return '/'.join((root, filename)) if filename in files else None