uranusjr commented on code in PR #33626:
URL: https://github.com/apache/airflow/pull/33626#discussion_r1302423356
##########
dev/breeze/src/airflow_breeze/utils/add_back_references.py:
##########
@@ -119,17 +104,15 @@ def generate_back_references(link: str, base_path: Path):
old_to_new.append(("index.html", "security.html"))
old_to_new.append(("security.html", "security/security-model.html"))
- versions = [f.path.split("/")[-1] for f in os.scandir(base_path) if
f.is_dir()]
- for version in versions:
- print(f"Processing {base_path}, version: {version}")
- versioned_provider_path = base_path / version
+ versioned_provider_paths = [p for p in base_path.iterdir() if p.is_dir()]
+ for versioned_provider_path in versioned_provider_paths:
+ print(f"Processing {base_path}, version:
{versioned_provider_path.name}")
for old, new in old_to_new:
# only if old file exists, add the back reference
- if os.path.exists(versioned_provider_path / old):
- split_new_path = new.split("/")
- file_name = new.split("/")[-1]
- dest_dir = versioned_provider_path.joinpath(*split_new_path[:
len(split_new_path) - 1])
+ if (versioned_provider_path / old).exists():
+ *split_new_path, file_name = new.rsplit("/")
+ dest_dir = versioned_provider_path.joinpath(*split_new_path)
Review Comment:
```suggestion
split_new_path, file_name = new.rsplit("/", 1)
dest_dir = versioned_provider_path.joinpath(split_new_path)
```
Avoid some unnecessary splitting
--
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]