Skip to content

Commit cb3f2f4

Browse files
committed
bug fix
1 parent ae4d598 commit cb3f2f4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

snippets/utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,14 @@ def _read2list(file_path, **kwargs):
210210
rs = []
211211
for f in file_path:
212212
logger.info(f"reading file_path={f}")
213-
rs.extend(_read2list(f, **kwargs))
213+
tmp = _read2list(f, **kwargs)
214+
if isinstance(tmp, list):
215+
rs.extend(tmp)
216+
else:
217+
rs.append(tmp)
218+
if len(file_path) == 1 and len(rs)==1 and file_path[0].endswith(".json"):
219+
rs = rs[0]
220+
214221
return rs
215222

216223

tests/test_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ def test_load(self):
6767
data = load("data/sample.*")
6868
print(len(data))
6969
self.assertEquals(len(data), 6)
70+
data = load("/Users/chenhao/workspace/XAgents/knowledge_base/test_service/config.json")
71+
print(data)
7072

7173

0 commit comments

Comments
 (0)