john-bodley commented on code in PR #24578:
URL: https://github.com/apache/superset/pull/24578#discussion_r1252270728
##########
superset/examples/utils.py:
##########
@@ -44,28 +44,30 @@ def load_examples_from_configs(
def load_contents(load_test_data: bool = False) -> dict[str, Any]:
"""Traverse configs directory and load contents"""
- root = Path("examples/configs")
- resource_names = resource_listdir("superset", str(root))
- queue = [root / resource_name for resource_name in resource_names]
+ root = files("superset") / "examples/configs"
+ resource_names = (files("superset") / str(root)).iterdir()
+ queue = [root / str(resource_name) for resource_name in resource_names]
contents: dict[Path, str] = {}
while queue:
path_name = queue.pop()
test_re = re.compile(r"\.test\.|metadata\.yaml$")
- if resource_isdir("superset", str(path_name)):
+ if (files("superset") / str(path_name)).is_dir():
queue.extend(
- path_name / child_name
- for child_name in resource_listdir("superset", str(path_name))
+ path_name / str(child_name)
+ for child_name in (files("superset") /
str(path_name)).iterdir()
)
- elif path_name.suffix.lower() in YAML_EXTENSIONS:
+ elif Path(str(path_name)).suffix.lower() in YAML_EXTENSIONS:
Review Comment:
Same comment as previously.
##########
superset/examples/utils.py:
##########
@@ -44,28 +44,30 @@ def load_examples_from_configs(
def load_contents(load_test_data: bool = False) -> dict[str, Any]:
"""Traverse configs directory and load contents"""
- root = Path("examples/configs")
- resource_names = resource_listdir("superset", str(root))
- queue = [root / resource_name for resource_name in resource_names]
+ root = files("superset") / "examples/configs"
+ resource_names = (files("superset") / str(root)).iterdir()
+ queue = [root / str(resource_name) for resource_name in resource_names]
contents: dict[Path, str] = {}
while queue:
path_name = queue.pop()
test_re = re.compile(r"\.test\.|metadata\.yaml$")
- if resource_isdir("superset", str(path_name)):
+ if (files("superset") / str(path_name)).is_dir():
queue.extend(
- path_name / child_name
- for child_name in resource_listdir("superset", str(path_name))
+ path_name / str(child_name)
Review Comment:
Why is `str(...)` needed here?
##########
superset/examples/utils.py:
##########
@@ -44,28 +44,30 @@ def load_examples_from_configs(
def load_contents(load_test_data: bool = False) -> dict[str, Any]:
"""Traverse configs directory and load contents"""
- root = Path("examples/configs")
- resource_names = resource_listdir("superset", str(root))
- queue = [root / resource_name for resource_name in resource_names]
+ root = files("superset") / "examples/configs"
+ resource_names = (files("superset") / str(root)).iterdir()
+ queue = [root / str(resource_name) for resource_name in resource_names]
contents: dict[Path, str] = {}
while queue:
path_name = queue.pop()
test_re = re.compile(r"\.test\.|metadata\.yaml$")
- if resource_isdir("superset", str(path_name)):
+ if (files("superset") / str(path_name)).is_dir():
queue.extend(
- path_name / child_name
- for child_name in resource_listdir("superset", str(path_name))
+ path_name / str(child_name)
+ for child_name in (files("superset") /
str(path_name)).iterdir()
)
- elif path_name.suffix.lower() in YAML_EXTENSIONS:
+ elif Path(str(path_name)).suffix.lower() in YAML_EXTENSIONS:
if load_test_data and test_re.search(str(path_name)) is None:
continue
- contents[path_name] = (
- resource_stream("superset",
str(path_name)).read().decode("utf-8")
- )
+ contents[Path(str(path_name))] = (
Review Comment:
Same comment as previously.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]