Skip to content

Commit

Permalink
Allowing stand-alone Python packages to be discovered as workspace pa…
Browse files Browse the repository at this point in the history
…ckages for parallel scans. (sscpac#396)
  • Loading branch information
tdenewiler authored Dec 9, 2021
1 parent e5be4c0 commit 6d6c871
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,27 +567,32 @@ within the workspace.
Each ROS package will then get a unique directory of results in the Statick output directory.
This can be helpful for presenting results using various reporting plugins.

For example, suppose you have the following directory layout for the ROS workspace.
Stand-alone Python packages are also identified as individual packages to scan when using the `-ws` flag.
Statick looks for a `setup.py` or `pyproject.toml` file in a directory to identify Python packages.

For example, suppose you have the following directory layout for the workspace.

* /home/user/ws
* src
* package1
* package2
* python_package1
* ros_package1
* ros_package2
* subdir
* package3
* package4
* package5
* python_package2
* ros_package3
* ros_package4
* ros_package5
* build
* devel

Statick should be run against the ROS workspace source directory.
Statick should be run against the workspace source directory.
Note that you can provide relative paths to the source directory.

```shell
statick /home/user/ws/src --output-directory <output directory> -ws
```

Statick can also run against a subset of the source directory in a ROS workspace.
Statick can also run against a subset of the source directory in a workspace.

```shell
statick /home/user/ws/src/subdir --output-directory <output directory> -ws
Expand Down
3 changes: 2 additions & 1 deletion statick_tool/statick.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def run_workspace(

ignore_packages = self.get_ignore_packages()
ignore_files = ["AMENT_IGNORE", "CATKIN_IGNORE", "COLCON_IGNORE"]
package_indicators = ["package.xml", "setup.py", "pyproject.toml"]

packages = []
for root, dirs, files in os.walk(parsed_args.path):
Expand All @@ -471,7 +472,7 @@ def run_workspace(
for sub_dir in dirs:
full_dir = os.path.join(root, sub_dir)
files = os.listdir(full_dir)
if "package.xml" in files and not any(
if any(item in package_indicators for item in files) and not any(
item in files for item in ignore_files
):
if ignore_packages and sub_dir in ignore_packages:
Expand Down

0 comments on commit 6d6c871

Please sign in to comment.