1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
try:
# Shopify serializes receipts in YAML format, and yaml.safe_load will
# not automatically load custom types because of security purpose,
# so create safe loaders for types returned from Shopify here.
#
# The YAMLObject metaclass will automatically add these classes to
# the list of constructors for yaml.safe_load to use.
import yaml
class YAMLHashWithIndifferentAccess(yaml.YAMLObject):
yaml_tag = "!map:ActiveSupport::HashWithIndifferentAccess"
yaml_loader = yaml.SafeLoader
@classmethod
def from_yaml(cls, loader, node):
return loader.construct_mapping(node, cls)
except ImportError:
pass
|