Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions glom/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,14 +919,31 @@ def __init__(self, *subspecs, **kwargs):
def glomit(self, target, scope):
skipped = []
for subspec in self.subspecs:
try:
ret = scope[glom](target, subspec, scope)
if not self.skip_func(ret):
break
skipped.append(ret)
except self.skip_exc as e:
skipped.append(e)
continue
if isinstance(subspec, list):
ret = []
for i,subspec_item in enumerate(subspec,start=1):
try:
ret_item = scope[glom](target, subspec_item, scope)
if not self.skip_func(ret_item):
ret.append(ret_item) # 只追加有效结果
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weishenme zhongwen zheli lai le? :P

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am Chinese ,you can change it to english , # 只追加有效结果 means , only add useful result

else:
skipped.append(ret_item)

except self.skip_exc as e:
skipped.append(e)
continue
if ret: # 如果收集到有效结果,返回
return ret
# 如果 ret 为空,继续外层循环
else:
try:
ret = scope[glom](target, subspec, scope)
if not self.skip_func(ret):
break
skipped.append(ret)
except self.skip_exc as e:
skipped.append(e)
continue
else:
if self.default is not _MISSING:
ret = arg_val(target, self.default, scope)
Expand Down