Skip to content

Commit 57ec65c

Browse files
committed
Use _check_for_error, drop the CheckForError; update docstrings.
1 parent c2c9cb0 commit 57ec65c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1348
-1339
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ In general, the DLL from `dss_capi` provides more features than both the officia
3939

4040
Besides most of the COM methods, some of the unique DDLL methods are also exposed in adapted forms, namely the methods from `DYMatrix.pas`, especially `GetCompressedYMatrix` (check the source files for more information).
4141

42-
Since no GUI components are used in the FreePascal DLL, we map nearly all OpenDSS errors to Python exceptions, which seems a more natural way of working in Python. You can still manually trigger an error check by calling the function `CheckForError()` from the main module or manually checking the `DSS.Error` interface.
42+
Since no GUI components are used in the FreePascal DLL, we map nearly all OpenDSS errors to Python exceptions, which seems a more natural way of working in Python. You can still manually trigger an error check by calling the function `_check_for_error()` from the main class or manually checking the `DSS.Error` interface.
4343

4444
## Installing
4545

docs/changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ relevant. See [DSS C-API's repository](https://github.com/dss-extensions/dss_cap
1616
- New `EnergyMeterRegisters` and `GeneratorRegisters` to simplify handling register indexes from EnergyMeters (`EnergyMeterRegisters`), Generators, PVSystems, and Storage objects (these last three use `GeneratorRegisters`).
1717

1818
- Implement the DSSEvents interface. Note that this is not a popular interface and we haven't seen it used in Python with COM yet. OpenDSS comes with a couple of examples using VBA in Excel though.
19+
- Drop `CheckForError()`; use `_check_for_error()` instead (same function, but the latter doesn't pollute the public scope).
1920

2021
- Packaging: Migrate build system to `pyproject.toml` and Hatch.
2122

@@ -384,7 +385,7 @@ Major changes:
384385
- Uses `__slots__` to simplify attribute handling.
385386
- Exposes both the our classic API (e.g. `dss.v7.DSS_IR` for the immediate/direct results) and global result API (e.g. `dss.v7.DSS_GR` for the global result interface). See [DSS C-API's docs](https://github.com/dss-extensions/dss_capi/blob/master/docs/usage.md) for a detailed explanation. We default to the GR interface since it will generally be faster at the cost of a small memory overhead.
386387
- Although still experimental, the v8/PM module is more stable. If you try it, please give feedback.
387-
- Error checking is now done for most API writes. That is, if a an OpenDSS error occurs, it should cause a Python exception soon after. Previously, you need to call `CheckForError()` manually to trigger this. This change was introduced after user reports indicated that manually checking for errors is a common behavior.
388+
- Error checking is now done for most API writes. That is, if a an OpenDSS error occurs, it should cause a Python exception soon after. Previously, you need to call `_check_for_error()` manually to trigger this. This change was introduced after user reports indicated that manually checking for errors is a common behavior.
388389
- Exposes API extensions for the classes `LineGeometry`, `WireData`, `LineSpacing`, `CNData`, `TSData`, `Reactor`.
389390
- Makes most DSS classes iterable (including buses), e.g. you can now use:
390391

dss/IActiveClass.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def ActiveClassName(self) -> str:
2626
2727
Original COM help: https://opendss.epri.com/ActiveClassName.html
2828
'''
29-
return self._get_string(self.CheckForError(self._lib.ActiveClass_Get_ActiveClassName()))
29+
return self._get_string(self._check_for_error(self._lib.ActiveClass_Get_ActiveClassName()))
3030

3131
@property
3232
def AllNames(self) -> List[str]:
@@ -35,7 +35,7 @@ def AllNames(self) -> List[str]:
3535
3636
Original COM help: https://opendss.epri.com/AllNames.html
3737
'''
38-
return self.CheckForError(self._get_string_array(self._lib.ActiveClass_Get_AllNames))
38+
return self._check_for_error(self._get_string_array(self._lib.ActiveClass_Get_AllNames))
3939

4040
@property
4141
def Count(self) -> int:
@@ -44,10 +44,10 @@ def Count(self) -> int:
4444
4545
Original COM help: https://opendss.epri.com/Count.html
4646
'''
47-
return self.CheckForError(self._lib.ActiveClass_Get_Count())
47+
return self._check_for_error(self._lib.ActiveClass_Get_Count())
4848

4949
def __len__(self) -> int:
50-
return self.CheckForError(self._lib.ActiveClass_Get_Count())
50+
return self._check_for_error(self._lib.ActiveClass_Get_Count())
5151

5252
def __iter__(self):
5353
n = self.First
@@ -65,7 +65,7 @@ def First(self) -> int:
6565
6666
Original COM help: https://opendss.epri.com/First.html
6767
'''
68-
return self.CheckForError(self._lib.ActiveClass_Get_First())
68+
return self._check_for_error(self._lib.ActiveClass_Get_First())
6969

7070
@property
7171
def Name(self) -> str:
@@ -74,14 +74,14 @@ def Name(self) -> str:
7474
7575
Original COM help: https://opendss.epri.com/Name.html
7676
'''
77-
return self._get_string(self.CheckForError(self._lib.ActiveClass_Get_Name()))
77+
return self._get_string(self._check_for_error(self._lib.ActiveClass_Get_Name()))
7878

7979
@Name.setter
8080
def Name(self, Value: AnyStr):
8181
if type(Value) is not bytes:
8282
Value = Value.encode(self._api_util.codec)
8383

84-
self.CheckForError(self._lib.ActiveClass_Set_Name(Value))
84+
self._check_for_error(self._lib.ActiveClass_Set_Name(Value))
8585

8686
@property
8787
def Next(self) -> int:
@@ -93,7 +93,7 @@ def Next(self) -> int:
9393
9494
Original COM help: https://opendss.epri.com/Next.html
9595
'''
96-
return self.CheckForError(self._lib.ActiveClass_Get_Next())
96+
return self._check_for_error(self._lib.ActiveClass_Get_Next())
9797

9898
@property
9999
def NumElements(self) -> int:
@@ -102,7 +102,7 @@ def NumElements(self) -> int:
102102
103103
Original COM help: https://opendss.epri.com/NumElements.html
104104
'''
105-
return self.CheckForError(self._lib.ActiveClass_Get_NumElements())
105+
return self._check_for_error(self._lib.ActiveClass_Get_NumElements())
106106

107107
@property
108108
def ActiveClassParent(self) -> str:
@@ -111,7 +111,7 @@ def ActiveClassParent(self) -> str:
111111
112112
Original COM help: https://opendss.epri.com/ActiveClassParent.html
113113
'''
114-
return self._get_string(self.CheckForError(self._lib.ActiveClass_Get_ActiveClassParent()))
114+
return self._get_string(self._check_for_error(self._lib.ActiveClass_Get_ActiveClassParent()))
115115

116116
def ToJSON(self, options: DSSJSONFlags = 0) -> str:
117117
'''
@@ -122,6 +122,6 @@ def ToJSON(self, options: DSSJSONFlags = 0) -> str:
122122
123123
Additionally, the `ExcludeDisabled` flag can be used to excluded disabled elements from the output.
124124
125-
(API Extension)
125+
**(API Extension)**
126126
'''
127-
return self._get_string(self.CheckForError(self._lib.ActiveClass_ToJSON(options)))
127+
return self._get_string(self._check_for_error(self._lib.ActiveClass_ToJSON(options)))

0 commit comments

Comments
 (0)