Skip to content

Commit 5030bc0

Browse files
mzuennimpsijm
authored andcommitted
use more absolute
1 parent a0736af commit 5030bc0

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

bin/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@
9393
SEED_DEPENDENCY_RETRIES: Final[int] = 10
9494

9595
# The root directory of the BAPCtools repository.
96-
TOOLS_ROOT: Final[Path] = Path(__file__).resolve().parent.parent
96+
TOOLS_ROOT: Final[Path] = Path(__file__).absolute().parent.parent
9797

9898
# The directory from which BAPCtools is invoked.
99-
current_working_directory: Final[Path] = Path.cwd().resolve()
99+
current_working_directory: Final[Path] = Path.cwd().absolute()
100100

101101
# Add third_party/ to the $PATH for checktestdata.
102102
os.environ["PATH"] += os.pathsep + str(TOOLS_ROOT / "third_party")

bin/problem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class Problem:
319319

320320
def __init__(self, path: Path, tmpdir: Path, label: Optional[str] = None):
321321
# The problem name/shortname, which is the name of the directory and used as a display name.
322-
self.name = path.resolve().name
322+
self.name = path.name
323323
# The Path of the problem directory.
324324
self.path = path
325325
self.tmpdir: Path = tmpdir / self.name

bin/program.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ def __init__(
141141
# Set self.name and self.tmpdir.
142142
# Ideally they are the same as the path inside the problem, but fallback to just the name.
143143
try:
144-
# Only resolve the parent of the program. This preserves programs that are symlinks to other directories.
145-
relpath = (path.parent.resolve() / path.name).relative_to(
146-
problem.path.resolve() / self.subdir
147-
)
144+
relpath = path.absolute().relative_to(problem.path.absolute() / self.subdir)
148145
self.short_path = relpath
149146
self.name: str = str(relpath)
150147
self.tmpdir = problem.tmpdir / self.subdir / relpath

bin/skel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ def copy_skel_dir(problems):
335335

336336
# NOTE: This is one of few places that prints to stdout instead of stderr.
337337
def create_gitlab_jobs(contest: str, problems: list[Problem]):
338-
git_root_path = Path(os.popen("git rev-parse --show-toplevel").read().strip()).resolve()
338+
git_root_path = Path(os.popen("git rev-parse --show-toplevel").read().strip()).absolute()
339339

340340
def problem_source_dir(problem: Problem):
341-
return problem.path.resolve().relative_to(git_root_path)
341+
return problem.path.absolute().relative_to(git_root_path)
342342

343343
if config.args.latest_bt:
344344
header_yml = (config.TOOLS_ROOT / "skel/gitlab_ci/header_latest_bt.yaml").read_text()
@@ -347,7 +347,7 @@ def problem_source_dir(problem: Problem):
347347
print(header_yml)
348348

349349
contest_yml = (config.TOOLS_ROOT / "skel/gitlab_ci/contest.yaml").read_text()
350-
contest_path = Path(".").resolve().relative_to(git_root_path)
350+
contest_path = Path(".").absolute().relative_to(git_root_path)
351351
changes = "".join(
352352
f" - {problem_source_dir(problem)}/{pdf_type.path().parent}/**/*\n"
353353
for problem in problems

bin/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def is_problem_directory(path):
8585
level: Optional[Literal["problem", "problemset"]] = None
8686
if config.args.contest:
8787
# TODO #102: replace cast with typed Namespace field
88-
contest = cast(Path, config.args.contest).resolve()
88+
contest = cast(Path, config.args.contest).absolute()
8989
os.chdir(contest)
9090
level = "problemset"
9191
if config.args.problem:
9292
# TODO #102: replace cast with typed Namespace field
93-
problem = cast(Path, config.args.problem).resolve()
93+
problem = cast(Path, config.args.problem).absolute()
9494
level = "problem"
9595
os.chdir(problem.parent)
9696
elif is_problem_directory(Path(".")):

bin/upgrade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ def upgrade_output_validators(problem_path: Path, bar: ProgressBar) -> None:
184184

185185
def move(src: str, dst: str) -> None:
186186
if Path(src).is_symlink():
187-
src_dst = Path(src).resolve()
187+
src_dst = Path(src).absolute()
188188
if src_dst.is_relative_to(content[0]): # local symlink
189189
Path(src).rename(dst)
190190
else: # link outside output_validators/
191-
dst_pos = Path(dst).resolve()
191+
dst_pos = Path(dst).absolute()
192192
common = [
193193
a
194194
for a, b in zip(reversed(src_dst.parents), reversed(dst_pos.parents))

bin/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def copytree_and_substitute(
10461046
pass
10471047
elif preserve_symlinks and os.path.islink(src):
10481048
shutil.copy(src, dst, follow_symlinks=False)
1049-
elif os.path.islink(src) and src.resolve().is_relative_to(base):
1049+
elif os.path.islink(src) and src.absolute().is_relative_to(base.absolute()):
10501050
shutil.copy(src, dst, follow_symlinks=False)
10511051
elif os.path.isdir(src):
10521052
names = os.listdir(src)

0 commit comments

Comments
 (0)