solidworks_mcp.progress.com_coverage¶
solidworks_mcp.progress.com_coverage ¶
How much of the SolidWorks COM API the adapters call, counted by text.
The method names come from a committed snapshot of the type library, so
counting needs no SolidWorks. A name counts as called when the adapter
source uses it as an attribute (model.ForceRebuild3) or passes it as a
string (flag_members(obj, "EditDelete")). A name scan can't tell
IFeature.Name from IComponent2.Name, so the figures are approximate.
Attributes¶
CORE_INTERFACES
module-attribute
¶
CORE_INTERFACES = ('ISldWorks', 'IModelDoc2', 'IModelDocExtension', 'IPartDoc', 'IAssemblyDoc', 'IDrawingDoc', 'IFeatureManager', 'ISketchManager', 'ISelectionMgr', 'IComponent2', 'IFeature', 'ISketch')
Classes¶
ComCoverage
dataclass
¶
ComCoverage(interfaces: tuple[InterfaceCoverage, ...], api_covered: int, api_total: int, type_library: str)
Coverage of the core interfaces and of the whole API.
Attributes:
| Name | Type | Description |
|---|---|---|
interfaces |
tuple[InterfaceCoverage, ...]
|
One entry per core interface, in |
api_covered |
int
|
Distinct method names called, across the whole API. |
api_total |
int
|
Distinct method names in the whole API. |
type_library |
str
|
The snapshot's source, which carries its version. |
InterfaceCoverage
dataclass
¶
The methods of one interface that the adapters call.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The interface, e.g. |
covered |
tuple[str, ...]
|
The called method names, sorted. |
total |
int
|
How many methods the interface has. |
Snapshot
dataclass
¶
The type library's interface and method names.
Attributes:
| Name | Type | Description |
|---|---|---|
type_library |
str
|
Where it came from (the gen_py wrapper's name). |
interfaces |
Mapping[str, frozenset[str]]
|
Interface name to its method names. |
Methods:¶
from_json
classmethod
¶
Read a snapshot written by :meth:to_json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The JSON text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Snapshot |
Snapshot
|
The parsed snapshot. |
Source code in src/solidworks_mcp/progress/com_coverage.py
load
classmethod
¶
Read the committed snapshot file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The snapshot's path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Snapshot |
Snapshot
|
The parsed snapshot. |
Source code in src/solidworks_mcp/progress/com_coverage.py
to_json ¶
The snapshot as committed: sorted, one interface per line.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON text ending in a newline. |
Source code in src/solidworks_mcp/progress/com_coverage.py
Functions:¶
adapter_sources ¶
The text of every Python file under the adapters package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapters_dir
|
Path
|
|
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: One string per file, in path order. |
Source code in src/solidworks_mcp/progress/com_coverage.py
called_names ¶
Capitalised names the source uses as attributes or string literals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
Iterable[str]
|
The text of each source file. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
set[str]: Candidate COM member names (not yet matched to the API). |
Source code in src/solidworks_mcp/progress/com_coverage.py
measure ¶
Coverage of the core interfaces and the whole API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
Snapshot
|
The type library's names. |
required |
called
|
set[str]
|
Names found in the adapter source. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ComCoverage |
ComCoverage
|
The counts. |