Skip to content

Commit 92b9997

Browse files
committed
robuster local pkg detection
1 parent 973779a commit 92b9997

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

package_xml_validation/helpers/workspace.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import xml.etree.ElementTree as ET
1616
from pathlib import Path
1717
from typing import Dict, List
18+
import os
1819

1920

2021
def find_package_dir(path: Path) -> Path:
@@ -113,11 +114,16 @@ def get_pkgs_in_wrs(path: Path) -> List[str]:
113114
try:
114115
pkg_dir = find_package_dir(path)
115116
ws_root = find_workspace_root(pkg_dir)
116-
117-
pkgs = pkg_iterator(ws_root / "src")
117+
src_dir = ws_root / "src"
118118
except Exception as e:
119119
print(f"Exception extracting local pkgs: {e}")
120-
return []
120+
if pkg_dir and os.path.exists(pkg_dir.absolute()):
121+
print(f"Attempting to extract local pkgs from {pkg_dir}")
122+
src_dir = pkg_dir.parent
123+
else:
124+
print(f"Unable to extract local pkgs")
125+
return []
126+
pkgs = pkg_iterator(src_dir)
121127
return sorted(pkgs)
122128

123129

0 commit comments

Comments
 (0)