aboutcode-org / aboutcode-org/scancode-toolkit
Feedback on using `run_scan` from Python
- Ngôn ngữ chính
- Python
- Star
- 2.6k
- Fork
- 791
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 5
Mô tả
I've started to use the internal ScanCode API to run my scans using `run_scan`.
It works great but I found minor issues on which we could improve for the Python API:
### 1. Options are not set in the `headers`
Using the command line, we got a proper list of used options during the scan:
```
'options': {
'--classify': True,
'--consolidate': True,
[...]
```
Those are missing when calling directly `run_scan`:
```
'options': {}
```
### 2. Scan options are not validated
```
run_scan(input, wrong_option=True)
```
The fact `wrong_option` is not supported is not reported. It would be nice to have a sanity check on the provided scanning options. We do have that check using the command line:
```
$ scancode --wrong_option
Error: no such option: --wrong_option
```
### 3. Different default value for `quiet`
`quiet` is False by default when using the command line but declared as True in the `run_scan` function:
```
def run_scan(
[...]
quiet=True,
```
### 4. Logging capture leak
We can capture the logging done to stdout/stderr by the command providing a `echo_func`, for example:
```
scan_log = []
def capture_scan_log(text, *args, **kwargs):
scan_log.append(text)
run_scan(
[...],
echo_func=capture_scan_log,
)
```
Everywhere is properly captured except the progress bar that is displayed and not capture:
```
[####################] 10
```
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.