Skip to content

Conversation

wangjingyu001
Copy link

def wash_image(arg):
return {'images_detail': arg + '123'}

spec = {
'images': Coalesce(
[
('data.imageCategory', wash_image),
('data.anotherImagePath', wash_image)
]
)
}
data = {
'data': {
'imageCategory': 'data1',
'anotherImagePath': 'data2'
}
}

result = glom(data, spec)
print(result)

{'images': [{'images_detail': 'data1123'}, {'images_detail': 'data2123'}]}

def wash_image(arg):
    return {'images_detail': arg + '123'}

spec = {
    'images': Coalesce(
        [
            ('data.imageCategory', wash_image),
            ('data.anotherImagePath', wash_image)
        ]
    )
}
data = {
    'data': {
        'imageCategory': 'data1',
        'anotherImagePath': 'data2'
    }
}

result = glom(data, spec)
print(result)

# {'images': [{'images_detail': 'data1123'}, {'images_detail': 'data2123'}]}
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

@wangjingyu001
Copy link
Author

@mahmoud can you merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants