From 1fb129d19456bef3cb96ca9853f22e760ce93f12 Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Wed, 27 Aug 2025 16:22:46 -0400 Subject: [PATCH] fix: add __iter__ and __next__ methods, and convert map object to a list object --- src/diffpy/srxconfutils/tools.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/diffpy/srxconfutils/tools.py b/src/diffpy/srxconfutils/tools.py index 2ad874a..26fa5e2 100644 --- a/src/diffpy/srxconfutils/tools.py +++ b/src/diffpy/srxconfutils/tools.py @@ -110,7 +110,7 @@ def str2Opt(opttype, optvalue): conv = StrConv(opttype) if opttype.endswith('list'): temp = re.split('\s*,\s*', optvalue) - rv = map(conv, temp) if len(temp) > 0 else [] + rv = list(map(conv, temp)) if len(temp) > 0 else [] else: rv = conv(optvalue) return rv @@ -146,6 +146,15 @@ def close(self): ''' self.fp.close() return + + def __iter__(self): + return self + + def __next__(self): + line = self.readline() + if line == '': + raise StopIteration + return line def checkCRC32(filename): '''