(scrap)
return payload
Translates scrap data to the output format
Translates scrap data to the output format
Translates scrap data to the output format
def scrap_to_payload(scrap):
    """Translates scrap data to the output format"""
    # Apply new keys here as needed (like `ref`)
    payload = {
        "name": scrap.name,
        "data": scrap.data,
        "encoder": scrap.encoder,
        "version": LATEST_SCRAP_VERSION,
    }
    # Ensure we're conforming to our schema
    try:
        json_validate(payload, scrap_schema(LATEST_SCRAP_VERSION))
    except ValidationError as e:
        raise ScrapbookDataException(
            "Scrap (name={name}) contents do not conform to required type structures: {error}".format(
                name=scrap.name or "None", error=str(e)
            ),
            [e],
        )
    return payload
def scrap_to_payload ( scrap ) : # Apply new keys here as needed (like `ref`) payload = { "name" : scrap . name , "data" : scrap . data , "encoder" : scrap . encoder , "version" : LATEST_SCRAP_VERSION , } # Ensure we're conforming to our schema try : json_validate ( payload , scrap_schema ( LATEST_SCRAP_VERSION ) ) except ValidationError as e : raise ScrapbookDataException ( "Scrap (name={name}) contents do not conform to required type structures: {error}" . format ( name = scrap . name or "None" , error = str ( e ) ) , [ e ] , ) return payload