Limiting traversing directories properly, improved not found resource explanation

This commit is contained in:
MaXFeeD
2026-07-31 18:30:44 +03:00
parent 158ef5843d
commit 959ee43782
4 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ class IsolatedWorkspace(MakeDataConfig):
return []
workspace_path = dirname(__file__)
dependencies = iterate_config_directories(workspace_path)
dependencies = iterate_config_directories(workspace_path, max_depth=1)
workspace = IsolatedWorkspace(workspace_path, dependencies)
graph = ProjectGraph(workspace)
graph.collect_dependencies(workspace)
+9 -7
View File
@@ -36,14 +36,16 @@ def iterate_config_directories(path: str, max_depth: int = 5) -> Iterable['MakeD
from .language import MakeDataConfig
path = abspath(path)
for dirpath, dirnames, filenames in os.walk(path):
if max_depth >= 0 and dirpath.count(os.sep, len(path) + 1) > max_depth:
break
relpath = os.path.relpath(dirpath, path)
if relpath == ".":
current_depth = 0
else:
current_depth = relpath.count(os.path.sep) + 1
for relative_directory in dirnames:
if os.path.basename(relative_directory) == "output":
continue
working_directory = join(dirpath, relative_directory)
config = MakeDataConfig.of(working_directory)
if max_depth >= 0 and current_depth >= max_depth:
del dirnames[:]
config = MakeDataConfig.of(dirpath)
if config:
yield config
+5 -3
View File
@@ -2,9 +2,8 @@ import subprocess
from os.path import basename, isdir, isfile, join, relpath
from .context import GLOBALS
from .errors import abort
from .hglob import glob
from .logger import error, failure, print, success
from .logger import attention, error, failure, print, success
from .modpack import get_modpack_push_directory
from .shell import InteractiveSession, Progress
from .utils import DEVNULL
@@ -26,18 +25,21 @@ def push_everything(push_unchanged: bool = True, cleanup_remote: bool = True) ->
result = push_directory(GLOBALS.PROJECT_STRUCTURE.directory, destination_directory, push_unchanged=push_unchanged, cleanup_remote=cleanup_remote)
if result > 0:
return result
for linked_resource in GLOBALS.LINKED_RESOURCE_STORAGE.iterate_resources():
project_path = GLOBALS.MAKE_CONFIG.get_relative_path(linked_resource["relative_path"])
remote_path = destination_directory + "/" + linked_resource["output_path"]
remote_push_unchanged = linked_resource["push_unchanged"] if "push_unchanged" in linked_resource else push_unchanged
remote_cleanup_remote = linked_resource["cleanup_remote"] if "cleanup_remote" in linked_resource else cleanup_remote
if isfile(project_path):
result = push_file(project_path, remote_path, push_unchanged=remote_push_unchanged, cleanup_remote=remote_cleanup_remote) or result
elif isdir(project_path):
result = push_directory(project_path, remote_path, push_unchanged=remote_push_unchanged, cleanup_remote=remote_cleanup_remote) or result
else:
print()
abort(f"We cannot push {linked_resource['relative_path']!r} resource because we could not determine its type!")
attention(f"We cannot push {linked_resource['relative_path']!r} resource because we could not find it in project directory!")
if result > 0:
return result
if result < 0:
+1 -1
View File
@@ -139,7 +139,7 @@ def build_package() -> int:
elif isdir(input_resource):
copy_directory(input_resource, output_package_resource)
else:
attention(f"We cannot copy resource {linked_resource['relative_path']!r} because we could not determine its type.")
attention(f"We cannot copy resource {linked_resource['relative_path']!r} because we could not find it in project directory.")
for path in GLOBALS.MAKE_CONFIG.obtain_list("excludeFromRelease"):
for excluded_path in expand_paths(join(output_package_directory, path)):