Skip to content

Commit 5b54ba3

Browse files
committed
Fix for reading text records.
1 parent fbe98e2 commit 5b54ba3

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hec-dss-python"
3-
version = "0.1.26"
3+
version = "0.1.28"
44
description = "Python wrapper for the HEC-DSS file database C library."
55
authors = ["Hydrologic Engineering Center"]
66
license = "MIT"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = hecdss
3-
version = 0.1.27
3+
version = 0.1.28
44
author = Hydrologic Engineering Center
55
author_email =hec.dss@usace.army.mil
66
description = Python wrapper for the HEC-DSS file database C library.

src/hecdss/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
from hecdss.regular_timeseries import RegularTimeSeries
77
from hecdss.array_container import ArrayContainer
88
from hecdss.paired_data import PairedData
9+
from hecdss.text import Text
910

src/hecdss/hecdss.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,16 @@ def _get_text(self, pathname: str):
138138
textLength = 1024
139139

140140

141-
BUFFER_TOO_SMALL = -1
141+
BUFFER_TOO_SMALL = -17
142142
textArray = []
143143
status = self._native.hec_dss_textRetrieve(pathname, textArray, textLength)
144144
while status == BUFFER_TOO_SMALL:
145145
textLength *= 2
146-
status = self._native.hec_dss_textRetrieve(pathname, textArray, textLength)
147146
if textLength > 2*1048576: # 2 MB
148147
print(f"Text record too large to read from '{pathname}'")
149148
return None
149+
textArray = [] # otherwise we get an entry for each attempt
150+
status = self._native.hec_dss_textRetrieve(pathname, textArray, textLength)
150151

151152
if status != 0:
152153
print(f"Error reading text from '{pathname}'")

0 commit comments

Comments
 (0)