Skip to content

Commit 19e57a7

Browse files
committed
address review comments
1 parent 377e46f commit 19e57a7

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

docs/architecture.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@ SPDX-License-Identifier: Apache-2.0
66

77
# Architecture of `opossum-file`
88

9-
![Architecture diagram](opossum-file-architecture.png)
109
The `opossum-file` package is composed of three primary components:
1110

12-
1. **Input format readers**: responsible for reading and converting different input file formats into the internal `Opossum` representation.
13-
1. **Internal representation**: a data structure used for all operations on `opossum` files, such as merging, which provides an easier-to-work-with format than the on-disk representation.
14-
1. **On-disk representation**: the format used to save `opossum` files to disk, defined using `pydantic`.
11+
1. [**Input format readers**](#input-format-readers): responsible for reading and converting different input file formats into the internal `Opossum` representation.
12+
1. [**Internal representation**](#internal-representation-of-opossum-files): a data structure used for all operations on `opossum` files, such as merging, which provides an easier-to-work-with format than the on-disk representation.
13+
1. [**On-disk representation**](#on-disk-opossum-format): the format used to save `opossum` files to disk, defined using `pydantic`.
14+
15+
![Architecture diagram](opossum-file-architecture.png)
1516

1617
The following sections provide a detailed overview of each component.
1718

18-
## Reading Input Formats
19+
## Input format readers
1920

20-
`opossum-file` supports multiple input file formats, which are converted into the internal `Opossum` representation before further processing. This conversion is facilitated by the `InputReader` interface, which consists of a single method `read() -> Opossum`. The file path is set via the constructor, and a complete invocation example is `ScancodeFileReader(path).read()`.
21+
`opossum-file` supports multiple input file formats, which are converted into the internal `Opossum` representation before further processing. This conversion is facilitated by the `InputReader` interface, which consists of a single method `read() -> Opossum`. The file path is set via the constructor, a complete invocation example is `ScancodeFileReader(path).read()`.
2122

2223
### Adding a New Input File Reader
2324

2425
To add support for a new input file format, follow these steps:
2526

26-
1. Create a new subfolder in `src/opossum_lib/input_formats/<format_name>` for the format.
27+
1. Create a new subfolder in `src/opossum_lib/input_formats/<format_name>`.
2728
1. Define the schema using `pydantic` (if applicable) in `<format_name>/entities`.
2829
1. Implement the conversion from the new schema to `Opossum` in `<format_name>/services/convert_to_opossum.py`.
2930
1. Write tests for the new format, mirroring the folder structure in `tests`.
@@ -39,8 +40,6 @@ All operations on `opossum` files, such as merging, are performed using an inter
3940

4041
This data structure ensures consistency between `resources`, `resourcesToAttribution`, and `externalAttributions` without requiring updates to multiple locations.
4142

42-
When working with resources, note that the object referenced by the `resources` field of `ScanResults` is an instance of `RootResource` (see [`root_resource.py`](src/opossum_lib/core/entities/root_resource.py)). This class manages the business logic of adding additional `Resource`s via its `add_resource` method.
43-
4443
## On-Disk Opossum Format
4544

46-
The on-disk format of `opossum` files is defined using `pydantic` in `src/opossum_lib/shared/entities`. The conversion between the internal `Opossum` and `OpossumFileModel` is implemented in `src/opossum_lib/input_formats/opossum/services`, following the same structure as other input file formats. To write an instance of `OpossumFileModel` to file, use the `write_opossum_file` function from `src/opossum_lib/core/services/write_opossum_file.py`.
45+
The on-disk format of `opossum` files is defined using [`pydantic`](https://docs.pydantic.dev/latest/) in [`opossum_file_model.py`](%60../src/opossum_lib/shared/entities/opossum_file_model.py%60). The conversion between the internal `Opossum` and `OpossumFileModel` is implemented in [`convert_to_opossum.py`](%60src/opossum_lib/input_formats/opossum/services/convert_to_opossum.py%60), following the same structure as other input file formats. To write an instance of `OpossumFileModel` to file, use the `write_opossum_file` function from [`write_opossum_file.py`](%60../src/opossum_lib/core/services/write_opossum_file.py%60).

docs/opossum-file-architecture.png

4.78 KB
Loading

src/opossum_lib/shared/services/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)