Restore the relative path handling portion of #11865
This commit is contained in:
parent
26d5a17b59
commit
e8452c864e
2 changed files with 7 additions and 3 deletions
|
@ -112,15 +112,19 @@ class DataLoader():
|
||||||
return parsed_data
|
return parsed_data
|
||||||
|
|
||||||
def path_exists(self, path):
|
def path_exists(self, path):
|
||||||
|
path = self.path_dwim(path)
|
||||||
return os.path.exists(path)
|
return os.path.exists(path)
|
||||||
|
|
||||||
def is_file(self, path):
|
def is_file(self, path):
|
||||||
|
path = self.path_dwim(path)
|
||||||
return os.path.isfile(path)
|
return os.path.isfile(path)
|
||||||
|
|
||||||
def is_directory(self, path):
|
def is_directory(self, path):
|
||||||
|
path = self.path_dwim(path)
|
||||||
return os.path.isdir(path)
|
return os.path.isdir(path)
|
||||||
|
|
||||||
def list_directory(self, path):
|
def list_directory(self, path):
|
||||||
|
path = self.path_dwim(path)
|
||||||
return os.listdir(path)
|
return os.listdir(path)
|
||||||
|
|
||||||
def _safe_load(self, stream, file_name=None):
|
def _safe_load(self, stream, file_name=None):
|
||||||
|
|
|
@ -29,11 +29,11 @@ class DictDataLoader(DataLoader):
|
||||||
def __init__(self, file_mapping=dict()):
|
def __init__(self, file_mapping=dict()):
|
||||||
assert type(file_mapping) == dict
|
assert type(file_mapping) == dict
|
||||||
|
|
||||||
|
super(DictDataLoader, self).__init__()
|
||||||
|
|
||||||
self._file_mapping = file_mapping
|
self._file_mapping = file_mapping
|
||||||
self._build_known_directories()
|
self._build_known_directories()
|
||||||
|
|
||||||
super(DictDataLoader, self).__init__()
|
|
||||||
|
|
||||||
def load_from_file(self, path):
|
def load_from_file(self, path):
|
||||||
if path in self._file_mapping:
|
if path in self._file_mapping:
|
||||||
return self.load(self._file_mapping[path], path)
|
return self.load(self._file_mapping[path], path)
|
||||||
|
@ -73,7 +73,7 @@ class DictDataLoader(DataLoader):
|
||||||
rebuild_dirs = False
|
rebuild_dirs = False
|
||||||
if path not in self._file_mapping:
|
if path not in self._file_mapping:
|
||||||
rebuild_dirs = True
|
rebuild_dirs = True
|
||||||
|
|
||||||
self._file_mapping[path] = content
|
self._file_mapping[path] = content
|
||||||
|
|
||||||
if rebuild_dirs:
|
if rebuild_dirs:
|
||||||
|
|
Loading…
Reference in a new issue